Message355226
In some circumstances, it's useful to be able in inspect the parameters with which an instance of functools.lru_cache was instantiated. It's currently possible to recover the cache's maxsize via the .cache_info() method, but there's no way to recover the value passed for `typed`, which controls whether the lru_cache's cache is partitioned by input type.
This came up in the context of cloudpickle, a library that tries to extend pickle to support more types (in particular, interactively-defined functions and classes) for use-cases like cluster computing.
It's currently not possible to pickle an lru-cache decorated function that's defined in __main__ (which includes, e.g. a Jupyter Notebook). We can **almost** fix this with a pure library solution (see https://github.com/cloudpipe/cloudpickle/pull/309), but we're currently blocked by the fact that there's no way to recover the value that was passed for `typed`. Exposing a .typed attribute on the extension type for lru_cached functions fixes this
For more discussion, see the above linked PR, along with https://github.com/cloudpipe/cloudpickle/issues/178. |
|
Date |
User |
Action |
Args |
2019-10-23 14:50:54 | Scott Sanderson2 | set | recipients:
+ Scott Sanderson2 |
2019-10-23 14:50:54 | Scott Sanderson2 | set | messageid: <1571842254.4.0.33528560442.issue38565@roundup.psfhosted.org> |
2019-10-23 14:50:54 | Scott Sanderson2 | link | issue38565 messages |
2019-10-23 14:50:54 | Scott Sanderson2 | create | |
|