Alex Martelli wrote:
> Frank Millman <[EMAIL PROTECTED]> wrote:
>...
> > If they are all equivalent from a functional point of view, I lean
> > towards the second version. I agree with Rune that the third one is
> > nicer to read, but somehow the [:] syntax makes it a bit more obvious
> > what
[EMAIL PROTECTED] (Alex Martelli) writes:
> I vastly prefer to call list(xxx) in order to obtain a new list with the
> same items as xxx -- couldn't be more obvious than that.
>
> You can't claim it's obvious that xxx[:] *copies* data
Heh, it wasn't obvious that list(xxx) copies data either (I th
Frank Millman <[EMAIL PROTECTED]> wrote:
...
> If they are all equivalent from a functional point of view, I lean
> towards the second version. I agree with Rune that the third one is
> nicer to read, but somehow the [:] syntax makes it a bit more obvious
> what is going on.
I vastly prefer to
"Frank Millman" <[EMAIL PROTECTED]> writes:
> Interesting. My results are opposite.
I got the same here (cPython 2.4.1):
[EMAIL PROTECTED] ~ % python -mtimeit -s "data=[range(100)]*100; row = []"
"row[:] = data[23]"
100 loops, best of 3: 1.15 usec per loop
[EMAIL PROTECTED] ~ % python -mtim
Fredrik Lundh wrote:
> Frank Millman wrote:
>
> > I have found two ways of doing it that seem to work.
> >
> > 1 - row = table[23][:]
> >
> > 2 - row = []
> > row[:] = table[23]
> >
> > Are these effectively identical, or is there a subtle distinction which
> > I should be aware of.
> >
> > I
Frank Millman wrote:
> I have found two ways of doing it that seem to work.
>
> 1 - row = table[23][:]
>
> 2 - row = []
> row[:] = table[23]
>
> Are these effectively identical, or is there a subtle distinction which
> I should be aware of.
>
> I did some timing tests, and 2 is quite a bit fa
Frank Millman wrote:
> Hi all
>
> Assume a 2-dimensional list called 'table' - conceptually think of it
> as rows and columns.
>
> Assume I want to create a temporary copy of a row called 'row',
> allowing me to modify the contents of 'row' without modifying the
> contents of 'table'.
>
> I used t