labd / commercetools-python-sdk

Commercetools Python SDK
https://commercetools-python-sdk.readthedocs.io/en/latest/
MIT License
17 stars 16 forks source link

Optimize import times #98

Closed mvantellingen closed 4 years ago

mvantellingen commented 4 years ago

Importing marshmallow schemas seems really expensive. By only import those schema needed for a certain service endpoint (and also import those lazy) we can optimize import times by ~200ms on my laptop. This is definitely interesting to minimize lambda/azure cold start times.

# This branch (auth + product query)
python foo.py  0.37s user 0.08s system 83% cpu 0.538 total

# Master branch (auth + product query)
python foo.py  0.58s user 0.08s system 88% cpu 0.747 total
codecov[bot] commented 4 years ago

Codecov Report

Merging #98 into master will decrease coverage by 3.14%. The diff coverage is 81.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #98      +/-   ##
==========================================
- Coverage   73.13%   69.98%   -3.15%     
==========================================
  Files         148      146       -2     
  Lines       26915    27037     +122     
==========================================
- Hits        19683    18921     -762     
- Misses       7232     8116     +884     
Impacted Files Coverage Δ
src/commercetools/_schemas/_graph_ql.py 0.00% <0.00%> (ø)
src/commercetools/_schemas/_me.py 0.00% <0.00%> (ø)
src/commercetools/_schemas/_message.py 75.88% <ø> (ø)
src/commercetools/_schemas/_order_edit.py 76.62% <ø> (ø)
src/commercetools/services/abstract.py 90.90% <ø> (-5.65%) :arrow_down:
src/commercetools/services/graphqls.py 0.00% <0.00%> (-75.00%) :arrow_down:
src/commercetools/services/in_stores.py 0.00% <0.00%> (-39.82%) :arrow_down:
src/commercetools/services/login.py 0.00% <0.00%> (-75.00%) :arrow_down:
src/commercetools/services/me.py 0.00% <0.00%> (-38.54%) :arrow_down:
src/commercetools/services/messages.py 0.00% <0.00%> (-69.24%) :arrow_down:
... and 157 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d984bd4...cda3a45. Read the comment docs.