Message284914
> I'm -1 if the intention is about easiness and efficiency.
Do you +1 when adding it to stdlib (say "bufferlib")?
> Creating a memoryview is not cheap enough in such a case.
Actually speaking, it's 5 calls + 2 temporary memoriview.
1. creating memoryview.
2. call __enter__.
3. slicing memoryview
4. create bytes from it
5. call __exit__
It can be bottleneck very easily, when writing protocol parser like HTTP parser.
> About easiness to use, when a user considering such low level details, it's reasonable to know memoryview and it needs to be released.
closing memoryview is not strict requirements in some cases.
When memoryview is created from immutable, relying to GC is safe.
That's why closing memoryview is easily forgotten.
> But if this API is added to simplify bytes(), I think it makes sense but it's not only about adding a frombuffer().
Yes. See msg284813.
There are PEP 467 already to make bytes() simple.
But if PEP 467 is accepted, bytes() constructor is simple enough.
Adding `offset` and `length` keyword-only argument to bytes() make sense. |
|
Date |
User |
Action |
Args |
2017-01-07 12:47:08 | methane | set | recipients:
+ methane, ncoghlan, belopolsky, vstinner, Yury.Selivanov, serhiy.storchaka, yselivanov, xiang.zhang |
2017-01-07 12:47:08 | methane | set | messageid: <1483793228.76.0.423850300358.issue29178@psf.upfronthosting.co.za> |
2017-01-07 12:47:08 | methane | link | issue29178 messages |
2017-01-07 12:47:08 | methane | create | |
|