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

Module is very slow to import #74

Open
silverwind opened this issue Apr 8, 2022 · 4 comments
Open

Module is very slow to import #74

silverwind opened this issue Apr 8, 2022 · 4 comments

Comments

@silverwind
Copy link

silverwind commented Apr 8, 2022

On my machine, it takes over 400ms to import pybars:

$ PYTHONPROFILEIMPORTTIME=1 python -c 'import pybars' |& grep pybars                                                                          
import time:       209 |        209 |     pybars._templates
import time:    203090 |     410008 |   pybars._compiler
import time:       383 |     410390 | pybars
@wbond
Copy link
Owner

wbond commented Jul 27, 2022

This is almost certainly due to the current architecture of using PyMeta and compiling the grammar when importing pybars._compiler.

I had originally had interest in rewriting the project to use a different parser (https://github.com/wbond/handlebars.py), but at this point I have too many projects to work on, so I don't foresee working on this any time soon. If there was some strong interest for this, and some corporate sponsors interested in backing the work, I might reconsider.

@wbond
Copy link
Owner

wbond commented Jul 28, 2022

Actually, it is possible that the compiled grammar could be serialized into a file on each release. That may give it enough of a performance boost. Perhaps that is something you could look into?

@silverwind
Copy link
Author

Not sure I'm motivated enough, Python is not my lingua franca. We definitely feel the pain of this import time thought, as it's used during short-lived processes, so I'm not saying I won't eventually get motivated :)

@zaafar
Copy link

zaafar commented Jul 29, 2022

Actually, it is possible that the compiled grammar could be serialized into a file on each release.|

do you mean via the CI (Github Actions) pipeline & source code modification?

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

No branches or pull requests

3 participants