[Python-ideas] Allow mutable builtin types (optionally)

Eloi Gaudry Eloi.Gaudry at fft.be
Tue May 8 03:26:47 EDT 2018


On Mon, 2018-05-07 at 15:23 -0400, Petr Viktorin wrote:
> On 05/07/18 11:37, Eloi Gaudry wrote:
> > I mean, to my knowledge, there is no reason why a type should be
> > allocated on the heap (https://docs.python.org/2/c-api/typeobj.html
> > ) to
> > be able to change its attributes at Python level.
> 
> One reason is sub-interpreter support: you can have multiple 
> interpreters per process, and those shouldn't influence each other.
> (see https://docs.python.org/3/c-api/init.html#sub-interpreter-suppor
> t)
> 
> With heap types, each sub-interpreter can have its own copy of the
> type 
> object. But with builtins, changes done in one interpreter would be 
> visible in all the others.

Yes, this could be a reason, but if you don't rely on such a feature
neither implicitly nor explicitly ?

I mean, our types are built-in and should be considered as immutable
across interpreters. And we (as most users I guess) are only running
one interpreter.

In case several intepreters are used, it would make sense to have a
non-heap type that would be seen as a singleton across all of them, no
?


More information about the Python-ideas mailing list