Arthur Darcet added the comment:
BytesIO is heavily optimised to avoid copying bytes when it can.
For case (1), if you want to modify the data, then there is no need to actually
copy it before overwriting it, because no-one else is using it
For case (2), if you want to change something
Arthur Darcet added the comment:
it's a tiny bit slow, but that works, thank you. I guess we can close this
% python -m timeit -s "import io; b = io.BytesIO(b'0' * 2 ** 30)" "p =
b.tell(); b.seek(0, 2); b.tell(); b.seek(p)"
100 loops, best of 3: 0.615 usec per loop
%
New submission from Arthur Darcet:
If I'm not mistaken, a BytesIO buffer can be in three states:
(1) `b = BytesIO(b'data')` -> free of any constraints
(2) `d = b'data'; b = BytesIO(d)` -> cannot modify the underlying bytes
without copying them
(3) `b = BytesIO(b'data'); d = b.get
Arthur Darcet added the comment:
Ok, thank you. I'm guessing the patch I proposed in the PR is not an option,
for my curiosity, why is that?
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
New submission from Arthur Darcet:
Here is the example code I am running:
```
import asyncio
class it:
async def __aenter__(self):
return self
async def __aexit__(self, *_):
print('EXIT')
async def main():
async
Changes by Arthur Darcet <arthur+pyt...@darcet.fr>:
--
nosy: +rthr
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29406>
___
_
On Sat, 18 Mar 2017 at 23:29, Ian Pilcher wrote:
> On 03/18/2017 05:15 PM, Chris Angelico wrote:
> > So the question is: How well do you trust the examples? Are they
> > likely to be instructing you in a safe way to use this
> > potentially-dangerous module?
>
> But as far
Changes by Arthur Darcet arthur.dar...@gmail.com:
--
nosy: +Arthur.Darcet
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6818
___
___
Python-bugs