ramonhagenaars / nptyping

💡 Type hints for Numpy and Pandas
MIT License
578 stars 29 forks source link

isinstance(x, NDArray) performance regression (1000x slower) #50

Closed mattgodbolt closed 1 year ago

mattgodbolt commented 3 years ago

In upgrading to 1.4.x we noticed a huge regression in performance checking isinstance(x, NDArray). Before (v1.0.1), it took a microsecond or so, after 1.4.x we see it taking 20ms.

We tracked most of this performance regression back to the call to _get_type(instance) which takes around 15-16ms.

Is this something that can be fixed, or are we stuck with this for correctness' sake.

(c.f. 3aca957ea76f761e1c324a5493f59b9d38ac6143, cc @pitluga)

ramonhagenaars commented 2 years ago

The upcoming 2.0.0 release should not have this issue anymore. You can already play with the prerelease, but note that the API has changed since v1.4.4.

ramonhagenaars commented 1 year ago

The new 2.* versions are performing better. Also, I now recommend to stack beartype with nptyping and to supress any type checking on production environments. Read more on this in the Quickstart section.

Closing this issue now.