Change one list item in place

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Dec 1 08:59:37 EST 2010


Gnarlodious wrote:
> On Dec 1, 6:23 am, Jean-Michel Pichavant <jeanmic... at sequans.com>
> wrote:
>   
>> what about
>>
>> def query():
>>     return ["Formating only {0} into a string".format(sendList()[0])] +
>> sendList()[1:]
>>     
>
> However this solution calls sendList() twice, which is too processor
> intensive.
>
>   
You got to get rid of those nerd habits of unecessary optimization.  To 
put it simple, you just don't give a [put whatever suitable word] to the 
overhead of 2 calls of sendList instead of one.
Until query is called a million time a second, there's no need to 
sacrifice anything on the optimization altar, because no one will never 
ever see the difference.

You can find my solution not that readable, that would be a proper 
reason for not using it. It's up to you.

JM









More information about the Python-list mailing list