Understanding how Python builtins are mapped to underlying C implementation

Viewed 65

If I go to the implementation of let's say the next() builtin function, I'm forwarded to the builtins.py module to following code:

def next(iterator, default=None): # real signature unknown; restored from __doc__
    """
    next(iterator[, default])
    
    Return the next item from the iterator. If default is given and the iterator
    is exhausted, it is returned instead of raising StopIteration.
    """
    pass

Now, it looks like this functions does nothing but obviously that's not the case.

I understand that this function is implemented in C under the hood, but how and when is this function(or other builtin functions) mapped to the underlying C implementation?

If you have an answer to this question, can you please also provide links that I can read in order to better unterstand this topic?

I'm not asking, where the code is, but how and when the function is mapped to that code

Thank you.

0 Answers
Related