Sorry, the last link should have been:

https://bugs.python.org/issue43908


On Thu, 27 May 2021 at 19:41, Pablo Galindo Salgado <pablog...@gmail.com>
wrote:

> > Modules dicts are cleared during interpreter shutdown to break
> such cycles.
>
> That is precisely what's not working because of the cycles, check the
> first message in the issue:
>
> https://bugs.python.org/msg385297
>
> > Also: Why are types mutable ? AFAIK, they are only meant to be
> mutable at C level and then only until they are fully initialized
> (PyType_Ready() called).
>
> Check https://bugs.python.org/issue43916
>
>
>
> On Thu, 27 May 2021 at 19:38, Marc-Andre Lemburg <m...@egenix.com> wrote:
>
>> On 27.05.2021 20:20, Pablo Galindo Salgado wrote:
>> >> And if a type pointer is the only thing being visited, then there's
>> > no point unless the object can itself be reachable from the type object.
>> >
>> > But that could happen easily for heap types as they are mutable by
>> default. For
>> > instance, you set the instance in a global:
>> >
>> > type -> module -> globals -> instance -> type
>>
>> Modules dicts are cleared during interpreter shutdown to break
>> such cycles. You would not really want to use GC to clear
>> type objects: if you GC the type object before the instance,
>> this would create really difficult to handle situations :-)
>>
>> Also: Why are types mutable ? AFAIK, they are only meant to be
>> mutable at C level and then only until they are fully initialized
>> (PyType_Ready() called).
>>
>> > On Thu, 27 May 2021, 19:07 Tim Peters, <tim.pet...@gmail.com
>> > <mailto:tim.pet...@gmail.com>> wrote:
>> >
>> >     [Tim Peters <tim.pet...@gmail.com <mailto:tim.pet...@gmail.com>>]
>> >     > ...
>> >     > This is, I believe, akin to what Marc-Andre is bringing up:  if X
>> >     > can't be reached _from_ X's type object, there's no need for X's
>> >     > tp_traverse to visit X's type object.  It _can_ be visited, but it
>> >     > would be a waste of time.
>> >
>> >     Ya, I need to retract that :-)  If X's type object is in a cycle not
>> >     directly containing X, and X is in a cycle not directly containing
>> its
>> >     type object, and both cycles are dead, then X's tp_traverse must
>> visit
>> >     X's type object for cyclic gc to deduce that the cycle directly
>> >     containing the type object _is_ dead.
>> >
>> >     Else only the cycle containing X will be reclaimed, and the cycle
>> >     containing the type object will have to wait for another gc run.
>> >
>> >     But that doesn't apply to some of the patches we're seeing. We're
>> >     seeing visits to things that can't possibly be parts of cycles:
>> >
>> >     +static int
>> >     +pattern_traverse(PatternObject *self, visitproc visit, void *arg)
>> >     +{
>> >     +    Py_VISIT(Py_TYPE(self));
>> >     +    Py_VISIT(self->groupindex);
>> >     +    Py_VISIT(self->indexgroup);
>> >     +    Py_VISIT(self->pattern);
>> >     +    return 0;
>> >     +}
>> >     +
>> >
>> >     For example, self->pattern there is a string.  For that matter, it's
>> >     hard to conceive of how a regexp pattern object could possibly be a
>> >     direct member of any cycle.
>> >
>> >     And if a type pointer is the only thing being visited, then there's
>> no
>> >     point unless the object can itself be reachable from the type
>> object.
>> >
>>
>> --
>> Marc-Andre Lemburg
>> eGenix.com
>>
>> Professional Python Services directly from the Experts (#1, May 27 2021)
>> >>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>> >>> Python Product Development ...        https://consulting.egenix.com/
>> ________________________________________________________________________
>>
>> ::: We implement business ideas - efficiently in both time and costs :::
>>
>>    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
>>     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>>            Registered at Amtsgericht Duesseldorf: HRB 46611
>>                https://www.egenix.com/company/contact/
>>                      https://www.malemburg.com/
>>
>>
_______________________________________________
python-committers mailing list -- python-committers@python.org
To unsubscribe send an email to python-committers-le...@python.org
https://mail.python.org/mailman3/lists/python-committers.python.org/
Message archived at 
https://mail.python.org/archives/list/python-committers@python.org/message/UBNKAASDQNKRHUR7FUT3AFYZ7ZCH5P6G/
Code of Conduct: https://www.python.org/psf/codeofconduct/

Reply via email to