[Python-Dev] Integer representation (Was: ssize_t question: longs in header files)

Fredrik Lundh fredrik at pythonware.com
Tue May 30 13:39:17 CEST 2006


Martin v. Löwis wrote:

>> That's why I'd like my alternative proposal (int as ABC and two
>> subclasses that may remain anonymous to the Python user); it'll save
>> the alignment waste for short ints and will let us use a smaller int
>> type for the size for long ints (if we care about the latter).
>
> I doubt they can remain anonymous. People often dispatch by type
> (e.g. pickle, xmlrpclib, ...), and need to put the type into a
> dictionary. If the type is anonymous, they will do
>
>   dispatch[type(0)] = marshal_int
>   dispatch[type(sys.maxint+1)] = marshal_int

"may remain anonymous" may also mean that type(v) is type(int) for all integers.

but I think isinstance(v, int) should be good enough for Py3K; I really hope all
the talk about typing and multimethods and stuff results in tools that can be used
to implement explicit dispatch machineries such as the one in XML-RPC (why
not turn all the marshal methods into a single multimethod?)

</F> 





More information about the Python-Dev mailing list