python slice是共享内存吗,将Python对象放置在共享内存中

Is there a Python module that would enable me to place instances of non-trivial user classes into shared memory?

By that I mean allocating directly in shared memory as opposed to pickling into and out of it.

multiprocessing.Value and multiprocessing.Array wouldn't work for my use case as they only seem to support primitive types and arrays thereof.

The only thing I've found so far is POSH, but it hasn't changed in eight years. This suggests that it's either super-stable or is out of date. Before I invest time in trying to get it work, I'd like to know if there are alternatives I haven't discovered yet.

I only need this to work on Linux.

解决方案

That's kind of a tough one. The best solution I can think of is pickling your objects and using a c_char_p with multiprocessing.sharedctypes. You'd still have to make sure no null bytes got into the c_char_p, either by escaping them or converting to hex.

On second thought, maybe you should go with POSH.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值