This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Enable __slots__ for meta-types
Type: enhancement Stage:
Components: None Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: tismer
Priority: low Keywords:

Created on 2003-03-02 20:52 by tismer, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
typeobject.diff tismer, 2003-03-02 20:54 diff file for typeobject.c and object.h, against today's CVS version.
Messages (1)
msg53791 - (view) Author: Christian Tismer (old) (tismer) Date: 2003-03-02 20:52
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 complexity.
History
Date User Action Args
2022-04-10 16:07:16adminsetgithub: 38079
2003-03-02 20:52:31tismercreate