On copying arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ernesto.adorio@gmail.com

    On copying arrays

    Is there a conceptual difference between
    best =test[:]
    and
    best = [x for x in test] ?
    test is a list of real numbers. Had to use the second form to avoid a
    nasty bug
    in a program I am writing. I have to add too that I was using psyco
    in Python 2.5.1.

    Regards,
    Ernie.
  • bearophileHUGS@lycos.com

    #2
    Re: On copying arrays

    ernesto:

    best = list(test)

    may be faster than:

    best = [x for x in test]

    Bye,
    bearophile

    Comment

    Working...