Re: Multiplication optimization

2006-02-20 Thread Tim Roberts
"Paul McGuire" <[EMAIL PROTECTED]> wrote: > >Does Python's run-time do any optimization of multiplication >operations, like it does for boolean short-cutting? That is, for a >product a*b, is there any shortcutting of (potentially expensive) >multiplication operations as in: Integer multiplication

Re: Multiplication optimization

2006-02-20 Thread Peter Otten
Atanas Banov wrote: > Paul McGuire wrote: >> Does Python's run-time do any optimization of multiplication >> operations, like it does for boolean short-cutting? That is, for a >> product a*b, is there any shortcutting of (potentially expensive) >> multiplication operations > > no. and the reason

Re: Multiplication optimization

2006-02-19 Thread Atanas Banov
Paul McGuire wrote: > Does Python's run-time do any optimization of multiplication > operations, like it does for boolean short-cutting? That is, for a > product a*b, is there any shortcutting of (potentially expensive) > multiplication operations no. and the reason is very simple: to the extent

Re: Multiplication optimization

2006-02-18 Thread Jean-Paul Calderone
On 18 Feb 2006 16:48:38 -0800, Paul McGuire <[EMAIL PROTECTED]> wrote: >Does Python's run-time do any optimization of multiplication >operations, like it does for boolean short-cutting? Here's the beginning of int_mul from Objects/intobject.c: static PyObject * int_mul(PyObject *v, PyObje

Re: Multiplication optimization

2006-02-18 Thread Raymond Hettinger
[Paul McGuire] > Does Python's run-time do any optimization of multiplication > operations, like it does for boolean short-cutting? Usually, it is safest (and typically true) to assume that Python performs no optimizations. To go beyond making assumptions, it is easy to run a few timings: >>> fr

Re: Multiplication optimization

2006-02-18 Thread Steven D'Aprano
On Sat, 18 Feb 2006 16:48:38 -0800, Paul McGuire wrote: > Does Python's run-time do any optimization of multiplication > operations, like it does for boolean short-cutting? Do you know that these shortcuts are optimizations, or are you just assuming it takes less time to do the comparison than it

Multiplication optimization

2006-02-18 Thread Paul McGuire
Does Python's run-time do any optimization of multiplication operations, like it does for boolean short-cutting? That is, for a product a*b, is there any shortcutting of (potentially expensive) multiplication operations as in: if a == 0 return 0 if a == 1 return b retu