Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

347
Vistas
Why does inspect() think map isn't built in?

The following code returns false

import inspect
print(inspect.isbuiltin(map))

But the map function is listed under "built-in" functions.

Why is it so?

over 4 years ago · Hanz Gallego
1 Respuestas
Responde la pregunta

0

The inspect.isbuiltin will only

Return true if the object is a built-in function or method.

The map builtin is a class, not a function or method:

>>> map
<class 'map'>

In fact, most "built-in functions" that return iterators are implemented as classes; calling them returns optimised instances instead of re-using some generic iterator class.

>>> zip  # zip iterator "function" is also a class
<class 'zip'>
>>> map(str, (1, 2, 34))  # map builds instances of map
<map object at 0x103fa34f0>

In addition, keep in mind that the term "built-in" has two meanings in Python:

  • A compiled object, i.e. built into the interpreter.
  • A member of the builtins module, available in every module.

While most builtins are compiled for speed, this is no necessity.

If you want to check whether a name is part of builtins, do so via the module:

>>> import builtins
>>> hasattr(builtins, "map")
True
>>> hasattr(builtins, "sum")
True
>>> hasattr(builtins, "reduce")
False
over 4 years ago · Hanz Gallego Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda