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 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.
i think this way is better:
my_list = my_list.insert(0,my_string)
my_tuple = tuple(my_list)
I can't speak for performance, but this is definitely the simplest I can think of:
my_tuple = tuple([my_string] + my_list)