Similar to redis
and memcache
, does Python by default has a caching attached to its run time environment?
This has to be local caching.
I need to know without installing or invoking any other libraries, can I cache some data using the existing Python installation in my system.
I need to add data to a dict
, but before that if there is any default cache, I need to add to that.
Any help is appreciated!
Depends on what you need to do. If you give a function a default argument that equates to a list or dictionary and never give it an argument for that default, the function parameter could act as a cache. The reason for this is because Python evaluates its function definition at compile time, so the function argument will be loaded in at compile time. Take for example this code:
When ran like so:
the result is: