extractor interface which can be used to extract C++ types from Python objects.
We have discussed two main use cases for extractions
1. In user code which needs to retrieve C++ objects from their corresponding Python objects:
- Getting value:
void f(object x) { int y = extract<int>(x); // retrieve an int from x }
- Users may also want to explicitly check for convertibility:
int g(object x) { extractor<int> get_int(x); if (get_int) return get_int(); else return 0; }
2. In the implementation of sequence from_python converters (e.g. Python tuple/list -> std::vector)