TallJimbo/bp3 — Issue #2: overhaul conversion/registry
Author: TallJimbo
Created: 2012-02-12 17:37:36+00:00
State: open

We've come up with a number of reasons to do a major redesign of the Boost.Python type conversion system.

1. We'd like to ensure a module's behavior is not affected by importing an unrelated module that may register different converters. There is still some debate on how best to achieve this; I think the following should meet any requirements:
- Converters may be registered as "private", "local", "shared", or "global".
- Global converters are not associated with a module and always have the lowest precedence (they are only invoked after all overloads using other converters have failed).
- "Private" converters may be used only by the module that registered them.
- "Local" converters are defined by one module, but may be explicitly imported by others (after which they will be considered equivalent to the module's own converters in terms of precedence).
- "Shared" converters behave like local converters in the module that registered them or modules that explicitly import them,
but are also available with the same low precedence given to global converters to all modules.
- "Shared" is the default.

2. Luabind has demonstrated a way to do priority-based (rather than simple try/fail) function overloads; we should adopt this in Boost.Python.

3. We'd like to provide a system that allows converters for template classes to be registered automatically when they appear in a function signature, without requiring users to enumerate all possible template instantiations in advance. Such converters should not, of course, appear in the registry more than once.

4. The current global registry model runs into problems with concurrency and multiple interpreters. It may not be possible to address these issues without making the library more difficult to use in simpler contexts, but if there are easy steps we can take to alleviate these concerns or make it easier to address them in the future we should take them.