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

Improve import startup time #2074

Closed
wants to merge 1 commit into from
Closed

Conversation

Viicos
Copy link

@Viicos Viicos commented Feb 15, 2024

Attempt to fix #2073. With these changes:

$ time python -c 'import weasyprint'

real	0m0.124s
user	0m0.106s
sys	0m0.020s

@Viicos Viicos force-pushed the improve-startup-time branch 2 times, most recently from 0eca1cc to fc6ebc5 Compare February 15, 2024 16:52
@grewn0uille grewn0uille marked this pull request as draft February 15, 2024 16:58
@Viicos Viicos force-pushed the improve-startup-time branch from fc6ebc5 to f9616de Compare February 15, 2024 17:54
return [HTML5_UA_COUNTER_STYLE.copy()]

def _ph_stylesheets(self):
from .html import HTML5_PH_STYLESHEET
Copy link
Author

@Viicos Viicos Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed with failing tests that I also had to import them in methods as well. So the __getattr__ machinery I added is only there for backwards compatibility in case e.g. users are importing from weasyprint import HTML_UA_COUNTER_STYLE

@Viicos Viicos force-pushed the improve-startup-time branch from f9616de to 449400f Compare February 15, 2024 19:27
@Viicos Viicos marked this pull request as ready for review February 15, 2024 20:02
@Viicos
Copy link
Author

Viicos commented Feb 15, 2024

Tested locally and tests are passing

@Viicos Viicos closed this Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve import startup time
1 participant