Help in Placing Object in Memory

H

Harry George

Clement said:
I am newbie to Python...... i want to know something..........

can i place an object in disk instead of placing in Main Memory...?

If possible, can you please explain with some scripts...?

can two python script share a common object....?

For the CPU to use the object, it needs to be in RAM. But it is
possible to save the RAM image onto disk, and then bring it back
later. The common approach is called "pickling", though there are
several variants on this:

http://docs.python.org/lib/persistence.html
 
C

Clement

I am newbie to Python...... i want to know something..........

can i place an object in disk instead of placing in Main Memory...?

If possible, can you please explain with some scripts...?

can two python script share a common object....?
 
D

Diez B. Roggisch

Clement said:
I am newbie to Python...... i want to know something..........

can i place an object in disk instead of placing in Main Memory...?
If possible, can you please explain with some scripts...?

See the module pickle and it's examples.
can two python script share a common object....?

What do you mean by that? They can both load a pickled object, yes. But they
can't share it as a at-runtime object, where changes in one script are
immediately are known to the other.

To do such a thing, look at pyro.

Diez
 
M

Michael L Torrie

What do you mean by that? They can both load a pickled object, yes. But they
can't share it as a at-runtime object, where changes in one script are
immediately are known to the other.

Remote procedure call, such as Python Twisted's PB library can allow
this to virtually be the case.
 
E

Erik Johnson

What do you mean by that? They can both load a pickled object, yes. But they
can't share it as a at-runtime object, where changes in one script are
immediately are known to the other.

To do such a thing, look at pyro.

Or not natively (i.e., that battery isn't included). I believe it can
still be done, though: http://poshmodule.sourceforge.net/
(I haven't used the module - just used Google to locate it)

You could, of course, roll-your-own solution using shared memory and/or
other interprocess communication (http://docs.python.org/lib/ipc.html)

Hope that helps,
-ej
 
B

Bruno Desthuilliers

Clement a écrit :
I am newbie to Python......

To Python only, or to both Python and programming in general ?
i want to know something..........

can i place an object in disk instead of placing in Main Memory...?

You can store it on disk (cf pickles and friends), but to actually use
it you'll have to load it in memory anyway.
can two python script share a common object....?

While there are technical answers on this, I guess you'd better learn
how to use functions and pass objects between them.

My 2 cents.
 
S

sjdevnull

I am newbie to Python...... i want to know something..........

can i place an object in disk instead of placing in Main Memory...?

If possible, can you please explain with some scripts...?

can two python script share a common object....?


POSH allows shared objects, but it's not built-in. http://poshmodule.sourceforge.net/

If you're only looking for persistence (and not sharing), there's the
(standard) shelve module. http://docs.python.org/lib/module-shelve.html
If your need to share objects is fairly minimal and not performance-
sensitive, you might be able to get by with shelves, sync, and file
locking or some other locking.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top