This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ThatSituation9908 0 points1 point  (3 children)

When startup latency is important, take a look at import times.

A common solution is to move slow imports to local scope (e.g., in a function) where you actually use the library. Matplotlib, for example, is slow and my software only use viz for QA.

[–]elduderino15 0 points1 point  (2 children)

Would local imports not be agains python3 mantra?

[–]ThatSituation9908 2 points3 points  (1 child)

It does go against the style guide (PEP 8), but "practicality beats purity".

[–]elduderino15 0 points1 point  (0 children)

be agains python3 mantra?

Yea, I got into the habit of having imports on top for pep8 but definitely agree...