This answer is based on OP's answer to my comment. I asked what he would do with the dicton, suggesting that perhaps he did not need to build it in the first place. @simon replies:
I will add it to the excel sheet, so I take the KEY, which is the name, and put it in A1, then I take the VALUE value, which is 1345,345,135,346,3451,35 .. etc. Etc., And put it in A2. then I do the rest of my programming with this information ...... but I need these values separated by commas and accessible inside this sheet like this!
So it seems that dict does not need to be built in the end. Here is an alternative: for each name, create a file and save these files in a dict :
files = {} name = 'John' # let say if name not in files: files[name] = open(name, 'w')
Then, when you loop into the excel 50k line, you do something like this (pseudocode):
for row in 50k_rows: name, value_string = rows.split() # or whatever file = files[name] file.write(value_string + ',') # if already ends with ',', no need to add
Since your value_string already separated by a comma, your file will be csv-like, without any additional configuration on your part (except perhaps you want to remove the last trailing comma after you finish). Then when you need the values of, say, John, just value = open('John').read() .
Now I have never worked with excellent 50k strings, but I would be very surprised if it weren’t much faster than you currently have. Having persistent data is also (well, maybe) a plus.
EDIT:
Above is a memory oriented solution. Writing to files is much slower than adding lists (but probably even faster than re-creating many large lines). But if the lists are huge (which seems likely) and you are faced with a memory problem (don't say you want), you can try the file approach.
An alternative, similar to performance lists (at least for the game test I tried), is to use StringIO :
from io import StringIO
This will exit 'ab,cd,ef,'