Chapter 4. Data Types and Structures
Bad programmers worry about the code. Good programmers worry about data structures and their relationships.
— Linus Torvalds
This chapter introduces basic data types and data structures of Python. Although the Python interpreter itself already brings a rich variety of data structures with it, NumPy and other libraries add to these in a valuable fashion.
The chapter is organized as follows:
- Basic data types
-
The first section introduces basic data types such as
int,float, andstring. - Basic data structures
-
The next section introduces the fundamental data structures of Python (e.g.,
listobjects) and illustrates control structures, functional programming paradigms, and anonymous functions. - NumPy data structures
-
The following section is devoted to the characteristics and capabilities of the
NumPyndarrayclass and illustrates some of the benefits of this class for scientific and financial applications. - Vectorization of code
-
As the final section illustrates, thanks to
NumPy’s array class vectorized code is easily implemented, leading to more compact and also better-performing code.
The spirit of this chapter is to provide a general introduction to Python specifics when it comes to data types and structures. If you are equipped with a background from another programing language, say C or Matlab, you should be able to easily grasp the differences that Python usage might bring along. The topics introduced here are all important and fundamental for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access