Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "a copy of" from removeprefix/suffix docs #29210

Closed
wants to merge 1 commit into from

Conversation

arjenzorgdoc
Copy link

@arjenzorgdoc arjenzorgdoc commented Oct 25, 2021

If there is no match str.removeprefix() and and str.removesuffix() don't make a copy of the string.

if there is no match str.removeprefix() and and str.removesuffix() don't make a copy of the string.
@the-knights-who-say-ni
Copy link

the-knights-who-say-ni commented Oct 25, 2021

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

Recognized GitHub username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@arjenzorgdoc

This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Oct 25, 2021
@sweeneyde
Copy link
Member

sweeneyde commented Oct 25, 2021

Whether or not the original string is returned is an implementation detail: PEP 616 neither mandates nor forbids the optimization of returning the original string, so one should not rely on s.removeprefix('xyz') is s being True. In general, the identity of immutable objects (-10 is -10) is an implementation detail, and one should compare immutable objects by value (-10 == -10).

If you want to discuss further, please open an issue on bugs.python.org.

@JelleZijlstra
Copy link
Member

JelleZijlstra commented Apr 2, 2022

Note that the docs for str.strip also say that "a copy" is returned, but:

>>> s = ""
>>> s.strip() is s
True

As @sweeneyde says, this is an implementation detail though, so let's keep the current wording.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants