halgari/clojure-py — Issue #17: Math and Number implementation
Author: halgari
Created: 2012-01-27 14:49:35+00:00
State: open

Clojure on the JVM has a very complex number system that auto converts between number types. Currently, lang.lispreader.matchNumber just spits out integers and floats. We really should look at a better parsing and in general, number handling.

I'd like to see us use gmp for our number processing. Gmp is the fastest number processing library I've encountered and it has optimizations for SSE. The issue would be when it comes to interfacing with non clojure libs, and with python in general. Let's say we used Integer() from gmp. The following will not work:

```(nth (tuple '(12 3)) (Integer 1))```

This is because tuple expects a int indexer. So perhaps the better way would be to have nth implicitly cast the Integer to a python int.

Or we can simply stick with python ints, and floats, but we give up arbitrary precision, and to be honest, when it comes to speed: gmp Integer > python ints > Java BigInt. At least that's what my benchmarks have shown.