Help in Placing Object in Memory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Clement

    #1

    Help in Placing Object in Memory

    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....?

  • Diez B. Roggisch

    #2
    Re: Help in Placing Object in Memory

    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

    Comment

    • Michael L Torrie

      #3
      Re: Help in Placing Object in Memory

      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

      Comment

      • Erik Johnson

        #4
        Re: Help in Placing Object in Memory


        "Diez B. Roggisch" <deets@nospam.w eb.dewrote in message
        news:56sp7kF2b0 fj6U1@mid.uni-berlin.de...
        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


        Comment

        • Bruno Desthuilliers

          #5
          Re: Help in Placing Object in Memory

          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.

          Comment

          • sjdevnull@yahoo.com

            #6
            Re: Help in Placing Object in Memory

            On Mar 27, 10:33 am, "Clement" <jeba.r...@gmai l.comwrote:
            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.

            Comment

            • Harry George

              #7
              Re: Help in Placing Object in Memory

              "Clement" <jeba.ride@gmai l.comwrites:
              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:




              --
              Harry George
              PLM Engineering Architecture

              Comment

              Working...