Create A Tuple From A String And A List Of Strings
I need to combine a string along with a list of strings into a tuple so I can use it as a dictionary key. This is going to be in an inner loop so speed is important. The list will
Solution 1:
I can't speak for performance, but this is definitely the simplest I can think of:
my_tuple = tuple([my_string] + my_list)
Solution 2:
The straightforward way is simply my_tuple = tuple( my_list + [my_string] )
. I would certainly start with that and see if the performance is acceptable before trying to figure out any crazy ways of subverting the normal system for speed.
Post a Comment for "Create A Tuple From A String And A List Of Strings"