[Python-Dev] Re: PEP-0467: Minor API improvements for binary sequences

2021年4月13日 16:37:44 -0700

On 4/13/21 3:01 PM, Jelle Zijlstra wrote:
Thanks for this PEP! Most of these proposals would make for useful improvements to the language. I have a few pieces of feedback below.
El mar, 13 abr 2021 a las 14:14, Ethan Furman escribió:
 This PEP has been deferred until Python 3.9 at the earliest, as the open
This should be 3.10 at least (and even that is pushing it by now).
Ah, thanks -- fixed (and fingers crossed for 3.10 -- most of the code/tests are 
already written).
 While this does create some duplication, there are valid reasons for it:
 * the ``bchr`` builtin is to recreate the ``ord``/``chr``/``unichr`` trio 
from
  Python 2 under a different naming scheme (however, see the Open 
Questions
  section below)
 * the class method is mainly for the ``bytearray.fromord`` case, with
  ``bytes.fromord`` added for consistency
I don't see an "Open questions" section in this email (only an "Open issues" 
section talking about memoryview).
Fixed (removed reference to Open questions).
I don't find the argument for a builtin very persuasive. Why is it important to recreate the Python 2 trio? `bchr` is a more obscure name than `bytes.fromord`. `bytes.fromord` is already short and doesn't require an import, so we don't gain that much from the separate builtin.
`chr` and `ord` are builtins, so `bchr` fits right in. `bytes.fromord` is there to mirror `bytearray.fromord` and facilitate duck-typing. What you are doing will affect which one you reach for. For me at least, reading code that contains `bytes.fromord` puts too much emphasis on the type and method, whilst `bchr` has it just right. :-)
--
~Ethan~
_______________________________________________
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/DX7GTNWYO36QQVNSN3BT3Z6QPG7SRXYA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to