Sharing modules in python processes

We are writing a system in which memory is dense. There are several python processes that will import the same set of classes. If processes load gazillion classes, and each process consumes a couple of hundred megabytes, then 10 processes, and I run to concerts. Is there a way to “split” class imports between python processes?

Summary:

import classA # Process 1 : loads classA in memory
import classA # Process 2 : reuses what was loaded previously by Process 1

PS: What I'm trying to achieve is what you do with modules .soin C / C ++.

+5
source share
2 answers

, ( ). import , fork(), .

, , , refcounts . , , .

+2

, python. , , . , 100 , , - (, ).

, , , - python, C/++. , python . .

P.S. python , . C/++, , .

+1

All Articles