Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
geysersam
on Aug 29, 2022
|
parent
|
context
|
favorite
| on:
Wren is a small, fast, class-based concurrent scri...
I think he meant that for Python operators, the method can be dispatched based on the first or the second argument.
csande17
on Aug 29, 2022
|
next
[–]
Yes, this is a special case that Python implements for binary operators. When evaluating "a + b", if a.__add__(b) doesn't work, it'll try b.__radd__(a). See
https://docs.python.org/3/reference/datamodel.html#object.__...
pansa2
on Aug 29, 2022
|
parent
|
next
[–]
Yeah - `__add__` then `__radd__` isn't exactly double dispatch, but it's close. (There are corner cases involving inheritance where double-dispatch will work correctly but Python's approach will fail to pick the most-specific method.)
munificent
on Aug 29, 2022
|
prev
[–]
Yes, this is what I was referring to.
Consider applying for YC's Fall 2026 batch!
Applications
are open till July 27.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: