On 28. 05. 21 6:55, Tim Peters wrote:
[Pablo]
Tim, check this out:
import re, gc x = re.compile("x") gc.get_referents(x.__class__)[-1]
Cool! So presumably this constructs a cycle involving a pattern object:
import re p = re.compile("ab*c") import _sre _sre.WOWZA = p
Indeed, under the current main branch:
import gc gc.get_referents(type(p))[-1].WOWZA is p True
Then again, type objects are in cycles regardless:
type(p).__mro__[0] is type(p) True dict.__mro__[0] is dict True int.__mro__[0] is int True
Etc.
I suppose I could ask why heap types were fiddled to point to their module objects too - but that's really got nothing to do with getting the release done, so I won't :-)
Not all heap types need to point to their module objects. Just the ones that need the module's state -- for example, if their method needs to raise a module-specific exception.