Open danielgafni opened 1 month ago
Hi @danielgafni!
Thanks for making a framegraph! I've never done this optimization.
Is it like moving all the imports to the code using it?
elif is_numpy_array(c):
from .numpy import deserialize_numpy_array_direct
res = deserialize_numpy_array_direct(c, o)
Yes exactly. If you need them for type annotations, you can do the following:
from typing import TYPE_CHECKING
if TYPE_CHECKING: # will NOT be executed at runtime
import numpy as np
def my_func(arg: "np.ndarray"):
...
Looks good!
Would you be able to contribute to pyserde? :slightly_smiling_face:
Maybe! I'm short on time right now but it should improve in a few weeks
awesome!
I've noticed
pyserde
contributes a fair share to my CLI app import time flamegraph (I'm usingpyserde
for app configuration so it has to be imported at top level).Here is the breakdown for
pyserde
:It's really nothing to worry about, but I guess dependencies like
numpy
andsqlalchemy
could be imported in a lazy fashion in order to further improve import times.This flamegraph can be made with tuna.