This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: Add capsule API to _decimal
类型: enhancement Stage: needs patch
Components: Versions: Python 3.5
process
状态: open Resolution:
Dependencies: 后续:
分配给: skrah 抄送列表: Arfrever, larry, lemburg, mark.dickinson, p-ganssle, rhettinger, scoder, skrah
优先级: normal 关键字:

skrah2012-07-01 10:02 创建。最近一次由 admin2022-04-11 14:57 修改。

Messages (9)
msg164469 - (view) Author: Stefan Krah (skrah) * (Python committer) 日期: 2012-07-01 10:02
Unfortunately, this won't make it into 3.3. -- The self-review of mpdecimal.c had priority and was extremely time consuming.
msg164474 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) 日期: 2012-07-01 10:42
See issue #7652 for context.
msg200154 - (view) Author: Stefan Krah (skrah) * (Python committer) 日期: 2013-10-17 19:01
I've looked at this, and the question is: Do we really need a capsule
API?  All relevant symbols in _decimal start with Py* and shouldn't
need to be static.
msg200168 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) 日期: 2013-10-17 20:48
On 17.10.2013 21:01, Stefan Krah wrote:
> 
> Stefan Krah added the comment:
> 
> I've looked at this, and the question is: Do we really need a capsule
> API?  All relevant symbols in _decimal start with Py* and shouldn't
> need to be static.

You need a capsule in order to use the C API from other extension
modules. See the datetime module for an example.
msg200234 - (view) Author: Stefan Krah (skrah) * (Python committer) 日期: 2013-10-18 09:39
I believe you, but I'd like to understand why. :)

It seems to me that a module and also PyInit_xxx() can be loaded portably.
Say the handles to the module are cached somewhere after loading and
initializing.  I think this already happens in Python/dynload_shlib.c.

Why can't another module use a slightly modified form of _PyImport_GetDynLoadFunc()
to get any non-static function apart from PyInit_xxx() by re-using the cached
handle?
msg200236 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) 日期: 2013-10-18 10:02
On 18.10.2013 11:39, Stefan Krah wrote:
> 
> Stefan Krah added the comment:
> 
> I believe you, but I'd like to understand why. :)

:-)

> It seems to me that a module and also PyInit_xxx() can be loaded portably.
> Say the handles to the module are cached somewhere after loading and
> initializing.  I think this already happens in Python/dynload_shlib.c.
> 
> Why can't another module use a slightly modified form of _PyImport_GetDynLoadFunc()
> to get any non-static function apart from PyInit_xxx() by re-using the cached
> handle?

This may work on Linux (and probably does if you use the right
DL flags), but I don't think this works reliably or at all on other
platforms such as Windows. Symbols from shared libs are not necessarily
available to all other shared libraries in the same process.

CObjects, which Capsules originate from, were added to address this
problem in a portable way. It's the Python standard approach to
"importing" C APIs from other extension modules.
msg200256 - (view) Author: Stefan Krah (skrah) * (Python committer) 日期: 2013-10-18 14:00
Marc-Andre Lemburg <report@bugs.python.org> wrote:
> This may work on Linux (and probably does if you use the right
> DL flags), but I don't think this works reliably or at all on other
> platforms such as Windows. Symbols from shared libs are not necessarily
> available to all other shared libraries in the same process.

Thanks. On Linux the scheme works (I stored the DLL handle in
the PyModuleObject and added a function PyModule_GetSymbol()).
msg226294 - (view) Author: Stefan Behnel (scoder) * (Python committer) 日期: 2014-09-03 06:43
Is this superseded by issue 22194 now or the other way round?
msg226300 - (view) Author: Larry Hastings (larry) * (Python committer) 日期: 2014-09-03 07:32
I think #22194 is a duplicate issue.
历史
日期 用户 动作 参数
2022-04-11 14:57:32admin修改github: 59442
2019-02-27 16:45:57p-ganssle修改抄送: + p-ganssle
2014-09-03 07:32:51larry修改消息: + msg226300
2014-09-03 06:43:04scoder修改抄送: + scoder

消息: + msg226294
versions: + Python 3.5, - Python 3.4
2013-10-18 14:00:11skrah修改消息: + msg200256
2013-10-18 10:02:10lemburg修改消息: + msg200236
2013-10-18 09:39:56skrah修改消息: + msg200234
2013-10-17 20:48:56lemburg修改消息: + msg200168
2013-10-17 19:01:55skrah修改消息: + msg200154
2012-07-01 14:41:16Arfrever修改抄送: + Arfrever
2012-07-01 10:42:26mark.dickinson修改消息: + msg164474
2012-07-01 10:09:42larry修改抄送: + larry
2012-07-01 10:02:50skrah创建