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.

Author vstinner
Recipients Aaron.Meurer, cheryl.sabella, r.david.murray, rhettinger, serhiy.storchaka, vstinner
Date 2017-12-13.21:29:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513200575.47.0.213398074469.issue32300@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2017-12-13 21:29:35vstinnersetrecipients: + vstinner, rhettinger, r.david.murray, Aaron.Meurer, serhiy.storchaka, cheryl.sabella
2017-12-13 21:29:35vstinnersetmessageid: <1513200575.47.0.213398074469.issue32300@psf.upfronthosting.co.za>
2017-12-13 21:29:35vstinnerlinkissue32300 messages
2017-12-13 21:29:35vstinnercreate