Episode 40: How Python Manages Memory and Creating Arrays With np.linspace
The Real Python Podcast
Dec 18, 2020 57m
Have you wondered how Python manages memory? How are your variables stored in memory, and when do they get deleted? This week on the show, David Amos is here, and he has brought another batch of PyCoder’s Weekly articles and projects.
Along with the Real Python article on Python memory management, we also talk about another article about creating even and non-even spaced arrays in Python with np.linspace.
We share an article titled “The Unholy Way of Using Virtual Environments”. This leads to a discussion on how to structure the directories around a virtual environment.
We also cover several other articles and projects from the Python community including, storing a list in an int, why you should use an ORM (Object Relational Manager), unraveling not
in Python, an open-source Python fuzzer, and Python static website generators.
Course Spotlight: How Python Manages Memory
Get ready for a deep dive into the internals of Python to understand how it handles memory management. By the end of this course, you’ll know more about low-level computing, understand how Python abstracts lower-level operations, and find out about Python’s internal memory management algorithms.
Topics:
- 00:00:00 – Introduction
- 00:01:38 –
np.linspace()
: Create Evenly or Non-Evenly Spaced Arrays - 00:05:20 – The Unholy Way of Using Virtual Environments
- 00:17:33 – Storing a list in an int
- 00:24:48 – Why Should You Use an ORM (Object Relational Mapper)?
- 00:32:30 – Video Course Spotlight
- 00:33:24 – Unravelling not in Python
- 00:40:03 – How Python Manages Memory
- 00:45:28 – Follow-up from Jupylet
- 00:46:51 – Announcing the Atheris Python Fuzzer
- 00:50:42 – nikola: Static Website and Blog Generator
Show Links:
np.linspace()
: Create Evenly or Non-Evenly Spaced Arrays – In this tutorial, you’ll learn how to use NumPy’s np.linspace()
effectively to create an evenly or non-evenly spaced range of numbers. You’ll explore several practical examples of the function’s many uses in numerical applications.
The Unholy Way of Using Virtual Environments – If you’ve used virtual environments before, you may have created a venv/
folder inside the root directory of your project. This is standard, but has some downsides. Have you every thought about reversing this and putting your project inside your venv/
folder?
Storing a list in an int – For a fun exercise, learn how you can leverage Python’s unlimited integer precision to encode and store lists of any size as a single integer. Because, why not?
Why Should You Use an ORM (Object Relational Mapper)? – Budding web developers learning Model-View-Controller frameworks are taught that they should use an Object Relational Mapper (ORM) to interface with their databases. But the “why” is often brushed aside or omitted entirely, leaving a fledgling programmer with burning questions like “What are ORMs, anyway?” and “What problems do they solve?”
Unravelling not
in Python – In the next blog post in his series about Python’s syntactic sugar, Brett Cannon tackles what would seem to be a very simple bit of syntax, but which actually requires diving into multiple layers to fully implement: not
.
How Python Manages Memory – Get ready for a deep dive into the internals of Python to understand how it handles memory management. By the end of this course, you’ll know more about low-level computing, understand how Python abstracts lower-level operations, and find out about Python’s internal memory management algorithms.
Announcing the Atheris Python Fuzzer – Get started with fuzzing, a technique for automatically finding bugs in Python code by repeatedly trying various inputs to your program, using Google’s newly open-sourced Python fuzzer called Atheris.
Project Links:
- Jupylet: Getting Started
- nikola: Static Website and Blog Generator
- atheris: Python Fuzzing Framework
Additional Links:
- Look Ma, No For-Loops: Array Programming With NumPy: Real Python article
- NumPy:
numpy.ndarray
- An Effective Python Environment: Making Yourself at Home: Real Python article
- A quick-and-dirty guide on how to install packages for Python: Brett Cannon’s blog
- Data Management With Python, SQLite, and SQLAlchemy: Real Python article
- SQLAlchemy: The Python SQL Toolkit and Object Relational Mapper
- Writing your first Django app: DjangoProject.com
- Memory Management in Python: Real Python article
- The Python Language Reference
- Memory Management: Python docs
- Pelican: Static Site Generator, Written in Python
- Lektor: Flexible and Powerful Static Content Management System