Skip to main content

Intelligent Meta-Dispatcher — AI-powered backend selection, agent execution, and code optimization.

Project description

🧠 Shaaha

One import. Best backend. Always. Now with AI.

PyPI version Python 3.9+ License: MIT Downloads

Shaaha is the world's first Self-Optimizing AI-Driven Python Meta-Dispatcher.

Instead of manually picking numpy, pandas, torch, or sklearn — you write one import and Shaaha silently picks the best available library for your hardware, learns from every run, fixes its own errors, and even rewrites your old code to be faster.


🚀 Install

pip install shaaha                      # zero dependencies
pip install "shaaha[default]"           # + numpy, pandas, pillow, sklearn, matplotlib
pip install "shaaha[science]"           # full scientific stack
pip install "shaaha[gpu]"               # CUDA / GPU stack

⚡ Quick Start

import shaaha

import shaaha.math as sm           # → cupy (GPU) or numpy (CPU)
import shaaha.dataframe as df      # → polars (large) or pandas (small)
import shaaha.ml as ml             # → torch (GPU) or sklearn (CPU)
import shaaha.image as img         # → opencv or pillow
import shaaha.viz as viz           # → plotly or matplotlib

arr = sm.array([1, 2, 3, 4, 5])
sm.sqrt(arr)

model = ml.LinearRegression()
model.fit(X_train, y_train)

🤖 Layer 2 — AI Agent

shaaha.agent("load sales.csv, find the top 10 products, and plot a bar chart")
# Breaks task into steps and executes automatically
# 📄 Report saved: shaaha_report.md

🔁 Layer 3 — Code Rewriter

shaaha.optimize_file("my_old_script.py")
# Finds slow patterns, shows diff, asks before applying
# ⚡ Estimated speedup: up to 100x faster

🧠 Layer 4 — Adaptive Brain

shaaha.status()
# "brain_confidence": "87%"
# "recommendations": ["math: 'numpy' fastest on your machine (4.2ms)"]

shaaha.reset_learning()

🩺 Layer 5 — Self-Healer

When a backend crashes, Shaaha auto-switches and always notifies you:

⚠️  'jax' failed → switched to 'numpy'.
   shaaha.suppress_warnings = True to hide this.

📖 Layer 6 — Explainer

shaaha.explain("my_script.py", output="report.md")
# Explains every library choice in plain English
# Perfect for students and researchers

📊 Layer 7 — Dashboard

shaaha.dashboard()
# 🚀 Opens http://127.0.0.1:7842
# Shows all operations, backends chosen, speed history

🔌 Layer 8 — Plugin System

shaaha.register_backend("dataframe", "vaex", "vaex", priority=88)
shaaha.list_backends("dataframe")

🤝 Layer 9 — Collaboration

shaaha.share_profile("my_profile.json")
shaaha.import_profile("teammate.json")
shaaha.sync("http://team-server:8080")

🛡️ Layer 10 — Safety Guard

shaaha.safe_mode(True)
# ✅ Results match 100%. Safe to switch from 'jax' to 'numpy'.

🗺️ Supported Domains

shaaha.<domain> Best Backend Fallbacks
shaaha.math cupy / jax torch → numpy
shaaha.dataframe polars modin → pandas → dask
shaaha.ml torch xgboost → lightgbm → sklearn
shaaha.image opencv pillow → skimage
shaaha.nlp transformers spacy → nltk
shaaha.viz plotly altair → seaborn → matplotlib
shaaha.stats statsmodels scipy → sklearn
shaaha.http httpx requests → urllib3
shaaha.json orjson ujson → json (stdlib)

🏗️ How It Works

Shaaha uses PEP 302 Import Hooks (sys.meta_path) to intercept Python's import system before it looks for any file. A MetaPathFinder captures every import shaaha.* call, the Router scores available backends by hardware context and learned timing data, and a lazy ProxyModule forwards all attribute access transparently — zero cost until first use.


🎓 MSc Thesis

Shaaha implements three advanced CS concepts:

  1. Python Import Protocol (PEP 302/451) — MetaPathFinder, Loader, ModuleSpec
  2. Proxy + Strategy + Registry Design Patterns
  3. Context-Aware Weighted Dispatch with Adaptive Learning

📄 License

MIT © Shaaha | pypi.org/project/shaaha

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shaaha-2.0.1.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shaaha-2.0.1-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file shaaha-2.0.1.tar.gz.

File metadata

  • Download URL: shaaha-2.0.1.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for shaaha-2.0.1.tar.gz
Algorithm Hash digest
SHA256 4cf66d726baaf6c0d8e853546f0f02132680d9c3339e4635e9d0842e1e934d53
MD5 f1d0b7a98e67d0207ff692f9e4565166
BLAKE2b-256 3d36b1869a1ad4481fda5123420a99641e93c500d97cb3aed805c1c47398833f

See more details on using hashes here.

File details

Details for the file shaaha-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: shaaha-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for shaaha-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c51f31683ac0a40a0824a12e00ef8ba8542336286ad4e07842668cdc33cab364
MD5 b225591da5f1cab3c6c702f7ffee6522
BLAKE2b-256 e0cc55ef9192117323b8613dd0a7c847fdff5de021cd58bd6d2fea7976265372

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page