3

The CPython implementation seems to have the same modules written both in C (e.g., datetime in .c) and also in .py for the same module (e.g., datetime in .py).

My question is which version is used when I use datetime in my .py file when using the CPython interpreter? And why are there two module versions in the first place?

4

1 Answer 1

1

C code is real code, python is interface code.

The c code is the performant code, while the python is for python runtime to correctly handle call sites.

Also use the c code Version to get the most performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.