Spatium: a fast spatial math library
Project description
🚀Spatium: a fast python spatial math library
⚙️Main features
- Fast Pure Cython Implementation
- ~20x speedup from pure python(3.12) impl on average
- Based on custom code generation
- Almost all static dispatch
- Spatial Math
- Vector
- Operators +, -, *, /, @(dot), ^(cross), |(distance) ...
- Fast (compile time) swizzling (e.g.
Vec3(1, 2, 3).zxy
) - Flexible constructor (e.g.
Vec3(Vec2(1, 2), 3)
) - Iterating and unpacking (e.g.
x, y, z = Vec3(1, 2, 3)
) - Works with other libraries (pygame, numpy, ...)
- Transform
- Vector
- All floats are double-precision
- Full pythonic interface & GLSL-like API
- Stubs for better IDE support
Please refer to the wiki for more details
📈Benchmark
🔧Implementation details
- Codegen!
Custom code generation is used throughout this library.
Every swizzle pattern and constructor are implemented as individual methods and properties (For performance reasons).
As a result, code generation is required so that I don't have to maintain 50,000+ lines of code by hand...
Besides, it also handles vector classes of every dimension and type (e.g. Vec2 Vec3 Vec2i Vec3i) are generated from the same template, so a lot of repetitive code is avoided.
There's also a stub generator.
Credits
- This library is partially inspired by Godot's math library.
Notes
- This library was originally named GdMath, as I originally used this to bridge Python and Godot and focus on gamedev.
As development went on, I realized that it has become a versatile spatial math library which is also one of the fastest, I also found it useful in many projects.
Thus, I've decided to rename it to Spatium (since Spatial was taken), before it (possibly) gets used by more people.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spatium-1.5.4.tar.gz
(129.5 kB
view hashes)
Built Distributions
spatium-1.5.4-cp312-cp312-win32.whl
(440.2 kB
view hashes)
spatium-1.5.4-cp311-cp311-win32.whl
(436.1 kB
view hashes)
spatium-1.5.4-cp310-cp310-win32.whl
(436.4 kB
view hashes)
spatium-1.5.4-cp39-cp39-win32.whl
(437.4 kB
view hashes)
Close
Hashes for spatium-1.5.4-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3348344673877489ed3e468ce1605efeaae888139dd667ec1a994eb8cbe05704 |
|
MD5 | 76b0fcbe8d51ba1f312d08dde8d27fbe |
|
BLAKE2b-256 | cff6d7cb3d04fac33283b1a4ef250636d97477cbfac6abe0634d124f924b863c |
Close
Hashes for spatium-1.5.4-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4f9eeec1f0a150f2e218de812a85ef062ad8c809f3887b350b07e22e3d27f3b |
|
MD5 | 89cac0532b703ff77c7a4ffba83e971a |
|
BLAKE2b-256 | 68e4a021d1959423c84eb384283f9e9ba3880a4009b085506a41a11fc748c1b2 |
Close
Hashes for spatium-1.5.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe8abe9863b4558bf99939acde4f66edb2440bd6324fdae18aefbaa878832ab0 |
|
MD5 | 63775be649b8842e5beac33e2019647b |
|
BLAKE2b-256 | de7f4e94c32f00be228a2a194e5cd65157e75b41d9ef681d2320026f8226fddc |
Close
Hashes for spatium-1.5.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 032cfa740a8a4d2480cf328c61852d70e82b2875bf9c2b5472554df4ddfb8f25 |
|
MD5 | d2e52a5b61037da4f90bbb78f56f4f0b |
|
BLAKE2b-256 | d33da5bd92b3e9071b8da6db1308853d5a374a0dad2670d1e1452b1911e856dc |
Close
Hashes for spatium-1.5.4-pp310-pypy310_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57aa955384ee961bfc9e1c52403ae243a187631e327e5f7e50aeb5bc3bf94e7f |
|
MD5 | 1e7cff9de72943c9530a161cb30b4b21 |
|
BLAKE2b-256 | 8beb5cfb7beaae5c79f525867d5f3ef03dfc4778440ca84605df7249779a75e2 |
Close
Hashes for spatium-1.5.4-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c939f8373c3d43cca1d3833d0de0f0c91a72a7a2c19f8a6a77be7afd94e9554f |
|
MD5 | 80a23e83df37b2820cb3fe40935a3a44 |
|
BLAKE2b-256 | 3098d8473c0d5b897b80b5e4ca135543c430a38c409b76fac3d7da25ccb0417d |
Close
Hashes for spatium-1.5.4-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38257745e3b7a4037eccc21f17a1c06a234d64ac4d0d45cf3bf15c46b3056401 |
|
MD5 | 82fb5eded6757c11c0c1e217a6f871e1 |
|
BLAKE2b-256 | 027559ba16678121c2dfce2456b0a25766ebe4e60c8e20ec0df645c6645efffa |
Close
Hashes for spatium-1.5.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 086e1a86c05df7b37ab6580fee72a3c9a71b4de0b2c77f4fbddafde48ac7778b |
|
MD5 | aaa7451a533808da4b12c6e7e52c3870 |
|
BLAKE2b-256 | 1dbda9cf54689d86d57863031b317a925191ee4bee1d281fa21cfabdbfd75a97 |
Close
Hashes for spatium-1.5.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ceb708e25cf00a1968429ab206a813af030227931107571321df32135c4b7e4 |
|
MD5 | 01d74432ccaab191cfd4222dc498ac47 |
|
BLAKE2b-256 | 1e60a0e99c893b9e4abea1e754f359214614e8f0520aa951553f64aa3c01ed9d |
Close
Hashes for spatium-1.5.4-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 526165c65bf3a5522b12ac5e1b5b9aee59c0e9c47fc4dcab089a9a08cc4e9396 |
|
MD5 | 0f3a8b651e79c9dbe76b69e9da7f85ee |
|
BLAKE2b-256 | d907df7a4cc87497870574cbd017dd02196654ebafea278e075c3f39902e0aa4 |
Close
Hashes for spatium-1.5.4-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c6043518fdab93da59c3b035c06be718d84d525fd075aade12f269f135e3094 |
|
MD5 | 8ff7112b89974d71560640a05b64c7fa |
|
BLAKE2b-256 | 7b8cea8dc2b623e198f0c9760eb09c80ada1d5dbd87a9ec27acefb4c73d62082 |
Close
Hashes for spatium-1.5.4-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2557023838cb88afcc823febef2f00c3b8c5991a8fcbcb0a0ab3054380a6aa7 |
|
MD5 | 58eb7e3181141f4a3fc80d8986e4f53b |
|
BLAKE2b-256 | 3dbbd8e464d74031c28393c5e0a54fc6c7813a26b283f9d98d4f9e325b5b3bd0 |
Close
Hashes for spatium-1.5.4-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 428b99d1694d07f0a4568aeda0f86e4d768be2117fce6f457c68e88761ee96c3 |
|
MD5 | ebc00acb8d572c4257bd190dce56c758 |
|
BLAKE2b-256 | d2ea220f5da8db6be6882c5133cfce46bd395e7cdcbb6606aee7ca74a10b7ef9 |
Close
Hashes for spatium-1.5.4-cp312-cp312-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe79029119bbcfd20b9dc4332a981444dc17952ea8857b875a153aa9db8fefc9 |
|
MD5 | 2f4598a54b62e0685eb2714c2ceaf88e |
|
BLAKE2b-256 | 140fa6774bc632442f1f60d136a2977ea6924567c572958081d5d9491c6d73df |
Close
Hashes for spatium-1.5.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1691dcde71a55c12af8d09651b101ecb75bbbe72b11faebe0a96ee9fd83121d |
|
MD5 | 5f4a64f9c0df899cae3f683b5b24e030 |
|
BLAKE2b-256 | 0da6d5a9069aeffbca4d97f49da80b7b1c2cc81920fd8d2e971151cce7cfc955 |
Close
Hashes for spatium-1.5.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40c6bf3ebeff7325264333a0578860398fbd2705edf4d43495a532abd7cd9505 |
|
MD5 | 755fa06aa150c273ae6ad837ebc7e0c3 |
|
BLAKE2b-256 | bf1418f5f33f2d61739335e72870a8293d784af8b89fc322b642268a1e7d605f |
Close
Hashes for spatium-1.5.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 767e05812d100acf0a8f39456ac9edf0c563465d44f68a8ff9c81e9876faae3d |
|
MD5 | 54a7699f3d56ee590bd1286344acc67e |
|
BLAKE2b-256 | f7733f8f15eb0c2f63216548b9ba5486d006269ac7598a11624482dc8eb38dc7 |
Close
Hashes for spatium-1.5.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f1ae88bcaf116539ff2ac8da66735a9be4750d663335c0bcecef8590b786236 |
|
MD5 | 40b348edb67e1d1a2376edadbf5aae58 |
|
BLAKE2b-256 | 3e47a7a3cb667baeca4ec8d20c111f5b991fdbae1bb2348ad06eae291a8e00b9 |
Close
Hashes for spatium-1.5.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1126c73eb4dab5ce4a51cdefed9947ac9b71065e8eb8357e79fff7a9ea800d8 |
|
MD5 | 70731da7bbdf637229ccefb53a3c1540 |
|
BLAKE2b-256 | 8daffc580c4a43840e9ef87edcf0f9f4cd91981b1bd051d6561ec71e81e8d05c |
Close
Hashes for spatium-1.5.4-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd6b78def7d2e55a77c30adef481d04fe8390217d29be896c9b8971b31544f0d |
|
MD5 | eb064099d04dc60f917221efdec23a3a |
|
BLAKE2b-256 | 56130d2cf663a4f321470d93f4a6514b3b8a56f8cb6bab5fff69f5af998ac24e |
Close
Hashes for spatium-1.5.4-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc82fd0a98563b943cda645e9623693ec9e41d534bcd605b1af0064708c36191 |
|
MD5 | 058d8ed5bf6efa58667fc5f796445e48 |
|
BLAKE2b-256 | 4d397c9755f2ee2daf764dc302865d160cc8709678d5b9a4c468a3a51d437093 |
Close
Hashes for spatium-1.5.4-cp311-cp311-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8467546ca46453bacd3127031b4bdaa40deac5b4f1030925cd01f9c057fb7b2 |
|
MD5 | 892db54985c835a85ee12685d86598a4 |
|
BLAKE2b-256 | 6628222097f00657ea2385e17ca1d4344de76d6743b8ffa50b7bb0f190ce73bd |
Close
Hashes for spatium-1.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a61c20496ef2e6f9597887847c6ef081012d5613f644869125cacb11d58f8a31 |
|
MD5 | 50b52241c284dcdb65a13093ee723528 |
|
BLAKE2b-256 | 2a673003f5d74e432158668c8cf0c84b4584d0707205c348927f00474b4e291d |
Close
Hashes for spatium-1.5.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03306200ae96d0946955bf7290a1b371872b7dea9c5431203ec4c541d3e23d10 |
|
MD5 | 2f5066d32988f14f8ae76acfe287a97a |
|
BLAKE2b-256 | d419c8d99a00f55ca6dc4816eb7cc75d30b97c0cfb7ef9e3a9da8e15c0f29111 |
Close
Hashes for spatium-1.5.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fb24e9bc8d1ae7808b27dfdc22c34564bff485e043c223e2255379fbda2fa55 |
|
MD5 | 56b8ca59a11f67e31b2e122e261f79db |
|
BLAKE2b-256 | 46e37e18e30458a8e10bf0cc22a78b4dc05b8ea4a38e0045a4316f42d20b1371 |
Close
Hashes for spatium-1.5.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91e1f0814aec263a883bf6261df00ff82a39bc0d773ffeedfbd5f1abf166739d |
|
MD5 | 10a614bd9043434efe01ec73b53a1d1b |
|
BLAKE2b-256 | cfb065a7f5dfa0d627fbfed349c458ef694d09ae81ed63940a849e8d21db8dd0 |
Close
Hashes for spatium-1.5.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e5a072966ee22e3009983baf2a390502e10c09f88b3387a6080111816648de8 |
|
MD5 | 7693452cbe405886d09ffbc94e350627 |
|
BLAKE2b-256 | f966822468cb89f42ad06f72c9ac7c1195d0fa94e92c255f421a62af726b91b7 |
Close
Hashes for spatium-1.5.4-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffb4c693c977867e25758f346bdbe7db0ab87a521688d03399e37bc5faaec6fe |
|
MD5 | eba06691d9e2a50cabb8ea063406aef3 |
|
BLAKE2b-256 | ad06ee860c8cd4e235df284ad253f7620692734313dbacc69d5455a44ff9dc9a |
Close
Hashes for spatium-1.5.4-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 979b1255683fad39b97ff8b13cb420c4c0be542b183731431133bdebdb7182b1 |
|
MD5 | 428303e0e2639da86423529087ca1c28 |
|
BLAKE2b-256 | 0d6bd96bcdbd3edbaf60673985c47a82a58d92bc122483325a87d2fc1a2d69f6 |
Close
Hashes for spatium-1.5.4-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94dbba664abad6697fb27331ed548c616c401da5af7600a17a6b98935d3b2e67 |
|
MD5 | e3fb3f9ccf3cfd36e384733c475dd16a |
|
BLAKE2b-256 | 197dd656c74d3dd001b0007875446da128666928e5f5cd3fd36931ec371bd7bc |
Close
Hashes for spatium-1.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87ce7eee95af3389d0adf1e9bb394d902f976e3e9a681a6e06070b491f740d35 |
|
MD5 | c0e28a78e96a0d2f55932b2e137e6a41 |
|
BLAKE2b-256 | f2a094f906be98a31f20e21ed6b45bc2783bb84f689f8b0d7c128e3e75729722 |
Close
Hashes for spatium-1.5.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaf5cbf301de8b0c188db33dc364cf08ba0d3c7056c28bc5d699b8612e81c8f2 |
|
MD5 | cc9df29859f2509c5dba40246f8046de |
|
BLAKE2b-256 | 0987caff8d0082a76043fe284c23e6e8c51eee9368dd40324b03b5e68874ecd3 |
Close
Hashes for spatium-1.5.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b63fec2ddf27405ed31db059e10842b42f11cee40a3837d358534bf02dab99a |
|
MD5 | ea5c04ebb2f095e08eaa181b49b0f8fe |
|
BLAKE2b-256 | 2ff4830e6d4b9dcdae097a2e3efa6c6714941ecf94b9629d953306183628d9f2 |
Close
Hashes for spatium-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f73ec81cdf4cc18611a38c6ce652563da83173538337e4fc0eae9b3eacbaa5c6 |
|
MD5 | 05e8b2991f9a3ba60f8f894555b4bb24 |
|
BLAKE2b-256 | 31341ec6434064ec78c40d8bf471fbc1bbc034c30313712c5fa67b1390597cd7 |
Close
Hashes for spatium-1.5.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2066f7435312963ba38bd8bed4959f2e1de911e86b289f89f35ea52622a2ecf8 |
|
MD5 | ad0f4192a35b0c4ef5a3a5aa75b3eec9 |
|
BLAKE2b-256 | a94f5b994d8a217db49a60e043f77fe04db9f5696c4750f6aa021f950ddb4e17 |
Close
Hashes for spatium-1.5.4-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d81c2cde490e907eb193e6b31f55e101cedb6a77ded90707eef1dbf5b88b5bc0 |
|
MD5 | e03893231d735fe3ba9095e17b6c0d58 |
|
BLAKE2b-256 | 3ab4a77bc2ca914a34729b5d9939e2994c89f8e536d9e0c5f88f3a5de5af2d74 |
Close
Hashes for spatium-1.5.4-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db390bcdddc39f3594876ec1f336c8f714ffdf341ae465d523a8adda89ad8164 |
|
MD5 | 6889e39c7a6e4cc8a3962b5c4a6b0ca8 |
|
BLAKE2b-256 | 633dc55d29d7f6c79f5f370e0365873124f1f58b8c9f5c10a55b6a03c53c1941 |
Close
Hashes for spatium-1.5.4-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 293c6a999f0014d1aba42109cc442c7ba875741137a42c5b13a1d1dc4e7851dc |
|
MD5 | 6e906e8ce03f669edc4a3bb38aa844cd |
|
BLAKE2b-256 | 7047cb5265fe9a149bf6e0ddc8a6017029fd1b78aa4e23e8ff3afc64ecc7a8f7 |
Close
Hashes for spatium-1.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96db5b27b57c876ecf473744fa573d614009b598f2b085090b31df511beef254 |
|
MD5 | a669030f05363a8408093d565ca2f984 |
|
BLAKE2b-256 | b9b613c330d9380e6c128b661ef86f022d72cb58e60f40c379eff074235d5e9e |
Close
Hashes for spatium-1.5.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf09c2ef7148a7ebd6ae9e7b0f0f7e3ebb156fc0393f0ad23a15c85804f393e0 |
|
MD5 | 71754d7a56415d746fa09ce66a390ca8 |
|
BLAKE2b-256 | c49f2d939458f14be1387605a835ed3edf8e13b2c671df28812224b85c4d3f9a |
Close
Hashes for spatium-1.5.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ecfd2dbf6d4165f3b142c6f70e1cc05d1f7438236f605505a016fd89be71280 |
|
MD5 | 53068157de8aa4274892168b1769044f |
|
BLAKE2b-256 | ab3dcb689af2fea9147ee94dff8445b127a2498fcf692b0ec191ecede3f2f1f0 |
Close
Hashes for spatium-1.5.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b936bb5a66170d1b79d7e5b9517fbcd4eb919912842db5591491bddbd3b02cc |
|
MD5 | c0adb150b491a6eac8f57c79b9876555 |
|
BLAKE2b-256 | 964dbbc302f7263884c242a0930e4d336af8a58afeb88e5125b290e4222f4766 |