On Mon, 24 Jan 2005 18:45:46 +0100 "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote: > > > Why does slicing a tuple returns a new tuple instead of a view of > > the existing one, given that tuples are immutable ? > > really? Well... seems like this case is optimized to return the original tuple just incrementing its reference count and returning tupleobject.c, 330-335 if (ilow == 0 && ihigh == a->ob_size && PyTuple_CheckExact(a)) { Py_INCREF(a); return (PyObject *)a; } > > >>> a = 1, 2, 3 > >>> b = a[:] > >>> a is b > True > > </F> > > > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list