Joined June 2012
·
Posted to
Use the in operator
over 1 year
ago
I just fixed some older code that I had written that did this. Perhaps I had added the second check later, but at any rate I refactored it yesterday. I used a list, however, as opposed to a tuple:
if value in ['cheese', 'bacon']:
I would say for values like this the performance is essentially the same, but is there a reason to favor one over the other?
Posted to
JSON5 - like JSON but for human-editing
over 1 year
ago
Sweet! I'll definitely check this out.
I guess this answers my question (thanks @corbinbs):
http://stackoverflow.com/questions/3340539/why-tuple-is-faster-than-list/3340881#3340881
I'll make a final tweak to use a tuple. :)