0

The code I tried to understand is:

foo = int("123", 8)
print(foo)

I want to view the source code of builtin functions in python to see how int() is implemented. As I have tried, sorted() is located here. Its function name is builtin_sorted, but nothing returns when I search builtin_int in the GitHub page.

Hope someone could help me understand its source code. Thanks in advance!

Cookie
  • 75
  • 1
  • 1
  • 5
  • not the source code, but `int??` in the python console will give you some info. at least in ipython – SuperStew Jun 23 '21 at 14:36
  • You get there by searching `cpython int source code` on Google. – mkrieger1 Jun 23 '21 at 14:41
  • @mkrieger1 I find longobject.c. Thank you! – Cookie Jun 23 '21 at 14:43
  • The "int" name in the "builtin" module is defined here: https://github.com/python/cpython/blob/bb3e0c240bc60fe08d332ff5955d54197f79751c/Python/bltinmodule.c#L3034. From there you can trace the definitions. – mkrieger1 Jun 23 '21 at 14:48

0 Answers0