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.

asked Feb 17, 2012 at 6:37

4 Answers 4

7

You can download it here:

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

answered Feb 17, 2012 at 6:40
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.

answered Nov 27, 2012 at 18:33

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

answered Feb 17, 2012 at 7:22

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.

Alex Riley
178k46 gold badges274 silver badges247 bronze badges
answered May 26, 2014 at 9:29

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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.