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.
Related Resources
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.
For additional information on related topics, take a look at the following resources:
- Python's Magic Methods: Leverage Their Power in Your Classes (Tutorial)
- Operators and Expressions in Python (Tutorial)
- Object-Oriented Programming in Python vs Java (Tutorial)
- Inheritance and Composition: A Python OOP Guide (Tutorial)
- Duck Typing in Python: Writing Flexible and Decoupled Code (Tutorial)
- Python's Magic Methods in Classes (Course)
- Python's Magic Methods: Leverage Their Power in Your Classes (Quiz)
- Python Operators and Expressions (Course)
- Operators and Expressions in Python (Quiz)
- Python vs Java: Object Oriented Programming (Course)
- Inheritance and Composition: A Python OOP Guide (Course)
- Inheritance and Composition: A Python OOP Guide (Quiz)
- Getting to Know Duck Typing in Python (Course)
- Duck Typing in Python: Writing Flexible and Decoupled Code (Quiz)
By Martin Breuss • Updated Sept. 4, 2026