{"id":47793858,"url":"https://github.com/chidcgithub/laziest-import","last_synced_at":"2026-04-06T10:03:11.551Z","repository":{"id":348858940,"uuid":"1200130392","full_name":"ChidcGithub/Laziest-import","owner":"ChidcGithub","description":"A Python library for automatic lazy importing. Import the library once, then use any installed module without explicit import statements.","archived":false,"fork":false,"pushed_at":"2026-04-03T12:25:34.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T12:56:43.625Z","etag":null,"topics":["auto-import","convenience","development","import","lazy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChidcGithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-03T04:20:09.000Z","updated_at":"2026-04-03T12:25:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ChidcGithub/Laziest-import","commit_stats":null,"previous_names":["chidcgithub/laziest-import"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ChidcGithub/Laziest-import","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChidcGithub%2FLaziest-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChidcGithub%2FLaziest-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChidcGithub%2FLaziest-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChidcGithub%2FLaziest-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChidcGithub","download_url":"https://codeload.github.com/ChidcGithub/Laziest-import/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChidcGithub%2FLaziest-import/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31362680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T15:19:21.178Z","status":"ssl_error","status_checked_at":"2026-04-03T15:19:20.670Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto-import","convenience","development","import","lazy"],"created_at":"2026-04-03T16:01:23.888Z","updated_at":"2026-04-06T10:03:11.545Z","avatar_url":"https://github.com/ChidcGithub.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laziest-import\n\n[![PyPI version](https://img.shields.io/pypi/v/laziest-import.svg)](https://pypi.org/project/laziest-import/)\n[![PyPI pre-release](https://img.shields.io/github/release/ChidcGithub/Laziest-import/all.svg?label=pre-release\u0026color=orange)](https://github.com/ChidcGithub/Laziest-import/releases)\n[![Python](https://img.shields.io/pypi/pyversions/laziest-import.svg)](https://pypi.org/project/laziest-import/)\n[![License](https://img.shields.io/pypi/l/laziest-import.svg)](https://opensource.org/licenses/MIT)\n[![Downloads](https://img.shields.io/pypi/dm/laziest-import.svg)](https://pypi.org/project/laziest-import/)\n[![GitHub stars](https://img.shields.io/github/stars/ChidcGithub/Laziest-import.svg?style=social)](https://github.com/ChidcGithub/Laziest-import/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/ChidcGithub/Laziest-import.svg?style=social)](https://github.com/ChidcGithub/Laziest-import/network/members)\n[![GitHub issues](https://img.shields.io/github/issues/ChidcGithub/Laziest-import.svg)](https://github.com/ChidcGithub/Laziest-import/issues)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/ChidcGithub/Laziest-import.svg)](https://github.com/ChidcGithub/Laziest-import/pulls)\n[![GitHub Actions](https://github.com/ChidcGithub/Laziest-import/workflows/Build%20and%20Publish/badge.svg)](https://github.com/ChidcGithub/Laziest-import/actions)\n[![GitHub last commit](https://img.shields.io/github/last-commit/ChidcGithub/Laziest-import.svg)](https://github.com/ChidcGithub/Laziest-import/commits/main)\n[![GitHub repo size](https://img.shields.io/github/repo-size/ChidcGithub/Laziest-import.svg)](https://github.com/ChidcGithub/Laziest-import)\n[![Type hints](https://img.shields.io/badge/type_hints-mypy-blue.svg)](https://mypy-lang.org/)\n[![Code style](https://img.shields.io/badge/code_style-pep8-green.svg)](https://peps.python.org/pep-0008/)\n[![Tests](https://img.shields.io/badge/tests-222_passed-brightgreen.svg)](https://github.com/ChidcGithub/Laziest-import/tree/main/tests)\n\nA zero-configuration lazy import library. Import and use any installed module with a single line.\n\n```python\nfrom laziest_import import *\n\narr = np.array([1, 2, 3])      # numpy\ndf = pd.DataFrame({'a': [1]})  # pandas\nplt.plot([1, 2, 3])            # matplotlib\n```\n\nNo `import numpy as np`, no `import pandas as pd` required.\n\n## Installation\n\n```bash\npip install laziest-import\n```\n\n## Quick Start\n\n\u003cdetails\u003e\n\u003csummary\u003eShow examples\u003c/summary\u003e\n\n**Method 1: Wildcard import (recommended)**\n\n```python\nfrom laziest_import import *\n\n# Common libraries work immediately\narr = np.array([1, 2, 3])           # numpy\ndf = pd.DataFrame({'a': [1, 2]})    # pandas\nplt.plot([1, 2, 3]); plt.show()     # matplotlib\n\n# Standard library\nprint(os.getcwd())                  # os\ndata = json.dumps({'key': 'value'}) # json\n\n# Submodules load automatically\nresult = np.linalg.svd(matrix)      # numpy.linalg\n```\n\n**Method 2: Namespace prefix**\n\n```python\nimport laziest_import as lz\n\narr = lz.np.array([1, 2, 3])\ndf = lz.pd.DataFrame({'a': [1, 2]})\n```\n\n**Method 3: Lazy proxy (with auto-correction)**\n\n```python\nfrom laziest_import import lazy\n\n# Automatic typo correction\narr = lazy.nump.array([1, 2, 3])    # nump -\u003e numpy ✅\ndf = lazy.pnda.DataFrame()          # pnda -\u003e pandas ✅\n\n# Submodule shortcuts\nlayer = lazy.nn.Linear(10, 5)       # nn -\u003e torch.nn ✅\n```\n\n\u003c/details\u003e\n\n## Key Features\n\n| Feature | Description |\n|---------|-------------|\n| **Modular architecture** | Clean 9-module codebase for maintainability |\n| **Lazy loading** | Modules import only on first access, reducing startup overhead |\n| **Submodule support** | `np.linalg.svd()` chains submodules automatically |\n| **Auto-discovery** | Unregistered names search installed modules automatically |\n| **Typo correction** | Misspelling auto-correction (`nump` → `numpy`, `matplotlip` → `matplotlib`) |\n| **Abbreviation expansion** | 300+ abbreviations (`nn` → `torch.nn`, `F` → `torch.nn.functional`) |\n| **Fuzzy matching** | Typo correction via Levenshtein distance algorithm |\n| **Auto-install** | Optional: missing modules can be pip-installed automatically |\n| **Multi-level cache** | Three-tier caching (stdlib/third-party/memory) for fast lookups |\n| **Cache persistence** | Symbol index saved to disk with configurable TTL |\n| **Cache statistics** | Track hits/misses and optimize performance |\n| **Version checking** | Automatic compatibility warnings for aliases/mappings |\n| **1000+ aliases** | Predefined aliases for common packages |\n| **222 tests** | Comprehensive test coverage |\n\n## What's New in v0.0.3\n\n- **Modular Architecture**: Refactored from single 5800-line file to 9 clean modules\n- **Version Compatibility**: Centralized version management with `version.json` and range checking\n- **LazyProxy**: New `lazy` object for automatic typo correction\n- **300+ abbreviations**: Expanded library shortcuts in `mappings/abbreviations.json`\n- **Submodule mappings**: `nn` → `torch.nn`, `optim` → `torch.optim`, etc.\n- **Misspelling correction**: 150+ common typos auto-corrected via fuzzy matching\n- **Folder-based config**: Organize aliases in `~/.laziest_import/aliases/A.json`, `B.json`, etc.\n- **JSON-based mappings**: All mappings stored in `mappings/` directory for easy customization\n- **222 tests**: Comprehensive test coverage with pytest\n\n## Auto-Install\n\nWhen enabled, accessing an uninstalled module triggers automatic installation:\n\n```python\nfrom laziest_import import *\n\n# Enable auto-install with interactive confirmation\nenable_auto_install()\n\n# Use a mirror for faster downloads\nenable_auto_install(index=\"https://pypi.org/simple\")\n\n# Now accessing uninstalled modules prompts for installation\narr = np.array([1, 2, 3])  # If numpy is missing, prompts to install\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eAuto-install API\u003c/summary\u003e\n\n| Function | Description |\n|----------|-------------|\n| `enable_auto_install(interactive=True, index=None)` | Enable auto-install |\n| `disable_auto_install()` | Disable auto-install |\n| `is_auto_install_enabled()` | Check status |\n| `install_package(name)` | Manually install a package |\n| `set_pip_index(url)` | Set mirror URL |\n\n\u003c/details\u003e\n\n## Predefined Aliases\n\n\u003cdetails\u003e\n\u003csummary\u003eShow full list\u003c/summary\u003e\n\n| Category | Aliases |\n|----------|---------|\n| Data Science | `np`, `pd`, `plt`, `sns`, `scipy` |\n| Machine Learning | `torch`, `tf`, `keras`, `sklearn`, `xgboost`, `lightgbm` |\n| Deep Learning | `transformers`, `langchain`, `llama_index` |\n| Web Frameworks | `flask`, `django`, `fastapi`, `starlette` |\n| HTTP Clients | `requests`, `httpx`, `aiohttp` |\n| Databases | `sqlalchemy`, `pymongo`, `redis`, `duckdb` |\n| Cloud Services | `boto3` (AWS), `google.cloud`, `azure` |\n| Image Processing | `cv2`, `PIL.Image`, `skimage` |\n| GUI | `PyQt6`, `tkinter`, `flet`, `nicegui` |\n| DevOps | `docker`, `kubernetes`, `ansible` |\n| NLP | `spacy`, `nltk`, `transformers` |\n| Visualization | `plotly`, `bokeh`, `streamlit`, `gradio` |\n\n\u003c/details\u003e\n\n## Advanced Features\n\n\u003cdetails\u003e\n\u003csummary\u003eFile-based cache\u003c/summary\u003e\n\nCache imported modules for faster subsequent runs:\n\n```python\nimport laziest_import as lz\n\n# View cache status\ninfo = lz.get_file_cache_info()\n# {'cache_size_bytes': 12345, 'cache_size_mb': 0.01, 'max_cache_size_mb': 100, ...}\n\n# Set custom cache directory\nlz.set_cache_dir('./my_cache')\n\n# Clear cache\nlz.clear_file_cache()\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCache configuration\u003c/summary\u003e\n\n```python\nimport laziest_import as lz\n\n# Get cache version\nversion = lz.get_cache_version()  # '0.0.2.3'\n\n# Configure cache settings\nlz.set_cache_config(\n    symbol_index_ttl=3600,       # Symbol index TTL: 1 hour\n    stdlib_cache_ttl=2592000,    # Stdlib cache TTL: 30 days\n    max_cache_size_mb=200        # Max cache size: 200 MB\n)\n\n# Get cache statistics\nstats = lz.get_cache_stats()\n# {'symbol_hits': 10, 'symbol_misses': 2, 'module_hits': 5, \n#  'module_misses': 1, 'hit_rate': 0.875, ...}\n\n# Reset statistics\nlz.reset_cache_stats()\n\n# Invalidate cache for a specific package (after upgrade)\nlz.invalidate_package_cache('numpy')\n\n# Rebuild symbol index\nlz.rebuild_symbol_index()\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eDebug and statistics\u003c/summary\u003e\n\n```python\nimport laziest_import as lz\n\n# Enable debug mode\nlz.enable_debug_mode()\n\n# Get import statistics\nstats = lz.get_import_stats()\n# {'total_imports': 3, 'total_time': 0.15, 'module_times': {...}}\n\n# Reset statistics\nlz.reset_import_stats()\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eImport hooks\u003c/summary\u003e\n\n```python\nimport laziest_import as lz\n\ndef before_import(module_name):\n    print(f\"About to import: {module_name}\")\n\ndef after_import(module_name, module):\n    print(f\"Imported: {module_name}\")\n\nlz.add_pre_import_hook(before_import)\nlz.add_post_import_hook(after_import)\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAsync import\u003c/summary\u003e\n\n```python\nimport laziest_import as lz\nimport asyncio\n\nasync def main():\n    # Import multiple modules in parallel\n    modules = await lz.import_multiple_async(['numpy', 'pandas', 'torch'])\n    np, pd = modules['numpy'], modules['pandas']\n\nasyncio.run(main())\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCustom aliases\u003c/summary\u003e\n\n```python\nfrom laziest_import import *\n\n# Register a single alias\nregister_alias(\"mylib\", \"my_awesome_library\")\n\n# Register multiple aliases\nregister_aliases({\n    \"api\": \"my_api_client\",\n    \"db\": \"my_database_lib\",\n})\n```\n\n\u003c/details\u003e\n\n## API Reference\n\n\u003cdetails\u003e\n\u003csummary\u003eShow full API\u003c/summary\u003e\n\n### Alias Management\n\n| Function | Description |\n|----------|-------------|\n| `register_alias(alias, module_name)` | Register an alias |\n| `register_aliases(dict)` | Register multiple aliases |\n| `unregister_alias(alias)` | Remove an alias |\n| `list_loaded()` | List loaded modules |\n| `list_available()` | List all available aliases |\n| `get_module(alias)` | Get module object |\n| `clear_cache()` | Clear cache |\n\n### Auto-Search\n\n| Function | Description |\n|----------|-------------|\n| `enable_auto_search()` | Enable auto-discovery |\n| `disable_auto_search()` | Disable auto-discovery |\n| `search_module(name)` | Search for a module |\n| `search_class(class_name)` | Search by class name |\n| `rebuild_module_cache()` | Rebuild cache |\n\n### Symbol Search\n\n| Function | Description |\n|----------|-------------|\n| `enable_symbol_search()` | Enable symbol search |\n| `search_symbol(name)` | Search for classes/functions |\n| `rebuild_symbol_index()` | Rebuild index |\n\n### Auto-Install\n\n| Function | Description |\n|----------|-------------|\n| `enable_auto_install()` | Enable auto-install |\n| `disable_auto_install()` | Disable auto-install |\n| `install_package(name)` | Install manually |\n| `set_pip_index(url)` | Set mirror URL |\n\n### Other\n\n| Function | Description |\n|----------|-------------|\n| `get_version(alias)` | Get module version |\n| `reload_module(alias)` | Reload a module |\n| `enable_retry()` | Enable retry mechanism |\n| `enable_file_cache()` | Enable file cache |\n\n### Cache Management\n\n| Function | Description |\n|----------|-------------|\n| `get_cache_version()` | Get cache version |\n| `set_cache_config(...)` | Configure cache settings |\n| `get_cache_config()` | Get cache configuration |\n| `get_cache_stats()` | Get cache statistics |\n| `reset_cache_stats()` | Reset cache statistics |\n| `invalidate_package_cache(pkg)` | Invalidate package cache |\n| `get_file_cache_info()` | Get file cache info |\n| `clear_file_cache()` | Clear file cache |\n| `set_cache_dir(path)` | Set cache directory |\n\n\u003c/details\u003e\n\n## Configuration\n\nCustom aliases can be configured in:\n\n1. `~/.laziest_import/aliases/A.json`, `B.json`, ... (user global, letter-based)\n2. `./.laziest_import/A.json`, `B.json`, ... (project level)\n\n```json\n// ~/.laziest_import/aliases/M.json\n{\n    \"mylib\": \"my_awesome_library\",\n    \"mpl\": \"matplotlib\"\n}\n```\n\nLetter-based files load faster - only the relevant file is loaded on demand.\n\n### JSON Mappings\n\nAll mappings are stored in `laziest_import/mappings/` directory:\n\n| File | Description |\n|------|-------------|\n| `abbreviations.json` | Module abbreviations (`np` → `numpy`) |\n| `misspellings.json` | Common misspellings (`numpi` → `numpy`) |\n| `submodules.json` | Submodule shortcuts (`nn` → `torch.nn`) |\n| `package_rename.json` | Package rename mappings (`sklearn` → `scikit-learn`) |\n| `symbol_misspellings.json` | Symbol misspellings (`dataframe` → `DataFrame`) |\n| `priorities.json` | Module priorities for conflict resolution |\n\n### Version Management\n\nVersion compatibility is managed centrally in `version.json`:\n\n```json\n{\n    \"_current_version\": \"0.0.3.1\",\n    \"_cache_version\": \"0.0.3.1\",\n    \"aliases\": {\n        \"_min_version\": \"0.0.3\",\n        \"_max_version\": \"0.0.4\"\n    },\n    \"mappings\": {\n        \"_min_version\": \"0.0.3\",\n        \"_max_version\": \"0.0.4\"\n    }\n}\n```\n\nIf the current version is outside the specified range, a warning is issued:\n\n```\nUserWarning: [laziest-import] aliases: Version 0.0.4 is at or above maximum 0.0.4. \nSome alias features may not work correctly.\n```\n\n## How It Works\n\n1. **Proxy objects**: Each alias maps to a `LazyModule` proxy\n2. **On-demand import**: Real import triggers on first attribute access via `__getattr__`\n3. **Caching**: Imported modules cache within the proxy object\n4. **Chain proxies**: `LazySubmodule` handles recursive lazy loading\n5. **Fuzzy search**: Levenshtein distance algorithm for fault-tolerant matching\n\n### Multi-Level Cache Architecture\n\nThe library uses a three-tier caching system for optimal performance:\n\n| Cache Level | Description | Default TTL |\n|-------------|-------------|-------------|\n| **Stdlib cache** | Standard library symbols | 7 days |\n| **Third-party cache** | Installed package symbols | 24 hours |\n| **Memory cache** | Hot cache for current session | Session |\n\nCache files are stored in `~/.laziest_import/cache/` and automatically:\n- Expire based on TTL settings\n- Clean up when exceeding size limit (default: 100 MB)\n- Invalidate on Python version changes\n\n## Requirements\n\n- Python 3.8+\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchidcgithub%2Flaziest-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchidcgithub%2Flaziest-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchidcgithub%2Flaziest-import/lists"}