Index Ai Academy
Glossary · Phase 7 · Software engineering

Call stack

The list of functions that are running, newest on top. Each call adds an entry, and each return removes one.

Python keeps two places. The call stack holds one frame per running function, and each frame holds names. The heap holds the objects those names point at: lists, dicts, instances. A name is a small arrow; an object is a box. Returning from a function throws its frame away, and the names in it with it.

Try it now

Names on the left, objects on the right. Inside add_tag the name tags points at the very same box as mine, so its change shows outside. list(mine) builds a second box, so copy is separate.

Learn it properly

How computers run code · Bits, memory, the processor, and what really happens when Python runs. About 40 minutes.

Other terms from the same lesson

  • bytecode: The simple instruction list Python turns your code into before its virtual machine runs it, one instruction at a time.
  • compiler: A program that translates code into machine instructions ahead of time, so the result runs fast.
  • garbage collector: The part of a language runtime that finds memory nobody uses any more and frees it.
  • interpreter: A program that carries out code as it reads it, instead of translating it all first.
  • reference count: The number of names that point at an object. When it reaches zero, Python frees the object.
Keep learning

More in plain English.

1286 terms in the glossary, each with the lesson that teaches it.

1286 terms

The glossary

Every word you'll meet in AI and machine learning, explained in everyday language.

Phase 7 · lesson 40 min

How computers run code

Bits, memory, the processor, and what really happens when Python runs.

Never trained an AI? Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account. Teach it to write