[Python-Dev] Comparison speed

M.-A. Lemburg mal@lemburg.com
Wed, 16 May 2001 11:32:36 +0200


"Martin v. Loewis" wrote:
> 
> > Sounds like we ought to do a search-and-destroy on type comparisons,
> > replacing with isinstance() where possible.
> 
> At least in my applications, this is unfortunately not possible: I
> want a test for byte-string-or-unicode-string. This could be done with
> two isinstance calls, but that is certainly less efficient.
> 
> Marc-Andre once proposed a type representing the immediate supertype
> of both byte strings and unicode strings; let's call it abstract string.
> Then I could write isinstance(e, types.AbstractString).

I'm still holding on to that idea... hopefully, Guido's type
checkins will make this possible in 2.2 or 2.3. The same
should then be done for numbers, sequences and mappings (all
abstract "types" defined in abstract.c).

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/