[issue26077] Make slicing of immutable structures return a view instead of a copy

2016-01-16 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Proposals for strings views have be rejected precisely because of the 
keep-alive effect.

I do not remember if tuples were explicitly part of earlier discussions. One 
could make the argument that million-item tuples, and especially slicing 
thereof is rarer than the same for strings.  On the other hand, copying short 
slices of short to medium tuples is not a big deal.

Because of previous discussions, I think this issue should be either closed or 
suspended for python-ideas discussion.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue26077] Make slicing of immutable structures return a view instead of a copy

2016-01-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The support of sharing a content between different tuples requires changing the 
structure of the tuple object, allocating additional block for every tuple, 
adding a level of indirection and reference counting. This will increase memory 
consumption, creating and access time for all tuples. All this is critically 
important for Python interpreter. I think this idea has no a chance.

--
nosy: +serhiy.storchaka
resolution:  -> rejected
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue26077] Make slicing of immutable structures return a view instead of a copy

2016-01-10 Thread Filip Haglund

New submission from Filip Haglund:

Slicing tuples returns a copy, which is O(n) time. This could be O(1) since 
tuples are immutable, by just pointing to the same data.

This probably applies to other immutable structures as well, such as strings.

--
components: Interpreter Core
messages: 257937
nosy: Filip Haglund
priority: normal
severity: normal
status: open
title: Make slicing of immutable structures return a view instead of a copy
type: performance
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue26077] Make slicing of immutable structures return a view instead of a copy

2016-01-10 Thread Emanuel Barry

Emanuel Barry added the comment:

This is an interesting idea, +1 from me. Do you want to submit a patch?

--
nosy: +ebarry
stage:  -> needs patch
versions:  -Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

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



[issue26077] Make slicing of immutable structures return a view instead of a copy

2016-01-10 Thread Martin Panter

Martin Panter added the comment:

I think which technique (copy or view) is better depends on the situation. If 
you are making a large temporary slice, a view may be more efficient. But if 
you are making a long-term slice and don’t need the original any more, a copy 
would allow the original memory to be freed early.

Do you have any use cases? You can already get a kind of slice view into bytes 
etc by using memoryview().

--
nosy: +martin.panter

___
Python tracker 

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