https://github.com/python/cpython/blob/4395ff1e6a18fb26c7a66...
isn’t exactly pure Python, because, under a different runtime (eg PyPy), the code would take a different path (the “pure Python” implementation of _count_elements[1] instead of the C implementation[2][3]). Yes, it's hard to draw exact lines when it comes to Python, especially as the language is so tied to its implementation. However, I think in this case it's relatively clear that the code that specific line is calling is an optimization in CPython, specifically intended to get around some of the VM overhead. Said optimization comes into play in the OP.
[1]: https://github.com/python/cpython/blob/4395ff1e6a18fb26c7a66...
[2]: https://github.com/python/cpython/blob/4395ff1e6a18fb26c7a66...
[3]: https://github.com/python/cpython/blob/4395ff1e6a18fb26c7a66...