-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mypyc] Generate smaller code for casts (#12839)
Merge a cast op followed by a branch that does an error check and adds a traceback entry. Since casts are very common, this reduces the size of the generated code a fair amount. Old code generated for a cast: ``` if (likely(PyUnicode_Check(cpy_r_x))) cpy_r_r0 = cpy_r_x; else { CPy_TypeError("str", cpy_r_x); cpy_r_r0 = NULL; } if (unlikely(cpy_r_r0 == NULL)) { CPy_AddTraceback("t/t.py", "foo", 2, CPyStatic_globals); goto CPyL2; } ``` New code: ``` if (likely(PyUnicode_Check(cpy_r_x))) cpy_r_r0 = cpy_r_x; else { CPy_TypeErrorTraceback("t/t.py", "foo", 2, CPyStatic_globals, "str", cpy_r_x); goto CPyL2; } ```
- Loading branch information
Showing
7 changed files
with
270 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.