Domanda

I am using Pyscripter to script and execute Python codes. I have a scenario where I'm population a tuple in a loop. And, at the end of the program I have 10 such variables with 1 Million elements in each. Pyscripter hangs when I try to call any variable after this.

Any tips how to overcome this? Are there any limitations on the size of variables in workspace? I have sufficient space in my disk to support the data.

È stato utile?

Soluzione

If you are adding to a tuple in a loop, you might be better off starting with a list, then converting it to a tuple later:

mylist = []
for i in range(million):
    mylist.append(something)
mytup = tuple(mylist)

But if you're appending to something a million times, it's possible that your program just takes time to populate the tuple...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top