On 2013-11-20, at 11:16 , Gaetan <[email protected]> wrote:

> actually that was what I was expected, sorry I'm not very confortable with 
> slices yet.
> It should not allocate, indeed, there is no reason. Python doesn’t allocate 
> but the way it handle items, it doesn’t really behave like rust's slices 

Slicing a list in Python will allocate and return a new list[0]

It does not have to, and you can easily implement a sequence type which
will return a genuine slice object (aka a triple of the parent object,
an offset and a length), but that’s not what list does.

I believe memory views[1] slicing behaves the way lower-level languages
expect. So do numpy arrays.

[0] http://hg.python.org/cpython/file/adb471b9cba1/Objects/listobject.c#l431

[1] http://docs.python.org/2/library/stdtypes.html#memoryview-type
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to