Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Yesterday I experimented with a patch which added the co_doc property and _PyCode_GetDoc() for extracting a docstring from code's constants. I was not sure in the usefulness of that feature, seems there are no use of co_doc in the Python code, and there is exactly one use of _PyCode_GetDoc() in the C code.
But your PR looks more interesting.
|
Do you have a bug #? Is the motivation to reduce memory overhead and performance with the docstring isn't used? |
|
@warsaw This PR is spin-off idea of bpo-36521. Motivation is faster function creation (including lambda) when docstring is not used. But performance gain is only 3~5% in micro benchmark and having backward incompatibility: P.S. I created new issue for this idea. bpo-45455. |
func.__doc__ lazy.func.__doc__ lazily.
|
This PR is stale because it has been open for 30 days with no activity. |
|
I don't see the benefit. We still use the same amount of the memory. The pointer just gets copied later rather than sooner. AFAICT, at best it saves a single INCREF. |
|
Yes. This have only 3~5% performance gain on microbenchmark. |
https://bugs.python.org/issue45455