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 belopolsky, ethan.furman, serhiy.storchaka, skrah, xiang.zhang
Date 2017-03-14.07:22:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Following example copies the entire buffer object while copying only smart part is needed:

    m = memoryview(b'x'*10**6)
    b'%.100b' % m

I don't know whether this is important use case that is worth an optimization. The workaround is using slicing rather than truncating in format:

    b'%b' % m[:100]

Or in the case of general buffer object:

    b'%b' % memoryview(m).cast('B')[:100]

But in that case it is not hard to add an explicit conversion to bytes.

    b'%b' % bytes(memoryview(m).cast('B')[:100])
Date User Action Args
2017-03-14 07:22:02serhiy.storchakasetrecipients: + serhiy.storchaka, belopolsky, skrah, ethan.furman, xiang.zhang
2017-03-14 07:22:02serhiy.storchakasetmessageid: <>
2017-03-14 07:22:02serhiy.storchakalinkissue28856 messages
2017-03-14 07:22:02serhiy.storchakacreate