Skip to content

overloading

Overloading is the practice of defining multiple implementations under a single name, with the programming language selecting which one to run based on the number and types of the arguments supplied.

Overloading is a form of ad hoc polymorphism, meaning each combination of argument types gets its own implementation instead of one that works for every type. Statically typed languages such as C++, Java, and C# resolve an overloaded function or method call at compile time by matching the argument list against the available signatures, a process called overload resolution.

Languages without built-in function overloading, including Python, reach similar results through default arguments, manual type checks, or helpers like functools.singledispatch. That decorator picks an implementation based on the type of the first argument.

Operator overloading applies the same idea to operators, so the plus sign can mean addition for numbers and concatenation for strings. Python supports this form through special methods like .__add__(). Overloading is also distinct from overriding, which replaces an inherited method in a subclass rather than offering alternatives under one name.

Operator and Function Overloading in Python

Tutorial

Operator and Function Overloading in Custom Python Classes

How to overload built-in functions and operators in your custom Python classes in order to make your code more Pythonic.

intermediate python

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated Sept. 4, 2026