how to handle cpu cache in python ( or fastest way to call a function once)

Vladimir Ignatov kmisoft at gmail.com
Sun Aug 23 08:07:26 EDT 2015


Hi,

>> for i in range(1000000): #just to create a time interval, seems this disturb cpu cache?
>>     pass

Python interpreter consumes memory quite extensively because
"everything is object".  So constructions like:

range(1000000):

_take_ memory.  Additionally it will trigger garbage collecting code
on deallocation time so expect even more delay.
To get most out of Python - all "numbers crushing" / "pixel pushing" /
"store gigabytes" code should go to low-level compiled binary
libraries.


Vladimir

https://itunes.apple.com/us/app/python-code-samples/id1025613117



More information about the Python-list mailing list