Boost logo

Boost-Build :

Subject: Re: [Boost-build] Extension style
From: Anthony Foglia (AFoglia_at_[hidden])
Date: 2010-07-28 14:16:25


Juraj Ivančić wrote:
> On 26.7.2010 14:22, Vladimir Prus wrote:
>
>> I guess I can try to put it in a different way:
>>
>> 1. Is there a way for a single C++ application to create several, fully
>> independent, instances of Python interpreter?
>
> Googling came up with this:
>
> http://docs.python.org/c-api/init.html#Py_NewInterpreter
>
>> 2. It is possible, within a single instance of Python interpreter, to
>> load the same module twice, so and get two copies of global data of
>> that module?
>
> I think that this can be achieved with module aliases (untested):
>
> import module as module1
> import module as module2

No, the import statement keeps track of what was imported. It doesn't work.

In [1]: import numpy as np1

In [2]: import numpy as np2

In [3]: id(np1)
Out[3]: 47437984

In [4]: id(np2)
Out[4]: 47437984

You might be able to do this by digging into the import mechanics. Look
at the __import__ builtin and the imp module. But I don't think it's
supported, and not something typically done.

-- 
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk