[New-bugs-announce] [issue11333] Add empty __slots__ to collections.abc abstract base classes

Daniel Urban report at bugs.python.org
Sat Feb 26 13:24:34 CET 2011


New submission from Daniel Urban <urban.dani+py at gmail.com>:

Currently instances of classes which inherit an ABC in collections.abc will have a __dict__.  This can be a problem for example a tree-like data structure. It would make sense to inherit for example MutableMapping, but that would possibly mean, that every node in the tree would have a __dict__, which is probably a waste of memory.

A workaround for this problem is not inheriting the ABC, and using ABCMeta.register (and optionally adding the mixin methods explicitly), but this feels like a hack.

The attached patch adds an empty __slots__ to the ABCs in collections.abc.  I excluded the mapping views (MappingView, KeysView, ItemsView and ValuesView), because they can't have an empty __slots__, and I think using a nonempty __slots__ possibly can cause problems in some cases with multiple inheritance.

----------
components: Library (Lib)
files: collections_abc_slots.diff
keywords: patch
messages: 129534
nosy: durban, rhettinger, stutzbach
priority: normal
severity: normal
status: open
title: Add empty __slots__ to collections.abc abstract base classes
type: feature request
versions: Python 3.3
Added file: http://bugs.python.org/file20910/collections_abc_slots.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11333>
_______________________________________


More information about the New-bugs-announce mailing list