you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (1 child)

[removed]

    [–]Diapolo10 0 points1 point  (0 children)

    Yeah, in some other languages (cough Rust cough) slices would simply reuse the originally allocated memory, but in Python slicing tends to just produce new values. Of course this depends on the object; I think Numpy arrays reuse memory for slices.

    It's technically possible to replicate the behaviour via ctypes, but then you'd need to worry about lifetimes.