Cross-process dictionary/hashtable

Calvin Spealman ironfroggy at gmail.com
Mon Sep 18 16:05:00 EDT 2006


On 18 Sep 2006 12:44:32 -0700, Sandra-24 <sandravandale at yahoo.com> wrote:
> A dictionary that can be shared across processes without being
> marshaled?
>
> Is there such a thing already for python?
>
> If not is there one for C maybe?
>
> I was just thinking how useful such a thing could be. It's a great way
> to share things between processes. For example I use a cache that
> subclasses a dictionary. It would be trivial to modify it to work
> across processes by changing the base class and the locking mechanism.
>
> Thanks,
> -Sandra

Maybe what you want is something like memcache
(http://cheeseshop.python.org/pypi/memcached), which offers a basic
in-memory, key-value share that processes (even on different boxes)
can connect to. Of course, as with any kind of concurrent work, its
going to be far easier to have some restrictions, which memcache has.
For example, full python objects being shared isn't a great idea, or
even possible in many situations. The closest you could get with
something like memcache is to wrap it up in a dictionary-like object
and have it pickle things coming in and out, but that won't work for
everying and has security concerns.



More information about the Python-list mailing list