Dennis Sweeney <[email protected]> added the comment:
Yes:
>>> x = "A"*10**6
>>> x.cutprefix("B") is x
True
>>> x.cutprefix("") is x
True
>>> y = b"A"*10**6
>>> y.cutprefix(b"B") is y
True
>>> y.cutprefix(b"") is y
True
>>> z = bytearray(b"A")*10**6
>>> z.cutprefix(b"B") is z
False
>>> z.cutprefix(b"") is z
False
I'm not sure whether this should be part of the spec or an implementation
detail. The (str/bytes).replace method docs don't clarify this, but they have
the same behavior:
>>> x = "A"*10**6
>>> x.replace("B", "C") is x
True
>>> x.replace("", "") is x
True
>>> y = b"A"*10**6
>>> y.replace(b"B", b"C") is y
True
>>> y.replace(b"", b"") is y
True
>>> z = bytearray(b"A")*10**6
>>> z.replace(b"B", b"C") is z
False
>>> z.replace(b"", b"") is z
False
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39939>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com