DEV Community

Furkan
Furkan

Posted on

I Built a Pure Python AI Library with Zero External Dependencies – No NumPy, No TensorFlow

Hi everyone,

I wanted to share a project I've been working on for the last 12 days. It's called Cognitive Discovery System (CDS) — a scientific computing library written in pure Python with zero heavy dependencies. No NumPy, no SciPy, no compiled extensions.

Why does this exist?

I'm not trying to compete with NumPy — it can't, and it shouldn't try. The goal was:

  • Readable source you can actually learn from (every algorithm from scratch)
  • Edge runtime — runs anywhere Python runs, no BLAS/C-Fortran toolchain
  • One umbrella for math + physics + stats + ML + signals + quantum, instead of 6+ separate libraries

What's inside (17 modules)

  • Quantum — single & multi-qubit circuits, Bell/GHZ states, entanglement detection
  • Signals — O(N log N) FFT, convolution via Convolution Theorem, power spectrum
  • Optimization — gradient descent, Newton's method, Adam
  • Numerical — O(N³) LU/QR/Cholesky, RK4 ODE solver, Gauss-Legendre quadrature
  • Stats — t-test, chi-square, ANOVA, Pearson, linear regression
  • ML — neural network from scratch (MLP, Adam)
  • NLP — BPE tokenizer, multi-head attention, MiniGPT demo
  • Graphs — Dijkstra, Kruskal MST, topo sort
  • + Monte Carlo, symbolic math, knowledge graph, hypothesis generation

One design choice I'm proud of

The whole library is built around "smarter algorithms, not faster loops." For example:

  • Instead of naive shot-by-shot quantum sampling, I used O(1) probabilistic sampling with explicit state collapse
  • The linear algebra uses partial-pivoting LU (O(N³)) instead of naive determinant expansion (O(N!))
  • FFT uses zero-padded radix-2 (O(N log N)) instead of naive DFT (O(N²))

Engineering

  • 1,244 tests, 100% statement + branch coverage
  • Multi-OS CI matrix, CodeQL, signed PyPI releases (OIDC)
  • mkdocs site, CLI, interactive web dashboard

Install

pip install cognitive-discovery-system
Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/Furox88/cognitive-discovery-system
Docs: https://Furox88.github.io/cognitive-discovery-system/

Feedback wanted

  1. Is the "pure Python, no NumPy" pitch compelling, or does it sound like reinventing the wheel?
  2. The library tries to be a broad umbrella — is that a strength (one package) or a weakness (unfocused)?
  3. Any modules where the from-scratch implementation would be useful for learning?

Not trying to compete with NumPy — genuinely curious whether there's a niche for a readable, dependency-light alternative. Happy to answer questions about any of the implementations.

Top comments (0)