From: "Guido van Rossum"
The main reason I want to be able to LBYL (and, AFAICT, it's the same as Alex's reason) is to support multiple dispatch.
But isn't your application one where the types are mapped from C++?
Not all of them, not hardly! Boost.Python is about interoperability, not just about wrapping C++. My users are writing functions that want to accept any Python sequence as one argument (for some definition of "sequence"). They'd like to dispatch to different implementations of that function based on whether that argument is a sequence or a scalar numeric type.
Then you should be able to dispatch on type() of the arguments. Or am I misunderstanding, and do you want to make multi-dispatch a standard paradigm in Python?
Absolutely.
In other words, it wouldn't be user code doing the looking. The best reason to support protocol introspection is so that we can provide users with a way to write more-elegant code, instead of messing around with manual type inspection. What's your position on multiple dispatch?
That it's too inefficient in a language with run-time dispatch to even think about it.
That's funny, my users are very happy with how fast it works in Boost.Python. I don't see any reason it should have to be much less efficient in pure Python for most cases... the important "type categories" could be builtins. And as others have pointed out, it could even be used to get certain optimzations. -Dave ----------------------------------------------------------- David Abrahams * Boost Consulting dave@boost-consulting.com * http://www.boost-consulting.com