annotate Python/hypot.c @ 17104:a488a63cb867 legacy-trunk

Fix PyFrame_FastToLocals() and counterpart to deal with cells and frees. Note there doesn't seem to be any way to test LocalsToFast(), because the instructions that trigger it are illegal in nested scopes with free variables. Fix allocation strategy for cells that are also formal parameters. Instead of emitting LOAD_FAST / STORE_DEREF pairs for each parameter, have the argument handling code in eval_code2() do the right thing. A side-effect of this change is that cell variables that are also arguments are listed at the front of co_cellvars in the order they appear in the argument list.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Wed, 21 Mar 2001 16:43:47 +0000
parents 59f8cedcf049
children 2dea40e40d9d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4176
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* hypot() replacement */
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 #include "config.h"
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13658
diff changeset
4 #include "pyport.h"
4176
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 4176
diff changeset
6 double hypot(double x, double y)
4176
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 {
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 double yx;
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 x = fabs(x);
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 y = fabs(y);
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 if (x < y) {
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 double temp = x;
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 x = y;
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 y = temp;
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 }
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 if (x == 0.)
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 return 0.;
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 else {
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 yx = y/x;
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 return x*sqrt(1.+yx*yx);
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 }
37d009b1bf45 *** empty log message ***
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 }