What Python values are, how types define behavior, and why runtime concepts matter.

objects identity truthiness bytes

Why this matters

Python behavior starts with objects

Many confusing Python behaviors become easier to understand once you stop thinking only in terms of syntax and start thinking in terms of objects, types, values, identity, and representation.

Core concepts

What this section teaches

Values are objects

Python variables refer to objects. They are not simple labeled boxes holding raw values.

Types define behavior

Truthiness, equality, representation, and operations depend on object type.

Representation matters

Text, bytes, and displayed output are related, but they are not the same thing.

Foundational type model

How Python thinks about values

Dynamic typing

In Python, you do not declare a variable’s type ahead of time. A name can be rebound to different kinds of objects over time.

x = 42
x = "Hi"
Key idea: changing x does not mutate the old object. It changes which object the name refers to.

C vs. Python memory

A low-level primitive value and a Python object should not be imagined as the same thing. Python values carry more structure than a raw fixed-size primitive.

Conceptual C integer
42
Conceptual Python integer object
ref count
type pointer
size / metadata
value: 42

Under the hood: PyObject

In standard CPython, Python values are implemented as C-level objects with structure and metadata. That is one reason Python values behave differently from simple primitive variables in languages like C.

  • Reference count: supports object lifetime tracking.
  • Type information: links the object to its behavior.
  • Metadata: helps explain why Python objects are richer than raw primitive values.

This is a conceptual teaching model, not a byte-for-byte memory inspector.

Type categories

Major built-in families

Text & numeric

  • str: text as Unicode characters
  • int: whole numbers
  • float: floating-point values
  • complex: numbers with real and imaginary parts

These are some of the most familiar Python value types, but they are still Python objects with behavior, not raw machine primitives in the usual beginner sense.

Boolean & null

  • bool: truth values used in logic and control flow
  • NoneType: the type of None

These types are small in surface area but important for truthiness, conditional behavior, and representing the absence of a meaningful value.

Binary types

  • bytes: immutable sequence of byte values
  • bytearray: mutable sequence of byte values

These become especially important when you need to think about encoding, protocols, files, and data that is not yet decoded into text.

A
character view
65 01000001

CPython context

Conceptual memory footprint

These values are approximate teaching numbers for a typical 64-bit CPython mental model. They are useful for intuition, not as an exact promise for every build or version.

Data Type Example Approx Size Conceptual Comparison
int 42 ~28 bytes primitive-sized value plus Python object overhead
float 3.14 ~24 bytes numeric payload plus object structure
str "A" ~50 bytes text object, not just a raw character
bool True object-backed truth value represented as a Python object
bytes b"A" ~34 bytes binary container object
NoneType None singleton object special shared object representing “no value”

Interactive labs

Explore the behavior

Truthiness Playground

Explore which values Python treats as truthy or falsy.

Identity vs Equality

Compare “same value” with “same object” through guided scenarios.

Bytes & Encoding

See how text becomes bytes and how different encodings change the binary result.

Type Inspector Lab

Inspect common Python values by type, category, mutability, and truthiness.

Representation Lab: str() vs repr()

Compare display-friendly output with Python’s more explicit representation of a value.

Mutability Preview Lab

Preview which built-in types can change in place and which ones produce a new result instead.

Literal to Object Lab

See how different Python literals create different kinds of runtime objects.

Numeric Tower Preview

Explore how Python numeric types interact and how result types change across expressions.

Common misconceptions

Things learners often get wrong

  • Variables are not boxes of raw data.
  • Python integers should not be imagined as plain C primitive integers.
  • Text is not the same thing as bytes.
  • is does not mean “has the same value.”

Takeaways

What to remember

  • Python values are objects with type-defined behavior.
  • Dynamic typing means names can be rebound to different object types.
  • CPython objects carry more structure than simple primitive values.
  • This foundation makes advanced runtime behavior easier to understand.