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

2020年3月23日 22:13:46 -0700

On 24/03/20 3:43 pm, Dennis Sweeney wrote:
This was an attempt to ensure no one can do funny business with tuple
or str subclassing. I was trying to emulate the ``PyTuple_Check``
followed by ``PyTuple_GET_SIZE`` and ``PyTuple_GET_ITEM`` that are
done by the C implementation of ``str.startswith()``
The C code uses those functions for efficiency, not to prevent
"funny business". PyTuple_GET_SIZE and PyTuple_GET_ITEM are macros
that directly access fields of the tuple struct, and PyTuple_Check
is much faster than a full isinstance check.
There is no point in trying to emulate these in Python code.
--
Greg
_______________________________________________
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/X3OBCBM3XTZD7XFEQ2ULR6XGEXB6PRLZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to