Help in Placing Object in Memory

2007-03-27 Thread 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?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help in Placing Object in Memory

2007-03-27 Thread Diez B. Roggisch
Clement wrote:

 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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help in Placing Object in Memory

2007-03-27 Thread Michael L Torrie
On Tue, 2007-03-27 at 16:49 +0200, Diez B. Roggisch wrote:
  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.

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

 
 To do such a thing, look at pyro.
 
 Diez

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help in Placing Object in Memory

2007-03-27 Thread Erik Johnson

Diez B. Roggisch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 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


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help in Placing Object in Memory

2007-03-27 Thread 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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help in Placing Object in Memory

2007-03-27 Thread [EMAIL PROTECTED]
On Mar 27, 10:33 am, Clement [EMAIL PROTECTED] wrote:
 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.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help in Placing Object in Memory

2007-03-27 Thread Harry George
Clement [EMAIL PROTECTED] writes:

 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


-- 
Harry George
PLM Engineering Architecture
-- 
http://mail.python.org/mailman/listinfo/python-list