Skip to content
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

[ENH] Use caching to speed up limited API exception handling code #5618

Open
da-woods opened this issue Aug 14, 2023 · 0 comments
Open

[ENH] Use caching to speed up limited API exception handling code #5618

da-woods opened this issue Aug 14, 2023 · 0 comments

Comments

@da-woods
Copy link
Contributor

Describe your issue

The current limited API exception handling code creates a minimal code object at each step, and then compiles it.

In principle a single code object could be created on program start-up, which would probably be more efficient

code_object = Py_CompileString("_getframe()", filename, Py_eval_input);

Note that with a cached version the filename wouldn't be set, so it'd need to be passed to code.update instead.

Comment where this was proposed:
#5550 (comment)

@scoder suggests caching the replace method to skip one step further. That's probably tricky given that it doesn't exist in Python 3.7. However, maybe my ultra-slow Python 3.7 workaround could be refactored into a function and cached in the same way (I'm not too worried about performance in 3.7 since it's really quite old now, but it'd be good to unify it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant