[Python-ideas] Do we need non-heap types any more? (Was: Implicit submodule imports)

Andrew Barnert abarnert at yahoo.com
Mon Sep 29 16:19:00 CEST 2014


On Sep 29, 2014, at 6:27, random832 at fastmail.us wrote:

> On Sun, Sep 28, 2014, at 22:58, Andrew Barnert wrote:
>> And at any rate, consider the case we're talking about. We have some heap
>> types and some non-heap types. Neither branch is very unlikely,
> 
> What? It is very unlikely, especially in existing code where it won't
> work at all, for someone to attempt to reassign the __class__ of a non
> heap type object. We are not talking about something that gets run on
> every object.

Look at the subject of this thread. Go back to the first message in the thread. Greg's suggestion is that, instead of just working around the __class__ assignment test, "I'm thinking it should be possible to reduce the
differences to the point where [heap allocation itself is] the *only* distinction,
so the vast majority of code doesn't have to care, and the
same tp_* functions can be used for both."

That's what we're talking about here. Is there a potential performance impact for making all of those changes? There could be a benefit from removing the tests; there could be a cost from adding work we didn't used to do (e.g., extra refcounting or other tests that we can currently skip).

So, the fact that the one check on __class__ can be statically predicted pretty well doesn't have much to do with the potential cost or benefit of removing all of the differences between heap and non-heap types instead of just the check on __class__.


More information about the Python-ideas mailing list