3 ms·
The standard library has something similar: https://docs.python.org/3/library/functools.html#functools.singledispatch https://docs.python.org/3/library/functool
by skrause 7y ago
The standard library has something similar: https://docs.python.org/3/library/functools.html#functools.singledispatch https://docs.python.org/3/library/functools.html#functools.s...
- Seirdy 7y agoDitto for this; it works very well with type hints. I used it in func-analysis [0], a tool I put together to learn about duck typing. [0]: https://gitlab.com/Seirdy/func-analysis https://gitlab.com/Seirdy/func-analysis
- mlthoughts2018 7y agoCython also has had a mechanism for this for a long time. In fact if you wanted multiple dispatch in a new pure C program in 2020, just write it in Cython with no use of the CPython API and have Cython generate the pure C library for you. https://cython.readthedocs.io/en/latest/src/userguide/fusedtypes.html https://cython.readthedocs.io/en/latest/src/userguide/fusedt...
- trymas 7y agoAlso there's this: https://pypi.org/project/multipledispatch/ https://pypi.org/project/multipledispatch/
- jdc 7y agoSQLAlchemy has too this for hybrid attributes/expressions. https://docs.sqlalchemy.org/en/13/orm/mapped_sql_expr.html https://docs.sqlalchemy.org/en/13/orm/mapped_sql_expr.html