You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
in xml.dom.minidom, Node and DocumentLS appear to be missing __slots__ #90405
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2022-01-03.18:41:15.874>labels= ['library', '3.9', '3.10', '3.11']
title='in xml.dom.minidom, Node and DocumentLS appear to be missing __slots__'updated_at=<Date2022-01-14.23:31:22.801>user='https://github.com/ariebovenberg'
It is not an oversight that can be corrected by adding __slots__. Node cannot have a non-empty __slots__ at all, because DocumentType inherits from both it and Identified ("multiple bases have instance lay-out conflict"), and DocumentType, Entity, Notation, DocumentFragment and Document use class attributes as defaults for attributes which are then set per instance, which __slots__ does not allow. Every such class would need a complete slot list and explicit initialization.
It would also break code which sets its own attributes on nodes, and setUserData() which stores them itself. Nodes are weak referenceable now, so __weakref__ would have to be added as well, which costs 8 bytes of what is saved.
It is better to fix the general problem instead: gh-135385 (PR #156656) does not reserve inline values for attributes stored in slots, which reduces an element from 328 to 232 bytes, without changing minidom and without breaking anything. The rest of the difference does not justify the above. Closing as not planned.
Activity
ariebovenberg commentedon Jan 3, 2022
(as instructed in bpo-46244, I've created this ticket)
The classes Node and DocumentLS don't define __slots__, but a number of subclasses do.
This appears to be a mistake.
If so, I'd like to create a PR to fix it.
serhiy-storchaka commentedon Aug 30, 2026
It is not an oversight that can be corrected by adding
__slots__.Nodecannot have a non-empty__slots__at all, becauseDocumentTypeinherits from both it andIdentified("multiple bases have instance lay-out conflict"), andDocumentType,Entity,Notation,DocumentFragmentandDocumentuse class attributes as defaults for attributes which are then set per instance, which__slots__does not allow. Every such class would need a complete slot list and explicit initialization.It would also break code which sets its own attributes on nodes, and
setUserData()which stores them itself. Nodes are weak referenceable now, so__weakref__would have to be added as well, which costs 8 bytes of what is saved.It is better to fix the general problem instead: gh-135385 (PR #156656) does not reserve inline values for attributes stored in slots, which reduces an element from 328 to 232 bytes, without changing minidom and without breaking anything. The rest of the difference does not justify the above. Closing as not planned.