[issue38565] Expose the value passed of typed passed to functools.lru_cache
New submission from Scott Sanderson : 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. -- components: Library (Lib) messages: 355226 nosy: Scott Sanderson2 priority: normal severity: normal status: open title: Expose the value passed of typed passed to functools.lru_cache type: enhancement versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue38565> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29235] Allow profile/cProfile to be used as context managers
Scott Sanderson added the comment: This looks like it's been dormant for a bit. I've posted a patch (with tests and docs) to https://github.com/python/cpython/pull/6808. -- nosy: +Scott Sanderson ___ Python tracker <https://bugs.python.org/issue29235> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29235] Allow profile/cProfile to be used as context managers
Change by Scott Sanderson : -- pull_requests: +6961 ___ Python tracker <https://bugs.python.org/issue29235> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29235] Allow profile/cProfile to be used as context managers
Scott Sanderson added the comment: I've posted a patch to update the docs to https://github.com/python/cpython/pull/7331. -- nosy: +Scott Sanderson2 ___ Python tracker <https://bugs.python.org/issue29235> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14611] inspect.getargs fails on some anonymous tuples
Scott Sanderson added the comment: This issue is the root cause of at least two open issues in IPython: https://github.com/ipython/ipython/issues/8293 https://github.com/ipython/ipython/issues/8205 Testing locally, the patch supplied here fixes both of those issues. Is there still work that needs to be done here? -- nosy: +Scott Sanderson ___ Python tracker <http://bugs.python.org/issue14611> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14611] inspect.getargs fails on some anonymous tuples
Scott Sanderson added the comment: Note also that a much simpler repro for this issue is: inspect.getargs(((x for _ in [0]) for x in [0]).gi_code) This triggers the same issue because the inner generator expression closes over the loop variable of the outer expression, which causes us to hit the STORE_DEREF case instead of the STORE_FAST case. -- ___ Python tracker <http://bugs.python.org/issue14611> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com