STINNER Victor <[email protected]> added the comment:
> Don't make KeysView.__repr__ and ValuesView.__repr__ containing the lists of
> all keys and values. This will make the repr of the view of a mapping which
> is a proxy of an external DB containing the full content of that DB, which
> can be gigabytes. See for example rejected issue21670.
The current implementation displays repr(self._mapping):
class MappingView(Sized):
...
def __repr__(self):
return '{0.__class__.__name__}({0._mapping!r})'.format(self)
For your proxy example: what is the proxy? The KeysView subtype, or the mapping?
repr(list), repr(dict) and repr(set) all render their full content in the
result, no?
repr() on a list of 1 million of items *will* render all items, even if nobody
wants to read such very long string :-)
If you want to get a smarter __repr__() than the default implementation: just
override __repr__(), no?
I don't see why KeysView must be special.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32300>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com