I am trying to save a dictionary of size 65000X50 to a local file and
I get the memory error problem.
How do I go about resolving this? Is there way to partition the pickle
object and combine later if this is a problem due to limited resources
(memory) on the machine (it is 32 bit machine Win XP, with 4GB RAM).
Here is the detail description of the error:
Traceback (most recent call last):
File "<pyshell#1 2>", line 1, in <module>
s = pickle.dumps(it emsim)
File "C:\Python25\li b\pickle.py", line 1366, in dumps
Pickler(file, protocol).dump( obj)
File "C:\Python25\li b\pickle.py", line 224, in dump
self.save(obj)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 649, in save_dict
self._batch_set items(obj.iteri tems())
File "C:\Python25\li b\pickle.py", line 663, in _batch_setitems
save(v)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 600, in save_list
self._batch_app ends(iter(obj))
File "C:\Python25\li b\pickle.py", line 615, in _batch_appends
save(x)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 562, in save_tuple
save(element)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 477, in save_float
self.write(FLOA T + repr(obj) + '\n')
MemoryError: out of memory 2 4501
Nagu wrote:
I am trying to save a dictionary of size 65000X50 to a local file and
I get the memory error problem.
How do I go about resolving this? Is there way to partition the pickle
object and combine later if this is a problem due to limited resources
(memory) on the machine (it is 32 bit machine Win XP, with 4GB RAM).
Here is the detail description of the error:
Traceback (most recent call last):
File "<pyshell#1 2>", line 1, in <module>
s = pickle.dumps(it emsim)
File "C:\Python25\li b\pickle.py", line 1366, in dumps
Pickler(file, protocol).dump( obj)
File "C:\Python25\li b\pickle.py", line 224, in dump
self.save(obj)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 649, in save_dict
self._batch_set items(obj.iteri tems())
File "C:\Python25\li b\pickle.py", line 663, in _batch_setitems
save(v)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 600, in save_list
self._batch_app ends(iter(obj))
File "C:\Python25\li b\pickle.py", line 615, in _batch_appends
save(x)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 562, in save_tuple
save(element)
File "C:\Python25\li b\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python25\li b\pickle.py", line 477, in save_float
self.write(FLOA T + repr(obj) + '\n')
MemoryError: out of memory
I've generated some rather large pickled dicts before and have never seen this
before. You can, of course, split your dictionary into several smaller ones,
pickle them individually and combine them back together on unpickle/read using
the dictionary update method.
BTW - 32-bit Windows can only address 3.5Gb of memory maximum. If you have more
installed, it is ignored.
-Larry
Nagu wrote:
I am trying to save a dictionary of size 65000X50 to a local file and
I get the memory error problem.
What do you mean by this size specification? When I interpreter X as
multiplication, I can't see a problem: the code
import pickle
d = {}
for i in xrange(65000*50 ):
d[i]=i
print "Starting dump"
s = pickle.dumps(d)
works just fine for me. Can you please modify it so that it does cause
a problem?
Regards,
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Benjamin Scott |
last post by:
Hello.
I attempted to build a compound dictionary:
len(Lst)=1000
len(nuerLst)=250
len(nuestLst)=500
Dict={}
|
by: Byron |
last post by:
Hello,
I am a newbie and would like to know if it is possible to convert a
string back to a dictionary?
For example, I can convert a dictionary to a string by doing this:
>>> names = {"Candy" : 2.95, "Popcorn" : 4.95}
>>> strNames = str(names)
>>> print strNames
|
by: Hans Georg Krauthaeuser |
last post by:
Dear all,
I have a long running application (electromagnetic compatibility
measurements in mode-stirred chambers over GPIB) that use pickle
(cPickle) to autosave a class instance with all the measured data from
time to time.
At the beginning, pickling is quite fast but when the data becomes more
and more pickling slows down rapidly.
|
by: Luis P. Mendes |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
my program builds a dictionary that I would like to save in a file.
My question is what are the simple ways to do it?
The first solution I've thought of is to transform the dictionary in a
|
by: Ganesan selvaraj |
last post by:
I using C# .net. i want to split the text files based of the some condition.
my source text file size may be 4 kb to 4 gb. some time when i split the
i got the "out of memory exception. when i read from the file i read the
10mb and split the this content and clear the buffer and read the second 10
mb and so on.
How can i rectify the problem?
| |
by: RubenDV |
last post by:
I am writing code for a dictionary type in c, but i have some problems
allocating the memory for it. The dictionary type itself is a struct
with the following contents:
typedef struct {
char ** keys;
char ** content;
int count; /* Amount of space actually used */
int allocated_space; /* Amount of space allocated for the keys and
content */
|
by: Nagu |
last post by:
I am trying to save a dictionary of size 65000X50 to a local file and
I get the memory error problem.
How do I go about resolving this? Is there way to partition the pickle
object and combine later if this is a problem due to limited resources
(memory) on the machine (it is 32 bit machine Win XP, with 4GB RAM).
Please advice.
Thank you,
|
by: Nagu |
last post by:
I didn't have the problem with dumping as a string. When I tried to
save this object to a file, memory error pops up.
I am sorry for the mention of size for a dictionary. What I meant by
65000X50 is that it has 65000 keys and each key has a list of 50
tuples.
I was able to save a dictionary object with 65000 keys and a list of
15-tuple values to a file. But I could not do the same when I have a
list of 25-tuple values for 65000 keys.
|
by: Catherine Moroney |
last post by:
I'm writing a python program that reads in a very large
"pickled" file (consisting of one large dictionary and one
small one), and parses the results out to several binary and hdf
files.
The program works fine, but the memory load is huge. The size of
the pickle file on disk is about 900 Meg so I would theoretically
expect my program to consume about twice that (the dictionary
contained in the pickle file plus its repackaging into...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |