Re: Design question - Sharing of single object by multiple processes



Mike D wrote:
Hello, I've just picked up the Python language and am really enjoying it.

I've just signed up to this mailing list and I'm looking forward to taking part in some discussions.

My first post is a question I've been pondering for the last couple of days:

For relatively static data (such as a list), is it possible to load a single instance and have many python processes access it?

First there's the problem of having multiple processes access any kind of shared resource. So your question makes me wonder whether you mean processes, or threads. Are you *sure* you mean processes?

I want to have an object in memory. This object will be loaded on application start up and will contain a list of objects. These will be obtained from (most likely) the file system.

So "application startup" is different from "process startup"? Your application is a group of co-operating processes? Really?

My reasoning is: I want to prevent a file system or database fetch each time as it seems unnecessary.

It might also seem unnecessary to start the Python interpreter for each process, but you are going to have to ...

Is this possible? In Java I'm pretty sure this could implemented with an object factory and static methods. My understanding is that python invokes a separate process for each request however.

Your understanding is clearly informed by some information you have omitted to share with us.

If possible, what would be a good way of providing a new structure as it is updated.

If anyone could give me some advice or point me in the correct direction I'd really appreciate it.

Thanks in advance,

More answers, please. There are mechanisms such as Pyro (Python remote objects) that allow inter-process method calls, but I am far from convinced that's what you really want (or need, anyway). Perhaps yo could let us know a little more about what it really is you are trying to do, and convince me, at least, that this isn't just a case of premature optimization.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

.



Relevant Pages

  • Re: File Creation Not Working In A Thread Class?
    ... Your first post was about as far away from that as it could be. ... The python community has some real jerks in it, ... this is not my first interaction with the Python IRC ...
    (comp.lang.python)
  • Re: How Common Lisp sucks
    ... Pascal Costanza wrote: ... Other popular technologies include Python and apparently Ruby. ... My impression was that you want to have a say in what should change in Common Lisp or not. ... Yes, these projects have moved beyond 1.0, but do you really think you would be able to convince them to make significant changes? ...
    (comp.lang.lisp)
  • Re: struct size confusion:
    ... I am relatively new to Python and this is my first post on ... the integer is forced to start on a 4-byte boundary so two pad bytes must be inserted between the short and the int. ... When the int is first no padding is needed - the short starts on a 2-byte boundary. ... I will be reading shorts and longs sent from C into Python ...
    (comp.lang.python)
  • Re: Convert raw binary file to ascii
    ... It's my first post to python-list, so first let me introduce myself... ... and programmer (currently in Record System company, ... big companies [developed in Python + WX ... Jan Kaliszewski ...
    (comp.lang.python)
  • Re: Explanation of Instance Variables in Python
    ... >>I am writing a chapter for teaching OOP in Python. ... attributes in general is critical to understanding its implementation of OOP. ... fish, not serving fish, though;-): ...
    (comp.lang.python)