← index #2552PR #7264
Off-topic · high · value 0.245
QUERY · ISSUE

Add .offset()/.seek() method for memoryview for inplace "slicing"

openby pfalconopened 2016-10-23updated 2018-12-01
enhancementrfc

Here's an idiom to send a large data buffer thru a short-write stream (e.g., non-blocking socket):

        buffer = memoryview(data).cast('b')
        while buffer:
            try:
                nsent = self._socket_send(buffer, flags)
                buffer = buffer[nsent:]

The last statement still produces bunch of object garbage. If we could do

buffer.offset(nsent)

it would be cool. Suggestions for better name are welcome.

CANDIDATE · PULL REQUEST

py/objarray: Fix constructing a memoryview from a memoryview.

mergedby dpgeorgeopened 2021-05-14updated 2021-05-18
py-core

Fixes issue #7261.

TODO:

  • improve the test so it triggers the bug (prior to this fix) on bare metal boards

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied