I quite like multiple dispatch. It's odd to claim it's not OOP, since a relatively old object-oriented system, the Common Lisp Object System (CLOS) uses this as it's fundamental construct.
A long time ago, I wrote about and created an example library for multimethods. Lots of other folks have done so as well. Mine was old enough to precede decorators, which I think is the best way to express it in modern Python. Guido had demonstrated a simple system when decorators were pretty new.
While I would like an implementation added to `functools`, I think it's exceptionally unlikely it would have anything to do with speeding up Python. It's a nice way to express certain programs, but not any slower or faster than other styles.
On Tue, Mar 16, 2021, 6:13 PM Greg Ewing greg.ewing@canterbury.ac.nz wrote:
On 17/03/21 2:54 am, Marvin van Aalst wrote:
it should in principle be possible to transform the code from |Class.method|to |method(class:type)|, *before compilation*essentially allowing the same optimizations.
I don't think this transformation would help with anything. If the static analysis can work out what class of object a name refers to, and what methods and attributes it has, it can generate code that is just as efficient.
-- Greg
Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ZEWMGY... Code of Conduct: http://python.org/psf/codeofconduct/