pydoc > imp

πŸ“› NAME

imp

πŸš€ Quick Reference

Use CaseCommandDescription
Acquire import lockimp.acquire_lock()Acquires the interpreter's import lock for thread safety
Release import lockimp.release_lock()Releases the lock
Check lock statusimp.lock_held()Returns True if lock is held
Find a moduleimp.find_module(name, [path])Search for a module DEPRECATED
Load a moduleimp.load_module(name, file, filename, details)Load a module found by find_module() DEPRECATED
Get .pyc path from .pyimp.cache_from_source(path)Return the .pyc file path DEPRECATED
Get .py path from .pycimp.source_from_cache(path)Return the .py file path DEPRECATED
Get magic numberimp.get_magic()Return magic bytes for .pyc files DEPRECATED
Get suffix listimp.get_suffixes()Return importable module suffixes DEPRECATED
Check built‑in moduleimp.is_builtin(name)Returns True if module is built‑in
Check frozen moduleimp.is_frozen(name)Returns True if module is frozen
Reload a moduleimp.reload(module)Reload an already imported module DEPRECATED

⚠️ This module is deprecated β€” prefer importlib for new code.

πŸ“š Module Reference

https://docs.python.org/3.10/library/imp.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

πŸ“– Description

This module provides the components needed to build your own __import__ function. Undocumented functions are obsolete.

In most cases it is preferred you consider using the importlib module's functionality over this module.

πŸ›οΈ Classes

builtins.object
NullImporter

🧩 class NullImporter(builtins.object)

DEPRECATED β€” Null import object.

Methods defined here:

Data descriptors defined here:

πŸ”§ Functions

πŸ”’ acquire_lock()

Acquires the interpreter's import lock for the current thread.

This lock should be used by import hooks to ensure thread-safety when importing modules. On platforms without threads, this function does nothing.

πŸ“¦ cache_from_source(path, debug_override=None)

DEPRECATED

Given the path to a .py file, return the path to its .pyc file.

The .py file does not need to exist; this simply returns the path to the .pyc file calculated as if the .py file were imported.

If debug_override is not None, then it must be a boolean and is used in place of sys.flags.optimize.

If sys.implementation.cache_tag is None then NotImplementedError is raised.

🧩 create_dynamic(...)

Create an extension module.

πŸ” find_module(name, path=None)

DEPRECATED

Search for a module.

If path is omitted or None, search for a built-in, frozen or special module and continue search in sys.path. The module name cannot contain '.'; to search for a submodule of a package, pass the submodule name and the package's __path__.

❄️ get_frozen_object(name, /)

Create a code object for a frozen module.

✨ get_magic()

DEPRECATED

Return the magic number for .pyc files.

🏷️ get_suffixes()

DEPRECATED

🏷️ get_tag()

Return the magic tag for .pyc files.

πŸ—οΈ init_builtin(name)

DEPRECATED

Load and return a built-in module by name, or None if such module doesn't exist

πŸ₯Ά init_frozen(name, /)

Initializes a frozen module.

πŸ”Ž is_builtin(name, /)

Returns True if the module name corresponds to a built-in module.

❄️ is_frozen(name, /)

Returns True if the module name corresponds to a frozen module.

πŸ“¦ is_frozen_package(name, /)

Returns True if the module name is of a frozen package.

πŸ“₯ load_compiled(name, pathname, file=None)

DEPRECATED

πŸ”Œ load_dynamic(name, path, file=None)

DEPRECATED

Load an extension module.

πŸ“₯ load_module(name, file, filename, details)

DEPRECATED

Load a module, given information returned by find_module().

The module name must include the full package name, if any.

πŸ“¦ load_package(name, path)

DEPRECATED

πŸ“„ load_source(name, pathname, file=None)

πŸ” lock_held()

Return True if the import lock is currently held, else False.

On platforms without threads, return False.

πŸ†• new_module(name)

DEPRECATED

Create a new module.

The module is not entered into sys.modules.

πŸ”“ release_lock()

Release the interpreter's import lock.

On platforms without threads, this function does nothing.

πŸ”„ reload(module)

DEPRECATED

Reload the module and return it.

The module must have been successfully imported before.

πŸ”™ source_from_cache(path)

DEPRECATED

Given the path to a .pyc. file, return the path to its .py file.

The .pyc file does not need to exist; this simply returns the path to the .py file calculated to correspond to the .pyc file. If path does not conform to PEP 3147 format, ValueError will be raised. If sys.implementation.cache_tag is None then NotImplementedError is raised.

πŸ“Š Data

πŸ“ File

/usr/lib/python3.10/imp.py

imp
πŸ“› NAME πŸš€ Quick Reference πŸ“š Module Reference πŸ“– Description πŸ›οΈ Classes
🧩 class NullImporter(builtins.object)
πŸ”§ Functions
πŸ”’ acquire_lock() πŸ“¦ cache_from_source(path, debug_override=None) 🧩 create_dynamic(...) πŸ” find_module(name, path=None) ❄️ get_frozen_object(name, /) ✨ get_magic() 🏷️ get_suffixes() 🏷️ get_tag() πŸ—οΈ init_builtin(name) πŸ₯Ά init_frozen(name, /) πŸ”Ž is_builtin(name, /) ❄️ is_frozen(name, /) πŸ“¦ is_frozen_package(name, /) πŸ“₯ load_compiled(name, pathname, file=None) πŸ”Œ load_dynamic(name, path, file=None) πŸ“₯ load_module(name, file, filename, details) πŸ“¦ load_package(name, path) πŸ“„ load_source(name, pathname, file=None) πŸ” lock_held() πŸ†• new_module(name) πŸ”“ release_lock() πŸ”„ reload(module) πŸ”™ source_from_cache(path)
πŸ“Š Data πŸ“ File

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 18:12 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^