在和boost ::蟒蛇::导入后会发生什么?
升压文档不指定。当我使用提振::蟒蛇::进口,正是被指定模块导入?我的猜测是在'__ __主
(只是为了确保)。
The Boost documentation does not specify this. When I use boost::python::import, where exactly is the specified module imported? My guess would be in '__main__'
(just to make sure).
此外,当模块对象超出范围会发生什么?鉴于Boost的文档&MDASH的措辞; 返回:对象实例持有到导入模块的引用—我猜只有参考超出范围,模块对象仍然发现在'__ __主
(或者是任何一个被导入)。
Also, what happens when the module object goes out of scope? Given the wording in Boost's docs — "Returns: An instance of object which holds a reference to the imported module" — I would guess only the reference goes out of scope, the module object is still found within '__main__'
(or wherever it was imported).
的基本机制是 PyImport_ImportModule
,并没有,它不触及 __ __主要
。成功导入模块插入 sys.modules中
字典,所以当你DECREF什么函数返回的对象没有被释放 - 仍有至少是一个参考活着
The underlying mechanism is PyImport_ImportModule
, and no, it doesn't touch __main__
. Successfully imported modules are inserted into sys.modules
dict, so the object is not freed when you DECREF what the function returns — there is still at least that one reference alive.