In article <gop0se$7hu$0...@news.t-online.com>,
Peter Otten  <__pete...@web.de> wrote:
>mattia wrote:
>>
>>         cpop += [nchromosome1] + [nchromosome2]
>
>I'd write that as 
>
>cpop.append(nchromosome1)
>cpop.append(nchromosome2)
>
>thus avoiding the intermediate lists.

You could also write it as

cpop += [nchromosome1, nchromosome2]

which may or may not be faster, substituting one attribute lookup, one
list creation, and one method call for two attribute lookups and two
method calls.  I shan't bother running timeit to check, but I certainly
agree that either your version or mine should be substituted for the
original, depending on one's esthetics (meaning that I doubt there's
enough performance difference either way to make that the reason for
choosing one).
-- 
Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Programming language design is not a rational science. Most reasoning
about it is at best rationalization of gut feelings, and at worst plain
wrong."  --GvR, python-ideas, 2009-3-1
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to