By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,941 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,941 IT Pros & Developers. It's quick & easy.

Keep getting MemoryError while calling copy.deepcopy()

P: 2
As the title tells, the detail is: There is a dictionary to be deepcopied. it has 100 key-value pairs. every value is a list of 200000 float numbers. I'm perform deepcopy to everyone of the value like below:
Expand|Select|Wrap|Line Numbers
  1.  curr_di_in_a = {}
  2.  for key,v in to_be_copy.items():
  3.      curr_di_in_a[key] = copy.deepcopy(v)
  4.  
This process will be in a loop of 3 times. And an MemoryError occurs after 2 times looped.
It seems there is not enough space for the action. But the memory of the machine is about 4G. So is there any way to make a full use of the physical memory, or maybe I have made some mistakes? Help me! Thanks.
Dec 23 '10 #1
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
I only see one loop. Where are the other two?

If the values are lists of numbers, why not do this:
Expand|Select|Wrap|Line Numbers
  1.  curr_di_in_a = {}
  2.  for key,v in to_be_copy.items():
  3.      curr_di_in_a[key] = v[:]
Dec 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.