|
10 | 10 |
|
11 | 11 | /*
|
12 | 12 | * Functions used to try to avoid/elide temporaries in python expressions
|
13 |
| - * of type a + b + b by translating some operations into inplace operations. |
| 13 | + * of type a + b + b by translating some operations into in-place operations. |
14 | 14 | * This example translates to this bytecode:
|
15 | 15 | *
|
16 | 16 | * 0 LOAD_FAST 0 (a)
|
|
23 | 23 | * instructions so they always have a reference count larger than 1.
|
24 | 24 | * The temporary of the first BINARY_ADD on the other hand only has a count of
|
25 | 25 | * 1. Only temporaries can have a count of 1 in python so we can use this to
|
26 |
| - * transform the second operation into an inplace operation and not affect the |
| 26 | + * transform the second operation into an in-place operation and not affect the |
27 | 27 | * output of the program.
|
28 | 28 | * CPython does the same thing to resize memory instead of copying when doing
|
29 | 29 | * string concatenation.
|
|
41 | 41 | * This is an expensive operation so temporaries are only avoided for rather
|
42 | 42 | * large arrays.
|
43 | 43 | *
|
44 |
| - * A possible future improvement would be to change cpython to give as access |
| 44 | + * A possible future improvement would be to change cpython to give us access |
45 | 45 | * to the top of the stack. Then we could just check that the objects involved
|
46 | 46 | * are on the cpython stack instead of checking the function callstack.
|
47 | 47 | *
|
48 |
| - * Elision can be applied to all operations that do have inplace variants and |
| 48 | + * Elision can be applied to all operations that do have in-place variants and |
49 | 49 | * do not change types (addition, subtraction, multiplication, float division,
|
50 | 50 | * logical and bitwise operations ...)
|
51 | 51 | * For commutative operations (addition, multiplication, ...) if eliding into
|
52 |
| - * the lefthand side fails it can succedd on the righthand side by swapping the |
| 52 | + * the lefthand side fails it can succeed on the righthand side by swapping the |
53 | 53 | * arguments. E.g. b * (a * 2) can be elided by changing it to (2 * a) * b.
|
54 | 54 | *
|
55 |
| - * TODO only supports systems with backtrace(), windows can probably be |
56 |
| - * supported too by using the appropriate windows apis. |
| 55 | + * TODO only supports systems with backtrace(), Windows can probably be |
| 56 | + * supported too by using the appropriate Windows APIs. |
57 | 57 | */
|
58 | 58 |
|
59 | 59 | #if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION
|
|
69 | 69 | #endif
|
70 | 70 | /*
|
71 | 71 | * Heuristic size of the array in bytes at which backtrace overhead generation
|
72 |
| - * becomes less than speed gained by inplace operations. Depends on stack depth |
| 72 | + * becomes less than speed gained by in-place operations. Depends on stack depth |
73 | 73 | * being checked. Measurements with 10 stacks show it getting worthwhile
|
74 | 74 | * around 100KiB but to be conservative put it higher around where the L2 cache
|
75 | 75 | * spills.
|
|
79 | 79 | #else
|
80 | 80 | /*
|
81 | 81 | * in debug mode always elide but skip scalars as these can convert to 0d array
|
82 |
| - * during in place operations |
| 82 | + * during in-place operations |
83 | 83 | */
|
84 | 84 | #define NPY_MIN_ELIDE_BYTES (32)
|
85 | 85 | #endif
|
@@ -272,7 +272,7 @@ check_callers(int * cannot)
|
272 | 272 |
|
273 | 273 | /*
|
274 | 274 | * check if in "alhs @op@ orhs" that alhs is a temporary (refcnt == 1) so we
|
275 |
| - * can do inplace operations instead of creating a new temporary |
| 275 | + * can do in-place operations instead of creating a new temporary |
276 | 276 | * "cannot" is set to true if it cannot be done even with swapped arguments
|
277 | 277 | */
|
278 | 278 | static int
|
|
0 commit comments