If I have a function that is called in few places in my mo开发者_如何学编程dule, does the virtual machine compiles it to native code only the first time the function is executed and than use the cashed code on the other calls? (like .NET jit compiler)
In CPython (the standard Python implementation) the first time a Python module is imported, it's compiled to bytecode and stored in a .pyc file. From then on, the .pyc file is read and interpreted by the VM when needed. Once the .pyc is read into memory, the bytecode is in memory, and interpreted by the VM when the function is called.
CPython never compiles Python code to native executable code.
精彩评论