super().__init__() and bytes

Roel Schroeven roel at roelschroeven.net
Wed Dec 4 06:38:33 EST 2024


Op 4/12/2024 om 0:14 schreef Greg Ewing via Python-list:
> On 4/12/24 3:24 am, Roel Schroeven wrote:
>> It's not entirely clear to me though how bytes.__new__ *can* set an 
>> object's value. Isn't __new__ also a regular function?
>
> Yes, but the __new__ methods of the builtin immutable objects (int,
> str, bytes, etc.) are implemented in C, and so are able to do things
> that Python methods cannot.
Aha, yes, that's what I already suspected, but I wasn't sure. Thanks for 
confirming that.

All clear now. Thanks to Anders and Greg for explaining this to me.

"In the old days, writers used to sit in front of a typewriter and stare out of
the window. Nowadays, because of the marvels of convergent technology, the thing
you type on and the window you stare out of are now the same thing.”
         -- Douglas Adams



More information about the Python-list mailing list