2

I wanted to know how the max() builtin function works. So I tried to read the source code at svn.python.org, but I couldn't find the __builtin__ module. It should be in __builtin__.py, right?

Can somebody tell me where to find the source code for this module? Is this available in ubuntu linux (which has the 2.6 version)?

approxiblue
  • 6,982
  • 16
  • 51
  • 59
damon
  • 8,127
  • 17
  • 69
  • 114
  • http://hg.python.org/cpython/file/bd853311ffe0/Objects – Ashwini Chaudhary Nov 16 '12 at 06:58
  • Python development moved from `svn` to `hg` a couple of years ago. The Python source repos at `svn.python.org` are out-of-date. Use `hg.python.org` as noted above. – Ned Deily Nov 16 '12 at 07:01
  • 1
    possible duplicate of [Finding the source code for built-in Python functions?](http://stackoverflow.com/questions/8608587/finding-the-source-code-for-built-in-python-functions) – Mogsdad Sep 01 '15 at 02:07

1 Answers1

4

__builtin__ as its name implies, refers to the special module containing functions and classes built in to the language itself. The implementation of these functions is in C, not Python. (Specifically, in the bltinmodule.c source file.)

cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • 2
    See the "builtin_max" function – David Robinson Nov 16 '12 at 06:53
  • 1
    Here's the link to [`builtin_max`](http://hg.python.org/cpython/file/c9910fd022fc/Python/bltinmodule.c#l1439) in the [2.6.8 hg repo](http://hg.python.org/cpython/file/c9910fd022fc). `min_max` starts at line 1336. – Eryk Sun Nov 16 '12 at 11:06