[Compiler-sig] Number classes

Jeremy Hylton jeremy@zope.com
Fri, 19 Apr 2002 12:58:39 -0400


>>>>> "FB" == Finn Bock <bckfnn@worldonline.dk> writes:

  >> If there's no difference to the way the numbers are handled, it
  >> would be better to mark a generic Num type with some flags or
  >> attributes that provide the extra info.

  FB> That will work for me too, but as I understand your first
  FB> paragraph above, CPython don't know the type without parsing the
  FB> string.

If we have 

expr = Num(object value, num_type type)
num_type = Int | Long | Float | Complex

Then I can parse the string and create a num passing the PyObject *
and setting the appropriate type flag.  I could also handle separate
IntNum, LongNum, etc. ctors, but that seems like more nodes that we
really need.

If the Num node(s) need to have the type specified, that I'd like it
to take an object not a string.

Jeremy