4 ms·
> In my mind this is a holdover from when Python was much more procedural/C-like That never existed. Or if it did, it was long before any trace exists, and the
by masklinn 3y ago
> In my mind this is a holdover from when Python was much more procedural/C-like
That never existed. Or if it did, it was long before any trace exists, and there's trace from quite a way back when e.g. the first commit in which I can find the len() builtin (https://github.com/python/cpython/commit/c636014c430620325f8d213e9ba10d925991b8d7 https://github.com/python/cpython/commit/c636014c430620325f8...) also has calls to file.read and list.append, and the first python-level methods are created just a few commits later (https://github.com/python/cpython/commit/336f2816cd3599b0347a7fe35d1286d9e38596a0 https://github.com/python/cpython/commit/336f2816cd3599b0347...). Though there may be missing commits, this is 30 in, back when Python was an internal CWI thing (although nearly a year in, according to the official timelines of the early days).
This was years before magic methods were even added (https://github.com/python/cpython/commit/04691fc1c1bb737c0db772f5c1ea697a351a01d9 https://github.com/python/cpython/commit/04691fc1c1bb737c0db...).
So no, I don't think it's a "holdover from" anything. Rather seems like it's GvR's sensibilities.
- JimDabell 3y agoYou’re correct. In GvR’s own words: https://mail.python.org/pipermail/python-3000/2006-November/004643.html https://mail.python.org/pipermail/python-3000/2006-November/...
- masklinn 3y agoThanks. I may have already read that post (or I just correctly backtracked the reasoning), as I was pretty much convinced namespacing conflict (the second bit of rationale) was a factor for the dunder-ing of methods, but I had no source so ultimately decided not to put it in.
- movpasd 3y agoThanks for the thorough correction. I think I was making that assumption due to the semantics of the language, which suggests classes and methods being somewhat "bolted onto" a dict-based core. Unfortunately for me, it makes me all the more dissatisfied with the choice.