Function overloading provides one operation through multiple signatures or argument forms. The forms should perform conceptually similar, identical, or equivalent operations; unrelated behaviors deserve different names. section 7.1.3 section 7.6
Use overloading when:
- Several calls express the same conceptual operation, such as calculating an area or measuring a line. section 7.1.3
- Different argument counts or datatypes provide convenient representations of the same result. section 7.1.3
- A single name is clearer than inventing separate names for strongly related operations. section 7.1.3
Selecting an area calculation
Python does not retain multiple same-named method definitions in one class; the last definition replaces earlier ones. Runtime parameter checking can simulate overloading: Shape.area(2, 3) calculates a rectangle's area, while Shape.area(1.0) calculates a circle's area. The implementation selects the behavior from whether arg2 is present. section 7.1.3
Measuring lines from multiple representations
Line.length accepts endpoint coordinates, a coordinate list, dictionaries, or Point objects, then computes the same distance. Explicit type and argument-count checks support the forms but make the method complex and prone to error. The @multimethod decorator separates each typed implementation and dispatches at runtime; unsupported combinations still produce an error. section 7.1.3 section 7.1.4


