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 -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/X3OBCBM3XTZD7XFEQ2ULR6XGEXB6PRLZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to