Since Python is implemented in C, I am confused how the developers managed to make the Python builtin len function run on any sequence in constant time, O(1), while C's string function strlen runs in linear time, O(n). 
What is the secret behind Python's builtin len functions's time complexity? If we were to write program in C, would it be best practice to copy Python's code for len if we ever wanted to a fast C program involves sequence length?
Any string/list in python is an object. Like many objects, it has a __len__ method, which stores the length of the list. When we call len, __len__ gets called internally, and returns the stored value, which is an O(1) operation.
What is the secret behind Python's len() builtin time complexity of O(1)