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 serhiy.storchaka
Recipients serhiy.storchaka, xiang.zhang
Date 2016-08-15.10:44:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1471257891.4.0.861685179019.issue27492@psf.upfronthosting.co.za>
In-reply-to
Content
The two function's advantage is in the ability to reuse this code for other purposes. For example in _codecs.escape_encode(). But since this is the only place where the same algorithm is used and this functions is not documented and I presume it is not much used, this advantage is pretty small.

The simplest implementation of bytearray.__repr__ is

    def __repr__(self):
        return 'bytearray(%r)' % bytes(self)

It is less efficient than the current implementation or proposed patch, but is much simpler. This approach is used in reprs of set, frozenset, deque, array, BaseException, itemgetter, attrgetter, etc.

It can be more efficient is make bytes.__repr__ accepting not only bytes, but objects supporting the buffer protocol.
History
Date User Action Args
2016-08-15 10:44:51serhiy.storchakasetrecipients: + serhiy.storchaka, xiang.zhang
2016-08-15 10:44:51serhiy.storchakasetmessageid: <1471257891.4.0.861685179019.issue27492@psf.upfronthosting.co.za>
2016-08-15 10:44:51serhiy.storchakalinkissue27492 messages
2016-08-15 10:44:51serhiy.storchakacreate