Re: [Python-Dev] __del__ is not called after creating a new reference
Hi all,
On 20 March 2017 at 22:28, Nathaniel Smith wrote:
> Modern CPython, and all extant versions of PyPy and Jython, guarantee that
> __del__ is called at most once.
Just a note, if someone actually depends on this: it is not true in
all cases. For example, in CPython 3.5.3:
>>> class X:
... __slots__=()# <= note this!
... def __del__(self):
... print("DEL")
... global resurrect
... resurrect = self
...
>>> print(X())
<__main__.X object at 0x7f5d1ad600d0>
DEL
>>> resurrect=None
DEL
>>> resurrect=None
DEL
>>> resurrect=None
DEL
A bientôt,
Armin.
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] __del__ is not called after creating a new reference
On 04/02, Armin Rigo wrote:
>
> Hi all,
>
> On 20 March 2017 at 22:28, Nathaniel Smith wrote:
> > Modern CPython, and all extant versions of PyPy and Jython, guarantee that
> > __del__ is called at most once.
>
> Just a note, if someone actually depends on this: it is not true in
> all cases. For example, in CPython 3.5.3:
>
> >>> class X:
> ... __slots__=()# <= note this!
> ... def __del__(self):
> ... print("DEL")
> ... global resurrect
> ... resurrect = self
> ...
> >>> print(X())
> <__main__.X object at 0x7f5d1ad600d0>
> DEL
> >>> resurrect=None
> DEL
Objects/typeobject.c:type_new()
/* Enable GC unless this class is not adding new instance variables and
the base class did not use GC. */
if ((base->tp_flags & Py_TPFLAGS_HAVE_GC) ||
type->tp_basicsize > base->tp_basicsize)
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
That is. "type->tp_basicsize > base->tp_basicsize" is false if empty __slots__,
so we do not set HAVE_GC.
And PyObject_CallFinalizer() doesn't set FINALIZED if PyType_IS_GC(tp) == F.
Oleg.
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] why _PyGen_Finalize(gen) propagates close() to _PyGen_yf() ?
Nathaniel Smith writes: > > Well, I'm afraid to contact this closed and not-for-mortals list, > > not sure this very basic question should go there ;) perhaps you > > are already a member, feel free to forward. > > core-mentorship is intended as a friendly place for folks who are > starting to study CPython internals. I'm not sure where you got the > impression that it's not-for-mortals but I suspect the people > running it would like to know so they can fix it :-). I imagine Oleg got that impression because he tried to access the archives, which are closed to non-members. I don't recall the rationale for that but there was one, I suspect that won't change. IMO, the listinfo https://mail.python.org/mailman/listinfo/core-mentorship makes it clear that developers new to Python core code (whether they are new or advanced developers in other code bases) are welcome. If it's something else, we would *definitely* like to know. Steve ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] why _PyGen_Finalize(gen) propagates close() to _PyGen_yf() ?
On 3 April 2017 at 05:23, Stephen J. Turnbull
wrote:
> Nathaniel Smith writes:
>
> > > Well, I'm afraid to contact this closed and not-for-mortals list,
> > > not sure this very basic question should go there ;) perhaps you
> > > are already a member, feel free to forward.
> >
> > core-mentorship is intended as a friendly place for folks who are
> > starting to study CPython internals. I'm not sure where you got the
> > impression that it's not-for-mortals but I suspect the people
> > running it would like to know so they can fix it :-).
>
> I imagine Oleg got that impression because he tried to access the
> archives, which are closed to non-members. I don't recall the
> rationale for that but there was one, I suspect that won't change.
It relates to these two points in the list's guidelines for participation:
=
* Statements made by core developers can be quoted outside of the list.
* Statements made by others can not be quoted outside the list without
explicit permission.
=
as well as this stated goal:
=
A major goal of this group is to help new contributors feel more
confident about participating in the results focused public
environments of the bug tracker, python-dev and python-ideas.
=
Lots of folks aren't comfortable with having their newbie questions
being archived permanently in reach of online search engines, so
rather than saying "You shouldn't be bothered by that", we instead
offer them a place to ask questions that is at least somewhat private.
There are folks at the other end of the spectrum that don't trust any
communications channel with deliberately closed archives ("What are
they hiding?"), but that's OK - different services are provided for
different audiences.
Cheers,
Nick.
--
Nick Coghlan | [email protected] | Brisbane, Australia
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
