On 10/23/2019 01:08 PM, Steven D'Aprano wrote:
On Wed, Oct 23, 2019 at 11:59:44AM -0400, Todd wrote:

Compare that to:

colors2 = "cyan,forest green,burnt umber".split(',')

Sure, that's not going away. But consider that you're using this inside
a tight loop:

     for something in lots_of_items:
         for another in more_items:
             function(spam, eggs, "cyan,forest green,burnt umber".split(','))

If you have a tight loop that is a performance bottleneck (you did measure, 
right?), then you trade readability for performance.  This is not news.

That's easy to fix, you say. Move the list outside the loop:

     L = "cyan,forest green,burnt umber".split(','))
     for something in lots_of_items:
         for another in more_items:
             function(spam, eggs, L)

What's wrong with this picture?

Other than you're now using one list for all calls, and the function could by 
modifying that list?  You do know if the function modifies the list, right?  I 
give up, what is wrong with that picture?

--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/B5SRQ4T3ULOTYYWF7B4FIYKNDYPB46PJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to