rethinkpriorities / squigglepy

Squiggle programming language for intuitive probabilistic estimation features in Python
MIT License
65 stars 8 forks source link

feat: optional/lazy imports #36

Closed agucova closed 1 year ago

agucova commented 1 year ago

This removes pandas and matplotlib as required dependencies, but lazily enables their related features when the modules are available, cutting import time significantly (> 2x). It also adds these as extras, installable with pip install squigglepy[plots] (for plotting-related functionality, matplotlib for now), pip install squigglepy[ecosystem] (for pandas, and in the future other related packages), or pip install squigglepy[all] (for all extras).

peterhurford commented 1 year ago

Nice! I'm seeing 448.81ms load time, down from 543.2ms (17% reduction)

agucova commented 1 year ago

@peterhurford how are you measuring load time? On my M1 this is at least a 2x improvement:

image

image

The profiling I did showed a 3x improvement (consistent with these benchmarks, considering the Python load time).

peterhurford commented 1 year ago

@agucova measuring load time via https://github.com/rethinkpriorities/squigglepy/blob/main/tests/integration.py#L184-L190

BTW I guess this is cheating because np is preloaded outside the timer