Should we always use tuples when instantiating them only once? E.g. *if*abc *in* ('e', 'f'): instead of *if* abc *in* ['e', 'f']:
They appear to be slightly faster sometimes.
Hi
For constant tuples ( once whose items are expressed by literals ) it is true.
Thanks Harsh
On Sat, Jun 7, 2014 at 3:19 AM, Ricordisamoa ricordisamoa@openmailbox.org wrote:
Should we always use tuples when instantiating them only once? E.g. *if* abc *in* ('e', 'f'): instead of *if* abc *in* ['e', 'f']:
They appear to be slightly faster sometimes.
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
On 6 June 2014 23:49, Ricordisamoa ricordisamoa@openmailbox.org wrote:
Should we always use tuples when instantiating them only once? E.g. *if* abc *in* ('e', 'f'): instead of *if* abc *in* ['e', 'f']:
Performance-wise, I don't think it matters much; after all, most time is spent inside the loop, not in instantiating a list or tuple. Conceptually, a list often makes more sense (a list would be different items of the same type, while a tuple represents different properties of the same item).
Merlijn
pywikipedia-l@lists.wikimedia.org