[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2019-04-08 Thread Inada Naoki


Inada Naoki  added the comment:

Maybe, we need C version of memoryview.release() to invalidate pointer in 
memoryview object.

--
nosy: +inada.naoki

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread tzickel


tzickel  added the comment:

ahh, very interesting discussion. BTW, how is this code different than

https://github.com/python/cpython/blame/50ff02b43145f33f8e28ffbfcc6a9d15c4749a64/Modules/_io/bufferedio.c

which does the same thing exactly ? (i.e. the memoryview can leak there as 
well).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread Martin Panter

Martin Panter  added the comment:

Looks like this is about about making “RawIOBase.read” delegate to “readinto” 
with a “bytes” object. If so, there’s more discussion in Issue 15903.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread tzickel


tzickel  added the comment:

I think that if someone tries that this code will raise an exception at the 
resize part (since the reference will be higher than one), a check can be added 
and in this case fallback to the previous behaviour, If it's a required check, 
I can add it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

When you remove the original reference, the second reference keeps the 
bytearray object live. When you remove or just resize the bytes object, the 
memoryview object becomes referring to freed memory.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread tzickel


tzickel  added the comment:

How is that different from the situation today ? The bytearray passed to 
readinto() is deleted before the function ends.

This revision simply changes 2 mallocs and a memcpy to 1 malloc and a potential 
realloc.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What if readinto() save a reference to its argument?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread tzickel


Change by tzickel :


--
nosy: +benjamin.peterson, stutzbach

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread tzickel


Change by tzickel :


--
keywords: +patch
pull_requests: +9726
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35210] Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read

2018-11-10 Thread tzickel


New submission from tzickel :

There was a TODO in the code about this:

https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Modules/_io/iobase.c#L909

--
components: IO
messages: 329629
nosy: tzickel
priority: normal
severity: normal
status: open
title: Use bytes + memoryview + resize instead of bytesarray + array in 
io.RawIOBase.read
type: performance
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com