This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年11月21日 23:46 by Lluís, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg203700 - (view) | Author: Lluís (Lluís) | Date: 2013年11月21日 23:46 | |
The following code works without raising any AssertionError >>> n = "some small integer value" >>> m = "some larger integer value" >>> assert n<m >>> data = bytearray(n) >>> mem = memoryview(data) >>> assert mem==mem[:] >>> assert mem==mem[0:] >>> assert mem==mem[:m] However, the different slices have different IDs, failing on the following asserts: >>> assert id(mem)==id(mem[:]) >>> assert id(mem)==id(mem[0:]) >>> assert id(mem)==id(mem[:m]) Is the interpreter copying unnecessary data in these type of slices? |
|||
| msg203717 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2013年11月22日 03:11 | |
I believe a new memoryview object is created, but the data is not copied. That's the whole point of memoryview, I think :) |
|||
| msg203745 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2013年11月22日 12:24 | |
David is correct: No data is copied, but new memoryview objects with different shape and strides are created. That is relatively cheap. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:53 | admin | set | github: 63885 |
| 2013年11月22日 12:24:43 | skrah | set | status: open -> closed type: enhancement -> behavior nosy: + skrah messages: + msg203745 resolution: not a bug stage: resolved |
| 2013年11月22日 03:11:16 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg203717 |
| 2013年11月21日 23:46:46 | Lluís | create | |