[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020年3月24日 13:39:26 -0700

On Tue, Mar 24, 2020 at 08:14:33PM -0000, Dennis Sweeney wrote:
> I think my confusion is about just how precise this sort of "reference 
> implementation" should be. Should it behave with ``str`` and ``tuple`` 
> subclasses exactly how it would when implemented? If so, I would expect the 
> following to work:
I think that for the purposes of a relatively straight-forward PEP like 
this, you should start simple and only add complexity if needed to 
resolve questions.
The Python implementation ought to show the desired semantics, not try 
to be an exact translation of the C code. Think of the Python 
equivalents in the itertools docs:
https://docs.python.org/3/library/itertools.html
See for example:
https://www.python.org/dev/peps/pep-0584/#reference-implementation
https://www.python.org/dev/peps/pep-0572/#appendix-b-rough-code-translations-for-comprehensions
You already state that the methods will show "roughly the following 
behavior", so there's no expectation that it will be precisely what 
the real methods do.
Aim for clarity over emulation of unusual corner cases. The reference 
implementation is informative not prescriptive.
-- 
Steven
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/F5Z24BQF5MNHL6BPIQGGIXGH23ZEREFA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to