Python Unbound Method: What It Is and How It Changed
An unbound method in Python 2 is the object you get when you access an instance method through the class. Python 3 replaces it with a plain function. See what changed and how to handle the difference.

When you access an instance method through the class itself in Python 2, you get an unbound method. For example:
class Greeter:
def greet(self, name):
return f"Hello, {name}"
# Access via the class
method = Greeter.greet
print(type(method)) # In Python 2: <type 'instancemethod'>An unbound method behaves like a function that expects the instance as its first argument. You can call it by passing an instance explicitly:
g = Greeter()
Greeter.greet(g, "Alice") # Works in both Python 2 and 3In Python 2, Greeter.greet is an unbound method object, distinct from a plain function. This distinction was a source of confusion for many developers.
How Python 3 Changed Unbound Methods
Python 3 removed the unbound method type. Accessing a method via the class now returns a plain function:
class Greeter:
def greet(self, name):
return f"Hello, {name}"
method = Greeter.greet
print(type(method)) # <class 'function'>For valid calls, the behavior is the same: you pass the instance as the first argument. The most visible difference is the object type. In Python 2, an unbound method also enforced that the first argument was an instance of the class; in Python 3, no such check exists. This simplification makes the language more consistent and removes a special case that had little practical benefit.
Bound vs Unbound Methods: Practical Differences
A bound method is created when you access a method through an instance. It automatically captures the instance, so you don't pass self explicitly:
g = Greeter()
bound = g.greet
print(bound("Bob")) # "Hello, Bob"An unbound method (or a plain function in Python 3) requires you to pass the instance manually. The practical difference matters when you inspect method types or when you pass methods around as callbacks.
For example, inspect.ismethod returns True for a bound method in both Python 2 and 3, but it returns True for an unbound method only in Python 2. In Python 3, inspect.ismethod(Greeter.greet) is False, while inspect.isfunction is True.
Common Scenarios Where This Distinction Matters
You see this distinction whenever you intentionally access a method through the class rather than an instance. It often comes up in metaprogramming and decorators, or when you need to pass SomeClass.method to code that will supply the instance at call time.
Another common scenario is passing a method as a callback. If you pass Greeter.greet to a function that expects a callable, you must provide the instance at call time. This is different from passing g.greet, which already has the instance bound.
Compatibility Considerations for Python 2 and 3
If you maintain legacy code that still supports both Python 2 and Python 3, you need to be aware of the type difference. Code that relies on inspect.ismethod to detect unbound methods will behave differently. For example:
import inspect
class A:
def method(self):
pass
if inspect.ismethod(A.method):
print("It's a method")
else:
print("It's a function")In Python 2, this prints "It's a method"; in Python 3, it prints "It's a function". To write compatible code, rely on callable behavior rather than the inspect.ismethod result, or add an inspect.isfunction check for the Python 3 case. In legacy projects, libraries like six provide helpers to abstract over these differences.
Performance and Runtime Considerations
Creating a bound method object has a small runtime cost because Python allocates a new object each time you access the method through an instance. If you call a method repeatedly in a hot loop, you can avoid this overhead by storing the unbound method (or function) and passing the instance explicitly:
method = Greeter.greet
for _ in range(1000):
method(g, "Alice")This avoids allocating a bound method object on each iteration. The performance difference is usually small, but it may matter in tight loops. However, this style is less readable and should be used only when profiling indicates a bottleneck.
Choosing Between Instance Methods, Class Methods, and Static Methods
The concept of unbound methods is closely related to how you define and call methods. Python offers three method types:
| Method type | First argument | Access via class | Typical use |
|---|---|---|---|
| Instance method | self | Returns a function (or unbound method in Python 2) | Operations that require instance state |
| Class method | cls | Returns a bound method to the class | Operations that need class-level state |
| Static method | none | Returns a plain function | Operations that don't depend on class or instance |
Choose an instance method when the logic depends on instance attributes. Use a class method when the logic needs class-level data or when you need a factory. Use a static method when the logic is independent of both. Understanding how these methods appear when accessed via the class helps you predict their behavior in callbacks and higher-order functions.
Try matching browser tools
All toolsSmall utilities that fit Python work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Python guides
All Python guidesPython iter(): How the Built-in Function Works
Explains Python's iter() built-in: how it creates iterators, the two-argument sentinel form, custom iterator classes, and common edge cases.
Python Pika: Queues, Exchanges, Routing Keys, and Acknowledgements
Learn how to use Python's Pika client with RabbitMQ: declare queues and exchanges, publish with routing keys, consume messages, and handle acknowledgements reliably.
Python Kafka: kafka-python vs Confluent Client
python kafka python vs confluent kafka: Compare kafka-python and Confluent Kafka Python clients: API differences, performance, feature coverage, and when to choose eac...
Python Kafka Offsets, Partitions, and Manual Commits
Learn how Kafka offsets and partitions work and how to manually commit offsets in Python consumers with kafka-python and confluent-kafka. Covers sync vs async commits, rebalances, and seeking.
More in Python
All Python guidesThe guides filed next to this one in Python, in library order.