[Python-Dev] thoughts on the bytes/string discussion

Terry Reedy tjreedy at udel.edu
Sun Jun 27 00:11:03 CEST 2010


The several posts in this and other threads go me to think about text 
versus number computing (which I am more familiar with).

For numbers, we have in Python three builtins, the general purpose ints 
and floats and the more specialized complex. Two other rational types 
can be imported for specialized uses. And then there are 3rd-party 
libraries like mpz and numpy with more number and array of number types.

What makes these all potentially work together is the special method 
system, including, in particular, the rather complete set of __rxxx__ 
number methods. The latter allow non-commutative operations to be mixed 
either way and ease mixed commutative operations.

For text, we have general purpose str and encoded bytes (and bytearry). 
I think these are sufficient for general use and I am not sure there 
should even be anything else in the stdlib. But I think it should be 
possible to experiment with and use specialized 3rd-party text classes 
just as one can with number classes.

I can imagine that inter-operation, when appropriate, might work better 
with addition of a couple of  missing __rxxx__ methods, such as the 
mentioned __rcontains__. Although adding such would affect the 
implementation of a core syntax feature, it would not affect syntax as 
such as seen by the user.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list