-
Notifications
You must be signed in to change notification settings - Fork 988
[Feature]: Option to disable inspect.stack()
calls for performance optimization
#2744
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
Comments
+1 |
Do you have in comparison how much time the actual page.goto/click/fill etc's took? Lets say 1s in average with network resources around different origins and sometimes even iframes etc. This should be way larger and demonstrate that its not worth investing into that end (inspector.stack). |
I think I might be affected by this, too. In my case, I load a page, check to make sure that a certain amount of buttons are visible, then execute a few thousand Profiling results Use case I have a game written in JavaScript, and I'm using Pytorch to train an AI to play the game. I use Playwright to load the page and then play the game via JS calls: As an aside: Is Thanks! :) |
I think I might have a fix for this that improves performance and doesn't require a special flag! :) I'm currently running some tests, and if they're successful, I'll probably open a PR within the next few days, God willing. |
I've opened two PRs to fix this:
|
🚀 Feature Request
Summary
playwright-python currently makes frequent calls to inspect.stack, which significantly impacts performance in certain use cases, such as web scraping with scrapy-playwright. This feature request proposes adding an option to disable stack inspections to improve execution speed when debugging information is not required.
Use case
Although Playwright is primarily designed for end-to-end testing, some projects leverage it for web scraping, where performance is a key concern. In my case, I am using scrapy-playwright, and profiling results from cProfile indicate that
inspect.stack
calls contribute to roughly 25% of the total execution time, as illustrated in the following icicle and call graph:As far as I can tell, these calls are primarily used for debugging and are not critical for normal execution.
Proposed solution
Introduce an environment variable (e.g.: PW_INSPECT_STACK) that allows users to disable stack inspections when debugging is not required. The default value would be 1 to preserve the current behavior.
Motivation
The text was updated successfully, but these errors were encountered: