Author Dennis Sweeney
Recipients Dennis Sweeney, eric.smith, steven.daprano, vstinner, xtreak
Date 2020-03-12.16:37:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584031044.93.0.316773368506.issue39939@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2020-03-12 16:37:24Dennis Sweeneysetrecipients: + Dennis Sweeney, vstinner, eric.smith, steven.daprano, xtreak
2020-03-12 16:37:24Dennis Sweeneysetmessageid: <1584031044.93.0.316773368506.issue39939@roundup.psfhosted.org>
2020-03-12 16:37:24Dennis Sweeneylinkissue39939 messages
2020-03-12 16:37:24Dennis Sweeneycreate