Python id() Function

Last Updated : 29 Aug 2026

Python id() function returns an identity of an object. This is an integer which is guaranteed to be unique. This function takes an argument an object and returns a unique integer number which represents identity. Two objects with non-overlapping lifetimes may have the same id() value.

Syntax of id() Function

It has the following syntax:

Parameters

  • object: It is an object of which id is to be returned.

Return Values

It returns a unique integer number.

Examples of Python id() Function

Let's see some examples of id() function to understand it's functionality.

Example 1: Using id() Function to Get Memory Address of Objects

This example demonstrates how the id() function returns the unique identity (memory address) of different objects in Python.

Python

Execute Now

Output:

139963782059696
139963805666864
139963781994504

Example 2: Using id() Function with User-Defined Class Object

This example demonstrates how the id() function is used to get the unique identity of a user-defined class object in Python.

Python

Execute Now

Output:

101
Mohan
Object id: 140157155861392

Example 3: Comparing Object Equality and Identity using id() Function

This example demonstrates the difference between object equality (==) and object identity (id()) in Python.

Python

Execute Now

Output:

True False
False False

Next TopicPython Set