[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issues

Skip Montanaro skip@pobox.com
Sat, 5 Oct 2002 20:01:12 -0500


    >> If Guido was adding complex numbers today instead of long ago, I
    >> wonder if he would allow a special notation for them, or just suggest
    >> a constructor.

    Guido> At the time I believe there was heavy pressure from the Numeric
    Guido> crowd to allow a special notation.  I'm not so sure if I should
    Guido> have given in though.

However, 1+4j can be peephole optimized into a compile-time constant whereas
complex(1,4) can't.  This is generally not a big deal, but to people who
deal with complex numbers a lot (and tend to be more sensitive to
optimization issues) it can be.  I believe when I tested my peephole
optimizer using pybench several years ago, the complex number tests showed
the most improvement because I could collapse constant expressions.

Of course, people using lots of complex numbers probably initialize their
complex constants outside of loops. ;-)

Skip