[Python-Dev] Adding bytes.frombuffer() constructor to PEP 467 (was: [Python-ideas] Adding bytes.frombuffer() constructor

Chris Barker chris.barker at noaa.gov
Mon Oct 24 12:53:49 EDT 2016


Before the horse is totally dead... (maybe it already is), a couple
comments:


> In such cases, an extension module written in something like Cython, C
> or Rust would be a better fit,


well, yes, but:


> From that perspective, adding "[bytes/bytearray].frombuffer"


this would be used for the fairly simple use case of passing stuff around
between different modules, which would probably be written in something
lower lever -- unless they too, only passed data around. Passign data
around is a pretty good use-case for Python.

is adding
> complexity to the core language for the sake of giving people one
> small additional piece of incremental performance improvement


here's the thing: this is a very small increase in complexity in exchange
for a small increase in performance -- really not a big deal either way. If
either of those were large, hte decision would be a no brainer.

By contrast, a library that provided better low level data buffer
> manipulation that was suitable for asyncio's needs is *much* easier to
> emulate on older versions, and provides more scope for extracting
> efficient data manipulation patterns beyond this one very specific
> case of more efficiently snapshotting a subset of an existing buffer.
>


IS this na either-or? IF someone is proposing a nice lib for "low level
data buffer
manipulation", then yes, putting frombuffer() in there would be a fine idea.

But if there is no such proposal on the table, then I think adding a
frombuffer method to the bytes object is a small improvement that we can do
now.

https://blog.sentry.io/2016/10/19/fixing-python-performance-with-rust.html


pretty cool -- I guess I should take a look at Rust...

Thanks,

  -CHB



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20161024/5de65b70/attachment.html>


More information about the Python-Dev mailing list