Note about difference between __new__ and __init__
Before explaining missing functionality let's get back to definition of __new__ and __init__:
__new__ is the first step of instance creation. It's called first, and is responsible for returning a new instance of your class.
However, __init__ doesn't return anything; it's only responsible for
initializing the instance after it's been created.
Consequences of replacing __init__ with __new__
Mainly you would lose out on flexibility. You would get a lot of semantics headaches and loose separation of initializatin and construction (by joining __new__ andinit we are to joining construction and initialization into one step...).
Let's take a look on snippet below:
class A(object):
some_property = 'some_value'
def __new__(cls, *args, **kwargs):
obj = object.__new__(cls, *args, **kwargs)
obj.some_property = cls.some_property
return obj
class B(A):
some_property = 2
def __new__(cls, *args, **kwargs):
obj = super(B, cls).__new__(cls)
return obj
Consequences of moving __init__ actions into __new__:
Initialize B before A: When you are using __new__ method instead of __init__ your first step of creating new instance of B is calling A.__new__ as side effect you cannot initialize B before A is initialized ( access and assign some properties to new B instance). Using of __init__ gives you such flexability.
Loose control on initializing order: let's imagine that you have B_N inherited from two classes (A_N1, A_N2), now you would miss controlling of order of initializing new instance of B_N(what is the order you are going to initialize instances ? it could be matter... what is weird.)
Properties and methods mess: you would miss access to A.some_property (cls would be equal to B while instantiating new instance of B. However directly accessing of A.some_property is possible, but my guess it's at least weird to access properties within class throught class name and not by using classmethods).
You cannot re-initialize an existed instance without creating new one or implementation special logic for this ( thanks to @platinhom for idea )
What can __init__ do that __new__ cannot?
There are no actions that cannot be done in __new__ and can in __init__, because actions that __init__ performs is a subset of the actions that can be performed by __new__.
An interesting moment from Python Docs, Pickling and unpickling normal class instances#object.getinitargs regarding when __init__ could be usefull:
When a pickled class instance is unpickled, its init() method is normally not invoked.
__new__is the constructor,__init__is the initializer" - why do people keep saying this? In what bizarre definition is__init__not a constructor? It takes an allocated, uninitialized object and brings it into an initialized, usable state. This is what constructors do in pretty much every language that has constructors. I'm not aware of any definition under which the constructor is responsible for allocation like__new__. Python has its weird allocator/secondary constructor thing in__new__because it turned out the first constructor design wasn't quite flexible enough. - user2357112 supports Monica__new__returns an instance and__init__initializes it, and it's convenient to have a clear way to distinguish between these two processes. True,__new__can do initialization, and it may return an existing instance rather than allocating a fresh one (but when that happens__init__isn't automatically invoked). But__init__shouldn't create an instance: it expects to be passed an instance that it can initialize. If you wish to refer to both of these methods as constructors, feel free, but that's not the usual Python convention. - PM 2Ring