Re: On copying arrays

2008-03-24 Thread Steven D'Aprano
On Mon, 24 Mar 2008 09:52:21 +, Duncan Booth wrote: > The method usually recommended is: > > best = list(test) > > as it has no side effects In general, you can't assume *anything* in Python has no side effects, unless you know what sort of object is being operated on. Here's an example

Re: On copying arrays

2008-03-24 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > 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.

Re: On copying arrays

2008-03-23 Thread bearophileHUGS
ernesto: best = list(test) may be faster than: best = [x for x in test] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

On copying arrays

2008-03-23 Thread ernesto . adorio
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. -- http://mail.python.o