New GitHub issue #100726 from eendebakpt:<br>

<hr>

<pre>
# Feature or enhancement

The python `range` object contains code to compute the length from the start, stop and step values. This calculation is performed with `PyLong` objects which is expensive. We can add a fast path for the common case where start, stop and step all fit into a long value. 


# Pitch

Benchmark results are in the PR.

The range object itself is often converted to a range iterator. For the iterator object there already is a fast version (the the method [fast_range_iter](https://github.com/python/cpython/blob/e6d44407827490a5345e8393fbdc78fd6c14f5b1/Objects/rangeobject.c#L901)). A further optimization could be achieved by creating a specialized range object that can construct the fast range iterator without conversions to `PyLong`, but this is much more involved.




<!--
You can freely edit this text. Remove any lines you believe are unnecessary.
-->

</pre>

<hr>

<a href="https://github.com/python/cpython/issues/100726">View on GitHub</a>
<p>Labels: type-feature</p>
<p>Assignee: </p>