-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delay import of sympy until actually needed.
sympy is a rather slow import (~330ms for me) which contributes nearly half of bezier's import time (~750ms). Delay the import until actually needed. As a typical use case where this is visible: I have a command-line utility which does some computation using bezier. Right now invoking something as simple as `my-program --help` takes over a second to complete (certainly a noticeable delay), in particular due to such slow imports -- even if I do not use the symbolic computation part at all. Obviously there are other ways in which this can be implemented, e.g. by duplicating the `try... except ImportError` in each function, or with another helper function, but given that you already have a requires_sympy decorator, I thought I may as well reuse it for this purpose.
- Loading branch information
Showing
2 changed files
with
21 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters