[Patches] [ python-Patches-696193 ] Enable __slots__ for meta-types

SourceForge.net noreply@sourceforge.net
Sun, 02 Mar 2003 13:02:44 -0800


Patches item #696193, was opened at 2003-03-02 22:02
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=696193&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Christian Tismer (tismer)
Assigned to: Nobody/Anonymous (nobody)
Summary: Enable __slots__ for meta-types

Initial Comment:
The new type system allows non-empty __slots__ only
for fixed-size objects.

Meta-types are types which instances are also types.
types are variable-sized, because they take the slot
definitions for their instances, so the cannot have
extra members from their meta-type.

The proposed solution allows for two things:
a) meta-types can have slots
b) extensions get access to the whole type object and
    can create extended types with private fields.

The changes providing this are quite simple:
- replace the internal hidden "etype" and turn it into
  an explicit PyHeapTypeObject in object.h
- instead of a fixed offset into the former etype, the
slots
  calculation is based upon tp_basicsize.

To keep things easy, I added a macro which does this
calculation, and member access read now like so:

before:
	type->tp_members = et->members;
after:
	type->tp_members = PyHeapType_GET_MEMBERS(et);

This patch has been tested thoroughly in my own code since
Python 2.2, and I think it is ripe to get into the
distribution.
It has almost no impact on speed or simlicity.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=696193&group_id=5470