The misunderstanding is due to poor documentation that doesn't catch a major change in specs, or due to the CPython implementation which dare to write a class for what is listed as a built-in function in the specs.

In Python 2, it is a function that returns a list. In the online documentation of Python 2, it is listed under Built-in Functions. The first line of help(map) on CPython 2.7.10 reads

Help on built-in function map in module builtin

correctly calling it a function.

In Python 3, they changed the specs that it returns an iterator instead of a list. As @RafaelC noted, it has an advantage of lazy loading. Althiugh it is still under "Built-n Functions", the CPython implementation decided to make it a class. This change is reflected in help(map), which you have seen and quoted in the question.

What you are doing when you call map() in CPython 3 is, you are creating an object of class map with the parameters you throw. This is clearly shown when you try to print what map() returns.

CPython 2.7.10:

>>> map(int, "12345")
[1, 2, 3, 4, 5]

CPython 3.7.2:

>>> map(int, "12345")
<map object at 0x1023454e0>

So you are clearly creating an object of class map, which makes what you've seen in help(map) sound very fine.

So it seems that, to the CPython core developers, a class can be a "function" with some definiton of a "function". This is clearly misleading. Anyway, it implements the necessary methods that enables it to be used as an iterator. (as the docs says, if you ignore that it's listed under builtin functions.)


It's used as a function

That's because the syntax of calling a function and fetching its return value is identical to creating a class object (by calling its initializer) and fetching the object.

For example, using a function my_function() as in return_value = my_function() is syntactically no different from creating a class object of my_class() as in my_object = my_class(). When you call map() in CPython 3, you are creating an object of class map. But you would write the same even if map were a function. That's why you're confused.


So in short,

  1. map was a function in CPython 2, but is a class in CPython 3. That is clear from help(map) on both versions, and that's what the CPython implementation does.

  2. The documentation keeps it under "Built-in functions" while CPython implementation finds liberty to write a class for it, causing confusion.

  3. It's a shame that the two aren't clearly distinguished in the docs.

Answer from Ignatius on Stack Overflow
Top answer
1 of 1
3

The misunderstanding is due to poor documentation that doesn't catch a major change in specs, or due to the CPython implementation which dare to write a class for what is listed as a built-in function in the specs.

In Python 2, it is a function that returns a list. In the online documentation of Python 2, it is listed under Built-in Functions. The first line of help(map) on CPython 2.7.10 reads

Help on built-in function map in module builtin

correctly calling it a function.

In Python 3, they changed the specs that it returns an iterator instead of a list. As @RafaelC noted, it has an advantage of lazy loading. Althiugh it is still under "Built-n Functions", the CPython implementation decided to make it a class. This change is reflected in help(map), which you have seen and quoted in the question.

What you are doing when you call map() in CPython 3 is, you are creating an object of class map with the parameters you throw. This is clearly shown when you try to print what map() returns.

CPython 2.7.10:

>>> map(int, "12345")
[1, 2, 3, 4, 5]

CPython 3.7.2:

>>> map(int, "12345")
<map object at 0x1023454e0>

So you are clearly creating an object of class map, which makes what you've seen in help(map) sound very fine.

So it seems that, to the CPython core developers, a class can be a "function" with some definiton of a "function". This is clearly misleading. Anyway, it implements the necessary methods that enables it to be used as an iterator. (as the docs says, if you ignore that it's listed under builtin functions.)


It's used as a function

That's because the syntax of calling a function and fetching its return value is identical to creating a class object (by calling its initializer) and fetching the object.

For example, using a function my_function() as in return_value = my_function() is syntactically no different from creating a class object of my_class() as in my_object = my_class(). When you call map() in CPython 3, you are creating an object of class map. But you would write the same even if map were a function. That's why you're confused.


So in short,

  1. map was a function in CPython 2, but is a class in CPython 3. That is clear from help(map) on both versions, and that's what the CPython implementation does.

  2. The documentation keeps it under "Built-in functions" while CPython implementation finds liberty to write a class for it, causing confusion.

  3. It's a shame that the two aren't clearly distinguished in the docs.

Top answer
1 of 2
19

The term "mapping" is described in the Python glossary as:

A container object that supports arbitrary key lookups and implements the methods specified in the Mapping or MutableMapping abstract base classes. Examples include dict, collections.defaultdict, collections.OrderedDict and collections.Counter.

The requirements to subclass collections.abc.Mapping are described in its docstring:

A Mapping is a generic container for associating key/value pairs.

This class provides concrete generic implementations of all methods except for __getitem__, __iter__, and __len__.

So you can define a new mapping type by subclassing collections.abc.Mapping, and implementing three methods: __len__, __getitem__, and __iter__.

>>> from collections.abc import Mapping
>>> def func(**kwargs):
...   print(kwargs)
...
>>> class MyMapping(Mapping):
...   def __len__(self):
...     return 1
...   def __getitem__(self, k):
...     return 'bananas'
...   def __iter__(self):
...     return iter(['custard'])
...
>>> func(**MyMapping())
{'custard': 'bananas'}
2 of 2
9

According to Python docs:

A container object that supports arbitrary key lookups and implements the methods specified in the Mapping or MutableMapping abstract base classes. Examples include:

  • dict
  • collections.defaultdict
  • collections.OrderedDict
  • collections.Counter.

The class is a mapping if it implements all methods from the Mapping / MutableMapping.

If you will create a Mapping/MutableMapping derived class and implement all of this, you will get a class that is a mapping.

๐ŸŒ
Real Python
realpython.com โ€บ python-map-function
Python's map(): Processing Iterables Without a Loop โ€“ Real Python
July 31, 2023 - You can use any kind of Python callable with map(). The only condition would be that the callable takes an argument and returns a concrete and useful value. For example, you can use classes, instances that implement a special method called __call__(), instance methods, class methods, static methods, and functions.
๐ŸŒ
pytz
pythonhosted.org โ€บ odin โ€บ ref โ€บ mapping โ€บ classes.html
Mapping Classes โ€” Odin 0.6 documentation
A mapping is a utility class that defines how data is mapped between objects, these objects are typically odin.Resource but other Python objects can be supported.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_map.asp
Python map() Function
Python Examples Python Compiler ... Python Certificate Python Training ... The map() function executes a specified function for each item in an iterable....
๐ŸŒ
Real Python
realpython.com โ€บ python-mappings
Python Mappings: A Comprehensive Guide โ€“ Real Python
July 23, 2024 - In this tutorial, you'll learn the basic characteristics and operations of Python mappings. You'll explore the abstract base classes Mapping and MutableMapping and create a custom mapping.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ c-api โ€บ mapping.html
Mapping Protocol โ€” Python 3.14.3 documentation
Return 1 if the object provides the mapping protocol or supports slicing, and 0 otherwise. Note that it returns 1 for Python classes with a __getitem__() method, since in general it is impossible to determine what type of keys the class supports.
Find elsewhere
๐ŸŒ
Zeroc
archive.zeroc.com โ€บ ice โ€บ 3.7 โ€บ language-mappings โ€บ python-mapping โ€บ client-side-slice-to-python-mapping โ€บ python-mapping-for-classes
Python Mapping for Classes - Ice
A Slice class maps to a Python class with the same name. The generated class contains an attribute for each Slice data member (just as for structures and exceptions).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-map-function
Python map() function - GeeksforGeeks
map() function in Python applies a given function to each element of an iterable (list, tuple, set, etc.) and returns a map object (iterator).
Published ย  September 7, 2025
๐ŸŒ
Quora
quora.com โ€บ In-Python-the-map-function-is-actually-an-object-oriented-programming-OOP-class-Is-my-understanding-correct
In Python, the map() function is actually an object-oriented programming (OOP) class. Is my understanding correct? - Quora
Answer (1 of 5): The correct answer is โ€ฆ itโ€™s complicated. [code ]map()[/code] is *implemented* as a class by the python interpreter , but in general use it looks like a function. And, indeed, it is documented as a built-in function in the library reference docs for the python library (see ...
๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ python map() method
Python map() Method - AskPython
January 25, 2026 - # Syntax map(function, iterable1, ... # [1, 4, 9, 16, 25] The python map function applies a transformation to every element in an iterable without writing explicit loops....
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ built-in โ€บ map
Python map() Function
Become a certified Python programmer. Try Programiz PRO! ... The map() function executes a given function to each element of an iterable (such as lists, tuples, etc.).
๐ŸŒ
Readthedocs
odin.readthedocs.io โ€บ en โ€บ latest โ€บ ref โ€บ mapping โ€บ classes.html
Mapping Classes โ€” Odin 2.0 documentation
A mapping is a utility class that defines how data is mapped between objects, these objects are typically odin.Resource but other Python objects can be supported.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ functions.html
Built-in Functions โ€” Python 3.14.3 documentation
Return a mapping object representing the current local symbol table, with variable names as the keys, and their currently bound references as the values. At module scope, as well as when using exec() or eval() with a single namespace, this function returns the same namespace as globals(). At class scope, it returns the namespace that will be passed to the metaclass constructor.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-map-function
Python map() function | DigitalOcean
August 3, 2022 - Python map() function is used to apply a function on all the elements of specified iterable and return map object. Python map object is an iterator, so we can iterate over its elements. We can also convert map object to sequence objects such as list, tuple etc.
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ creating-a-mapping
Creating a mapping - Python Morsels
September 17, 2022 - The abc in collections.abc stands for abstract base classes and that's what Mapping is. And the collections.abc module has quite a few more abstract base classes within it. Abstract base classes are an invention of Python's abc module.
๐ŸŒ
Tutorial Teacher
tutorialsteacher.com โ€บ python โ€บ python-map-function
Python map() Function (With Examples)
In the above example, the map() function applies to each element in the numbers list. This will return an object of the map class, which is an iterator, and so, we can use the next() function to traverse the list.
๐ŸŒ
ZeroC
doc.zeroc.com โ€บ ice โ€บ 3.6 โ€บ language-mappings โ€บ python-mapping โ€บ client-side-slice-to-python-mapping โ€บ python-mapping-for-classes
Python Mapping for Classes - Ice
A Slice class maps to a Python class with the same name. The generated class contains an attribute for each Slice data member (just as for structures and exceptions).