mrocklin / multipledispatch

Multiple dispatch
https://multiple-dispatch.readthedocs.io/en/latest/
Other
810 stars 72 forks source link

Cythonize `Dispatcher.__call__/resolve` #13

Open mrocklin opened 10 years ago

mrocklin commented 10 years ago

Dispatched functions currently incur about a microsecond latency. This stops them from being used in tight inner loops. The Dispatcher.__call__/resolve methods could be written in optimized Cython to reduce this duration.

multipledispatch should still be accessible from a Pure Python environment. The Cython code should be optional and should fall back onto the Python version if a C compiler is not present upon installation.

CC @eriknw , in case he's looking for another project to accelerate :)

eriknw commented 10 years ago

Sounds like a typical application of Cython. I bet I can help with this, although I have plenty on my plate for the near future. Feel free to ping me every couple of weeks or so if this still needs done and you haven't heard from me.

btw, I have been silently tracking this project, although I haven't had much input to give (hence my silence).

mrocklin commented 10 years ago

I was reminded of this topic from your attribute caching trick. Someone once mentioned to me that they wished that Python cached the last method called for fast repeated lookup. Ideally this would accelerate tight loops like for x in item: total += x. Given that we have a new dispatch mechanism I'm a little curious if we can beat the traditional CPython interpreter with better policies. The success of CyToolz has sort of blown open a set of accelerations that I had previously disregarded.

mrocklin commented 10 years ago

But yes, your plate does seem awfully full these days. I'm actually a little surprised at how much you've been able to heap on.