Should we cache some small properties?
See original GitHub issueI was doing some profiling on isel
, and see there are some properties that (I think) never change, but are called frequently. Should we cache these on their object?
Pandas uses cache_readonly for these cases.
Here’s a case: we call LazilyOuterIndexedArray.shape
frequently when doing a simple indexing operation. Each call takes ~150µs. An attribute lookup on a python object takes ~50ns (i.e. 3000x faster). IIUC the result on that property should never change.
I don’t think this is the solution to performance issues, and there’s some additional complexity. Could they be easy & small wins, though?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Caching data with class properties - why is it a bad idea?
Strictly speaking it is not a bad idea per se, in that it will do you what you expect it to do and...
Read more >Resolving Inefficient Cache Usage - IBM
Following are the different ways in which inefficient use of cache can be resolved, depending on the identified cause: Improperly Tuned Cache Performance...
Read more >Best practices for caching in Spark SQL - Towards Data Science
In Spark SQL caching is a common technique for reusing some computation. ... We will use the following dataset and cluster properties:
Read more >What is Caching and How it Works - AWS
A cache is a high-speed data storage layer which stores a subset of data, typically transient in nature, so that future requests for...
Read more >Information about using disk drive caches with SQL Server ...
To fully secure your data, you should ensure that all data caching is properly handled. In many situations, this means you must disable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
By reading the implementation of cachedproperty, it needs a
__dict__
. It should be straightforward to write a variant that uses slots though.Output (uncached):