[Python-Dev] Overloading comparison operator for lists

2019年5月26日 20:59:58 -0700

NumPy arrays have this awesome feature, where array == 3 does an
element-wise comparison and returns a list. For example:
np.array([1,2,3,4,5])==3
returns
[False,False,True,False,False]
It would be cool if Python had similar functionality for lists.
If that is not possible, perhaps we could consider allowing developers to
overload operators on built-in types within the context of a project or
module. For example, an overload in one module would have no effect on the
same operator in a different module (such as any Python standard modules.)
Additionally, let's then give the developers the option to explicitly
import an overload from other modules. So, people could develop a module
with the purpose of providing overloads that make complete sense within a
certain context.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to