Skip to main content

🧠 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

Metadata

Release files for shaaha 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shaaha 2.0.1
File Size Uploaded Provenance Actions
shaaha-2.0.1.tar.gz 42.4 kB Without provenance Details for shaaha-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shaaha 2.0.1
File Interpreter ABI Platform Actions
shaaha-2.0.1-py3-none-any.whl Python 3 none any Details for shaaha-2.0.1-py3-none-any.whl

Total release size: 84.4 kB

Release files / shaaha-2.0.1.tar.gz

Download URL shaaha-2.0.1.tar.gz
Size 42.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4cf66d726baaf6c0d8e853546f0f02132680d9c3339e4635e9d0842e1e934d53
BLAKE2b-256 checksum
How to use checksums
3d36b1869a1ad4481fda5123420a99641e93c500d97cb3aed805c1c47398833f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Release files / shaaha-2.0.1-py3-none-any.whl

Download URL shaaha-2.0.1-py3-none-any.whl
Size 41.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c51f31683ac0a40a0824a12e00ef8ba8542336286ad4e07842668cdc33cab364
BLAKE2b-256 checksum
How to use checksums
e0cc55ef9192117323b8613dd0a7c847fdff5de021cd58bd6d2fea7976265372
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Security for shaaha 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page