"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
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
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
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
[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
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
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