[英]Python : Variable size problems with Pyscripter
I am using Pyscripter to script and execute Python codes. 我正在使用Pyscripter编写脚本并执行Python代码。 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.
并且,在程序结束时,我有10个这样的变量,每个变量中有1百万个元素。 Pyscripter hangs when I try to call any variable after this.
当我尝试在此之后调用任何变量时,Pyscripter会挂起。
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.
我的磁盘上有足够的空间来支持数据。
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... 但是,如果您要追加一百万次,则程序可能会花费一些时间来填充元组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.