New submission from Daniel Urban <urban.dani...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue11333>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to