parse-time optimizations 
Author Message
 parse-time optimizations

> Thing is, if you're writing code that benefits from constant folding -
> WHY?  If your code contains things like:

>     "a" + "b"

> then you have bigger problems than Python's lack of optimizations...

There are three main things which would benefit from constant folding.

1. Negative numbers. Currently -3 performs a runtime negation each time
through the code. This could be folded to a stored negative number.

2. Complex numbers. Complex numbers are often written as 2+2j (for example),
which again is a runtime computation each time through the code.

3. (Future) Rational numbers. In the future, I think rationals will
primarily be written as 2+2/3. This involves both a division and an addition
at runtime, when such a constant could be folded at compile-time.

These are (or will be) the most common cases, and I do not feel that any of
these indicate "big problems" in design. The only way to write these without
performing the computation each time is to bind them to a variable name.
Often this is the right thing to do anyway (remove magic numbers), but even
in this case you will take the performance hit at least once.

I don't see this as an urgent thing to do, but I think it would be a
worthwhile project for someone (anyone, possibly me) when they get the time
or have a desire to play with the python source. There are no disadvantages
to constant folding, no backwards compatibility issues, and I'm certain a
number of applications will benefit.

Tim Delaney

Sun, 16 Nov 2003 09:22:15 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Portable version of time:parse-universal-time ?

2. Ruby Compile-time optimization

3. Parsing a date/time field

4. Python module to parse time?

5. Parsing Run-time Formats

6. Confused about parsing time...

7. parse-time

8. Bug in time.c (was Time.times problems)

9. time and scheduling (was: bug report: [ #447945 ] time.time() is not non-decreasing)

10. time zones, daylight saving time, and universal time

11. Manugistics run-time [was: STSC run-time]

12. GMT time vs. local time


Powered by phpBB® Forum Software