-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-45455: Set func.__doc__ lazily.
#28704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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