On Sun, 05 Jan 2020 12:37:24 +1300
Greg Ewing wrote:
> On 5/01/20 11:41 am, Antoine Pitrou wrote:
>
> > +1 for pointing to `weakref.finalize` as a better
> > alternative for things that may survive until interpreter shutdown.
>
> I'm not sure that weakref.finalize is much better. It can still
On Fri., 3 Jan. 2020, 3:52 am Yonatan Zunger, wrote:
> weakref.finalize always executes during the ordinary Python flow, IIUC --
> e.g., it happens before the interpreter is stopping. I guess it does still
> have the "arbitrary thread" limitation -- which is a good point, I may have
> some code
On 5/01/20 11:41 am, Antoine Pitrou wrote:
+1 for pointing to `weakref.finalize` as a better
alternative for things that may survive until interpreter shutdown.
I'm not sure that weakref.finalize is much better. It can still be
called at an arbitrary time from an arbitrary thread with the
On Wed, 1 Jan 2020 11:51:41 -0800
"Gregory P. Smith" wrote:
> On Wed, Jan 1, 2020 at 6:40 AM Andrew Svetlov
> wrote:
>
> > __del__ is very useful not for interpreter shutdown but as a regular
> > destructor in object's lifecycle.
> >
>
> The reason we should warn people against ever
On Sat, Jan 4, 2020 at 5:43 AM Inada Naoki wrote:
>
> I don't want to recommend atexit or weakref because they have their pitfall.
>
> I think the context manager should be considered at first when people want
> to use __del__.
>
I support this proposal :)
> --
> Inada Naoki
>
I don't want to recommend atexit or weakref because they have their pitfall.
I think the context manager should be considered at first when people want
to use __del__.
On Wed, Jan 1, 2020 at 9:35 AM Yonatan Zunger wrote:
>
> Hey everyone,
>
> I just encountered yet another reason to beware of
Jeff, I like all of your proposals. It does get a bit long, but I think
it's not so long that it feels out-of-place in the data model docs, which
is where you expect weird stuff to live. (I mean, look how long the
discussion of metaclasses is -- and I certainly wouldn't want to eliminate
that!)
On 02/01/2020 02:53, Yonatan Zunger wrote:
Oh, I'm absolutely thinking about clarity. ...
Could any revision also be clear what is *required of Python the
language* vs. what is a CPython implementation detail? I always
appreciate this care. There is good practice here and elsewhere in the
Could there be a clearer separation between the language semantics and
current CPython behavior?
On 2020-01-02 03:53, Yonatan Zunger wrote:
Oh, I'm absolutely thinking about clarity. Something like:
This method is called when the instance is about to be destroyed.
Because it may be
weakref.finalize always executes during the ordinary Python flow, IIUC --
e.g., it happens before the interpreter is stopping. I guess it does still
have the "arbitrary thread" limitation -- which is a good point, I may have
some code bugs of my own to fix. But it's a huge difference in terms of
I would say that the "recommended" weakref.finalize() shares very many
limitations of __del__(), that's why hard to buy it.
atexit.register() is not a common thing, the recommendation of using
atexit for file descriptor closing *in general* looks weird, while it
can be a good solution in some
Hi,
On Thu, 2 Jan 2020 at 03:59, Yonatan Zunger wrote:
> It is possible (though not recommended!) for the __del__() method to postpone
> destruction of the instance by creating a new reference to it. This is called
> object resurrection. It is implementation-dependent whether __del__() is
>
Oh, I'm absolutely thinking about clarity. Something like:
This method is called when the instance is about to be destroyed. Because
it may be called by either the ordinary Python execution flow or by the
garbage collector, it has very unusual semantics, and must be treated with
great care.
If the warning text tells about the delayed execution -- I'm +1.
-1 for something like "just don't use __del__, it is dangerous".
On Wed, Jan 1, 2020, 21:51 Gregory P. Smith wrote:
>
>
> On Wed, Jan 1, 2020 at 6:40 AM Andrew Svetlov
> wrote:
>
>> __del__ is very useful not for interpreter
On Wed, Jan 1, 2020 at 6:40 AM Andrew Svetlov
wrote:
> __del__ is very useful not for interpreter shutdown but as a regular
> destructor in object's lifecycle.
>
The reason we should warn people against ever implementing __del__ is that
people rarely actually understand object lifecycle. Its
__del__ is very useful not for interpreter shutdown but as a regular
destructor in object's lifecycle.
Action on the shutdown is another beast.
Personally, I prefer to do all finalization works by explicit calls instead.
On Wed, Jan 1, 2020 at 2:39 AM Yonatan Zunger wrote:
>
> Hey everyone,
>
>
16 matches
Mail list logo