AndJM
AndJM

Reputation: 151

Reading Python implementations

Curious about how Python's itertools.product was implemented, I took to searching the C:\Python27 directory. Could not find it. This lead me to post these related questions:

I understand that the statement import xyzabc reads a module from some place (possibly where the environment variable directs it), but since I found no module itertools, 1) how is it being imported? and 2) can someone point me to that implementation? (or is it written is C, so that I will have trouble reading it?)

Mildly related: 3) is anything Python "closed source"?

Upvotes: 1

Views: 58

Answers (1)

Sven Marnach
Sven Marnach

Reputation: 601759

  1. The itertools module is one of the modules compiled directly into the interpreter; see sys.builtin_module_names for a full list of these modules.

  2. The itertools module is implemented in C, see e.g. its Python 2.7 source code.

  3. No, all of the CPython implementation is open.

Upvotes: 3

Related Questions