0% found this document useful (0 votes)
33 views1 page

Python and Data Structure

CPython is the original implementation of Python, written in C. It compiles Python code into bytecode that is then interpreted and executed by the CPython program. The key data structures in Python like lists, tuples, dicts and sets are implemented differently in CPython than in other Python implementations like Jython and IronPython. CPython uses C arrays to implement lists while Jython uses Java ArrayLists. Understanding these underlying implementations can help optimize Python code.

Uploaded by

cxiii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

Python and Data Structure

CPython is the original implementation of Python, written in C. It compiles Python code into bytecode that is then interpreted and executed by the CPython program. The key data structures in Python like lists, tuples, dicts and sets are implemented differently in CPython than in other Python implementations like Jython and IronPython. CPython uses C arrays to implement lists while Jython uses Java ArrayLists. Understanding these underlying implementations can help optimize Python code.

Uploaded by

cxiii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Gabriele Angeletti

 (http://blackecho.github.io) se
mo

Mar 23, 2016 • Gabriele Angeletti • blog programming

Understanding Python's
underlying data structures
Let’s take a look at how Python’s typical data structures (lists,
tuples, dicts, sets) are implemented, and how we can take
advantage of this knowledge to optimize our code. The
implementation we are focusing on is CPython.

CPython is the original implementation


(http://stackoverflow.com/questions/17130975/python-vs-
cpython) of Python, written in C. Since Python is a high-level
language, the code you execute has to be evaluated and
interpreted somehow. CPython is the program that translates
Python instructions, written following the language
specification, to something the machine can actually execute.
Specifically, it compiles the code into bytecode, which then get
interpreted and executed. There are other implementations of
Python “the language”, like Jython (http://www.jython.org/)
written in Java and Iron Python (http://ironpython.net/) written
in C#. The high-level Python code you wrote is the same (a list
of integers is l = [1, 2, 3] in all of them), it is the
underlying implementation that changes: for example CPython
creates a C array, while Jython creates a Java ArrayList.

You might also like