Skip to content

Commit

Permalink
fast_range_1
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt committed Nov 6, 2023
1 parent a7b0f63 commit dac1b29
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Objects/rangeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ range_from_array(PyTypeObject *type, PyObject *const *args, Py_ssize_t num_args)
if (!stop) {
return NULL;
}
if (_PyLong_IsCompact( (PyLongObject *)args[0])) {
obj = PyObject_New(rangeobject, type);
if (obj == NULL) {
return NULL;
}
obj->start = _PyLong_GetZero();
obj->stop = args[0];
obj->step = _PyLong_GetOne();
if (_PyLong_IsNonNegativeCompact((PyLongObject*)args[0]))
obj->length = args[0];
else {
obj->length = _PyLong_GetZero();
}
return obj;
}
start = _PyLong_GetZero();
step = _PyLong_GetOne();
break;
Expand Down

0 comments on commit dac1b29

Please sign in to comment.