8000 DOC: Fixed minor typos in temp_elide.c by mortada · Pull Request #8709 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: Fixed minor typos in temp_elide.c #8709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
DOC: Fixed minor typos in temp_elide.c
[ci skip]
  • Loading branch information
mortada committed Feb 28, 2017
commit fe652b6957d59c9335ed2268a9a2d9d6bc53be7c
20 changes: 10 additions & 10 deletions numpy/core/src/multiarray/temp_elide.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/*
* Functions used to try to avoid/elide temporaries in python expressions
* of type a + b + b by translating some operations into inplace operations.
* of type a + b + b by translating some operations into in-place operations.
* This example translates to this bytecode:
*
* 0 LOAD_FAST 0 (a)
Expand All @@ -23,7 +23,7 @@
* instructions so they always have a reference count larger than 1.
* The temporary of the first BINARY_ADD on the other hand only has a count of
* 1. Only temporaries can have a count of 1 in python so we can use this to
* transform the second operation into an inplace operation and not affect the
* transform the second operation into an in-place operation and not affect the
* output of the program.
* CPython does the same thing to resize memory instead of copying when doing
* string concatenation.
Expand All @@ -41,19 +41,19 @@
* This is an expensive operation so temporaries are only avoided for rather
* large arrays.
*
* A possible future improvement would be to change cpython to give as access
* A possible future improvement would be to change cpython to give us access
* to the top of the stack. Then we could just check that the objects involved
* are on the cpython stack instead of checking the function callstack.
*
* Elision can be applied to all operations that do have inplace variants and
* Elision can be applied to all operations that do have in-place variants and
* do not change types (addition, subtraction, multiplication, float division,
* logical and bitwise operations ...)
* For commutative operations (addition, multiplication, ...) if eliding into
* the lefthand side fails it can succedd on the righthand side by swapping the
* the lefthand side fails it can succeed on the righthand side by swapping the
* arguments. E.g. b * (a * 2) can be elided by changing it to (2 * a) * b.
*
* TODO only supports systems with backtrace(), windows can probably be
* supported too by using the appropriate windows apis.
* TODO only supports systems with backtrace(), Windows can probably be
* supported too by using the appropriate Windows APIs.
*/

#if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION
Expand All @@ -69,7 +69,7 @@
#endif
/*
* Heuristic size of the array in bytes at which backtrace overhead generation
* becomes less than speed gained by inplace operations. Depends on stack depth
* becomes less than speed gained by in-place operations. Depends on stack depth
* being checked. Measurements with 10 stacks show it getting worthwhile
* around 100KiB but to be conservative put it higher around where the L2 cache
* spills.
Expand All @@ -79,7 +79,7 @@
#else
/*
* in debug mode always elide but skip scalars as these can convert to 0d array
* during in place operations
* during in-place operations
*/
#define NPY_MIN_ELIDE_BYTES (32)
#endif
Expand Down Expand Up @@ -272,7 +272,7 @@ check_callers(int * cannot)

/*
* check if in "alhs @op@ orhs" that alhs is a temporary (refcnt == 1) so we
* can do inplace operations instead of creating a new temporary
* can do in-place operations instead of creating a new temporary
* "cannot" is set to true if it cannot be done even with swapped arguments
*/
static int
Expand Down
0