Implement lazy imports for numpy and beartype to improve startup time#658
Conversation
|
Please consider formatting your code according to the standards described here: https://github.com/yukinarit/pyserde/blob/main/CONTRIBUTING.md |
273c05e to
67dd973
Compare
|
Please consider formatting your code according to the standards described here: https://github.com/yukinarit/pyserde/blob/main/CONTRIBUTING.md |
67dd973 to
a20e107
Compare
|
Please consider formatting your code according to the standards described here: https://github.com/yukinarit/pyserde/blob/main/CONTRIBUTING.md |
a20e107 to
d729cc0
Compare
d729cc0 to
ba4ad25
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR implements lazy imports for numpy and beartype dependencies to improve serde's startup time from 200+ msec to 100+ msec by deferring module imports until they are actually needed.
- Replaces direct numpy imports with wrapper functions that lazily import numpy functions when called
- Moves beartype and SQLAlchemy imports to be lazy-loaded at usage points
- Adds local imports within functions that need numpy serialization/deserialization functionality
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| serde/se.py | Replaces numpy imports with lazy wrapper functions and adds local imports in render method |
| serde/de.py | Implements lazy numpy imports with wrapper functions and adds local imports for deserialization |
| serde/msgpack.py | Moves numpy encode function import to point of usage |
| serde/json.py | Moves numpy encode function import to point of usage |
| serde/core.py | Adds blank line after beartype import |
| serde/compat.py | Implements lazy SQLAlchemy import wrapper function |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Just fyi there is this neat TID253 |
This PR improves serde import time from 200+ msec to 100+ msec.
before
after
Closes #604