Message284864
> Which virtually no one follows :(
Sad. But adding bytes.frombuffer() wouldn't make it magically used. If you are
aware of the problem, you can use the above two-liner as well as
bytes.frombuffer(). You even can use it in the current code with older Python
releases, unlike to bytes.frombuffer() which would need 3.7.
> Any protocol parsing code has a lot of slicing.
How much code you expect to update with bytes.frombuffer()? And why not use the
above two-liner instead?
> > There is also a problem with returned type for subclasses (this is always
> > a problem for alternate constructors).
> Good point. How do we usually solve this in CPython?
It is deemed that returning an instance of a subclass is more preferable.
Otherwise you could use separate function rather of a class method. But it is
not easy. You need either pass a memoryview or bytes instance to class
constructor, or (only for mutable arrays) create an empty instance and
concatenate a buffer to it. |
|
Date |
User |
Action |
Args |
2017-01-06 22:29:08 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ncoghlan, belopolsky, vstinner, methane, Yury.Selivanov, yselivanov |
2017-01-06 22:29:08 | serhiy.storchaka | link | issue29178 messages |
2017-01-06 22:29:08 | serhiy.storchaka | create | |
|