You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Performance Boost: Reducing unnecessary function calls can significantly speed up Playwright for scraping-heavy applications.
Flexibility: Users who require stack traces for debugging can leave the option enabled.
Backward Compatibility: The default behavior remains unchanged, ensuring no disruption for existing users.
The text was updated successfully, but these errors were encountered:
🚀 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: