> So you are saying that for example "if do_reverse: data.reverse()" is > *much* slower than "data.reverse()" ? I would expect that checking the > truthness of a boolean would be negligible compared to the reverse > itself. Did you try converting all checks to identity comparisons with > None ? I mean replacing every "if compile_time_condition:" in a loop > with > > compile_time_condition = compile_time_condition or None > for i in some_loop: > if compile_time_condition is None: > ... > > It's hard to believe that the overhead of identity checks is > comparable (let alone much higher) to the body of the loop for > anything more complex than "pass". >
There are also dict accesses (to extract the format parameters, such as length and offsets) to the format, which are absent. Besides, the fields are usually small, so reverse is relatively cheap. Eli -- http://mail.python.org/mailman/listinfo/python-list