Eric Snow added the comment:
FYI, __new__() is a staticmethod to accommodate subclassing. Several things
that happen at instantiation-time (when __new__() is called), including memory
allocation, are tied to the class that is passed in and may be different for
subclasses. For example:
class Spam(int):
def __new__(cls, value):
self = super().__new__(Spam, value)
self._eggs = 10
return self
Spam is passed in instead of int (as would happen if it were a classmethod),
resulting in extra memory being allocated for _eggs (and for __dict__ among
other things).
----------
nosy: +eric.snow
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21415>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com