top | item 40415624

(no title)

DNF2 | 1 year ago

Yes, python exposes a limited list of names that map to operators, like __add__, __sub__, __ne__, __or__, etc. The list is large enough that it covers most normal usage, but the semantic meaning of the operators is normally fixed, so creating your own more specialized operators with new meanings is not very convenient (I mean, in principle, you can overload __xor__ to do something inventive, but it's probably a bad idea to veer from the established meaning of 'exclusive or'.)

In contrast, julia provides a nearly endless list of operators to use for whatever you like, allowing you to adopt mathematical operators from your field of study, for example.

Also, I am not aware of any type promotion mechanism in python, which, in Julia, makes e.g. binary operators on different types convenient to implement. The inherent multiple dispatch also seems more natural than the __roperator__ stuff you need to do in python.

discuss

order

No comments yet.