8

Is it possible to view the source code of Python's functions like sum, zip and the like? I just want to know about the implementation.

Thanks.

4 Answers 4

7

You can download it here:

http://www.python.org/getit/source/

Sign up to request clarification or add additional context in comments.

2 Comments

The source of the modules is (fairly obviously) in the Modules directory.
sum and zip aren't modules though. He's asking about the backend C code.
6

Source for builtins functions (like sum, zip, etc) are in http://hg.python.org/cpython/file/57c157be847f/Python/bltinmodule.c.

Comments

3

You cant see the code for the sum and zip because those are wrapper of c functions. But other module you can check on http://hg.python.org/cpython/file/2.7/Lib

Comments

0

This will give you the location of the Python source code files on disk:

import sys
print(["%s %s" % (k,v) for k,v in sys,modules.items()] if k == "re")

On Windows, it is usually found on C:\python33\lib\. and on Linux it is /usr/python2.7/lib/....

Once there, you can view the .py files as you wish.

1 Comment

I think OP is asking for the C source code of the internal funcions like sum, min, max, reduce and so on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.