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
Title: Add capsule API to _decimal
Type: enhancement Stage: needs patch
Components: Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: skrah Nosy List: Arfrever, larry, lemburg, mark.dickinson, p-ganssle, rhettinger, scoder, skrah
Priority: normal Keywords:

Created on 2012-07-01 10:02 by skrah, last changed 2022-04-11 14:57 by admin.

Messages (9)
msg164469 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 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) Date: 2012-07-01 10:42
See issue #7652 for context.
msg200154 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 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) Date: 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) Date: 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) Date: 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) Date: 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) Date: 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) Date: 2014-09-03 07:32
I think #22194 is a duplicate issue.
History
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59442
2019-02-27 16:45:57p-gansslesetnosy: + p-ganssle
2014-09-03 07:32:51larrysetmessages: + msg226300
2014-09-03 06:43:04scodersetnosy: + scoder

messages: + msg226294
versions: + Python 3.5, - Python 3.4
2013-10-18 14:00:11skrahsetmessages: + msg200256
2013-10-18 10:02:10lemburgsetmessages: + msg200236
2013-10-18 09:39:56skrahsetmessages: + msg200234
2013-10-17 20:48:56lemburgsetmessages: + msg200168
2013-10-17 19:01:55skrahsetmessages: + msg200154
2012-07-01 14:41:16Arfreversetnosy: + Arfrever
2012-07-01 10:42:26mark.dickinsonsetmessages: + msg164474
2012-07-01 10:09:42larrysetnosy: + larry
2012-07-01 10:02:50skrahcreate