[prev in list] [next in list] [prev in thread] [next in thread]
List: python-dev
Subject: Re: [Python-Dev] [Python-checkins] Daily reference leaks (d7e490db8d54): sum=61494
From: Steven D'Aprano <steve () pearwood ! info>
Date: 2015-10-21 22:41:42
Message-ID: 20151021224141.GO3813 () ando ! pearwood ! info
[Download RAW message or body]
On Wed, Oct 21, 2015 at 10:10:56AM -0700, Ethan Furman wrote:
> On 10/21/2015 08:53 AM, Random832 wrote:
>
> >If a pure python class can cause a reference leak, doesn't that mean it
> >is only a symptom rather than the real cause? Or is it that the use of
> >@object.__new__ is considered "too clever" to be worth fixing?
>
> Where can I find out more about using `object.__new__` as a decorator?
How about the interactive interpreter?
py> @object.__new__
... class X:
... pass
...
py> X
<__main__.X object at 0xb7b4dacc>
Consider the pre-decorator-syntax way of writing that:
class X:
pass
X = object.__new__(X)
That's a way of setting X = X(), except that it only works for X a class
(can't decorate a function this way), and it avoids calling the __init__
method.
--
Steve
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-marcsub-zyf4%40marc.info
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic