| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| // Slicing a string/list/tuple always returns the same type. | ||
| PyTypeObject *type = sym_get_type(container); | ||
| if (type == &PyUnicode_Type || | ||
| type == &PyList_Type || |
There was a problem hiding this comment.
| type == &PyList_Type || | |
| type == &PyBytes_Type || | |
| type == &PyList_Type || |
I do not know whether slicing a bytes object occurs often enough to add PyBytes_Type here (and whether the jit slows down if we add more cases here), but if I understand correctly slicing bytes (or bytearray) results in a bytes (or bytearray) so we could add them.
Sorry, something went wrong.
There was a problem hiding this comment.
@fluhus, this PR is probably fine for now, but feel free to add other sequence types like this in a follow-up PR (with tests)!
Sorry, something went wrong.
There was a problem hiding this comment.
Looks great, just one style nitpick:
Sorry, something went wrong.
| for i in range(n): | ||
| false = i == TIER2_THRESHOLD | ||
| empty = "X"[:false] | ||
| empty += "" # Make JIT realize this is a string. |
There was a problem hiding this comment.
Nice!
Sorry, something went wrong.
| // Slicing a string/list/tuple always returns the same type. | ||
| PyTypeObject *type = sym_get_type(container); | ||
| if (type == &PyUnicode_Type || | ||
| type == &PyList_Type || |
There was a problem hiding this comment.
@fluhus, this PR is probably fine for now, but feel free to add other sequence types like this in a follow-up PR (with tests)!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Slicing a string/list/tuple always returns the same type.
Make the optimizer assign a string/list/tuple type to the result of slicing a string/list/tuple.
@brandtbucher