Library with some C and Cython code for speeding up common operations. This is externalized to avoid the hassle of building binary wheels in my other projects.
Project description
This library contains a number of functions for speeding up critical parts of your Python code without having to bother with the hassle of building binary extensions. That way you can keep your main packages simple PEP517 based packages and still get the speedups.
Currently only a few functions are available, but several more are planned.
Generic endian conversion functions in speedups.hton:
void pack_int16(char *buf, int16_t x)
void pack_int32(char *buf, int32_t x)
void pack_int64(char *buf, int64_t x)
void pack_float(char *buf, float f)
void pack_double(char *buf, double f)
int16_t unpack_int16(const char *buf)
uint16_t unpack_uint16(const char *buf)
int32_t unpack_int32(const char *buf)
uint32_t unpack_uint32(const char *buf)
int64_t unpack_int64(const char *buf)
uint64_t unpack_uint64(const char *buf)
float unpack_float(const char *buf)
double unpack_double(const char *buf)
These functions are used to convert between native and network byte order and are meant to be used from Cython code. Examples can be found in the speedups.psycopg_array code.
For the psycopg library we have a binary COPY loader to convert a PostgreSQL array to a numpy ndarray. This can be used with the copy() method of a psycopg cursor: https://www.psycopg.org/psycopg3/docs/basic/copy.html
It supports the following PostgreSQL types:
float4 (numpy.float32)
float8 (numpy.float64)
smallint (numpy.int16)
integer (numpy.int32)
bigint (numpy.int64)
Additionally, it supports arrays varying from 1D to N-D so a 2D or 3D array are supported.
cursor: psycopg.Cursor
psycopg_loaders.NumpyLoader.install(cursor)
query = '''
COPY (
SELECT array_agg(x)
FROM generate_series(1, 100000) x
) TO STDOUT WITH BINARY
'''
copy: psycopg.Copy
with cursor.copy(query) as copy:
copy.set_types(['integer[]'])
for row in copy.rows():
print(row)
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
Built Distributions
File details
Details for the file speedups-1.4.0.tar.gz
.
File metadata
- Download URL: speedups-1.4.0.tar.gz
- Upload date:
- Size: 176.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6458a2f732f0487c70a6ffcb3aa7da4ab0b092166585210db5334f83549d5e82 |
|
MD5 | 9416d98abae2e9e0b2ef1cce391d1c42 |
|
BLAKE2b-256 | adbdcc96f153b96f7eb5949720d6ea2a96a04a9c9e0a2ed146959a8e1209d91d |
File details
Details for the file speedups-1.4.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 263.9 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13d70bb49fd3d4785f1fa30d240934d3417808b8da09470cf7a522efefd340df |
|
MD5 | 41604eb87e7f81c9040e4d9df5224f13 |
|
BLAKE2b-256 | 0aa10e1077ea356d7ecbc164962d999b55bdfb1bd1f3ea9dd166585f0cc89363 |
File details
Details for the file speedups-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 787.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01f7da5188f805e8ddd68b49cbed08bc9b38c7919d79ad74c8002d538f1c5c78 |
|
MD5 | d62f31e2a1e7957cbd8c0c24b1a6aec3 |
|
BLAKE2b-256 | 3c0658beba59bbeda0c3250d0adacc4983fb5e82db4eee9ebbf392b582491877 |
File details
Details for the file speedups-1.4.0-cp312-cp312-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 279.4 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45011bda14236e58a43f9143165c74e68d6f46924070c51c47a832cb1c13c3ee |
|
MD5 | d20a42ec7a47e872cf3832a1330547a9 |
|
BLAKE2b-256 | 66072a70c722971901f247f694a285771119d3492f21c22c4b2f53fd6ce7334f |
File details
Details for the file speedups-1.4.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 263.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8db868526434050a8e7adb164d4205dfe5ca3d1600c1674a2565d3b2660d9a0b |
|
MD5 | 9fdc2319a5aa3d392a9870e17bde35c3 |
|
BLAKE2b-256 | e8634f18ae845d8b817b5a8a7c26d8d7a4476b08620ba7b75d227ca47a6ee2b6 |
File details
Details for the file speedups-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 793.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8e4b4695ef085749244ac4cdbcb33679815de9b79ae12945bc5162b78c59bf3 |
|
MD5 | 942c8209d3ebfcc685a40f72f6eba435 |
|
BLAKE2b-256 | 081f2118c484dbaec8db18435ef029d9a4edb324cd43541981ede774bdd5ec17 |
File details
Details for the file speedups-1.4.0-cp311-cp311-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp311-cp311-macosx_12_0_x86_64.whl
- Upload date:
- Size: 274.6 kB
- Tags: CPython 3.11, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98581e3a3216b6425633eb865c200a6376f8f8d56c7ed78ab9ecbf9261db459b |
|
MD5 | 77e451ca785f661e1c6ab1c54df053ac |
|
BLAKE2b-256 | ad5c25a4d6e0e023cf6e82a5f13ecf684f5d2ba94bbfd9784498b2457c65908a |
File details
Details for the file speedups-1.4.0-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 276.4 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac7de083eccaea68a61e9709eef1027daaff1653ce2728040ce027b41dfbc75c |
|
MD5 | 93b0181776f12f7eb0ced8c0d53ebe6d |
|
BLAKE2b-256 | f416bbd1e040e4674d5857fa9d5d569c416ac00bbe6bccf6ae0208733fa73aa0 |
File details
Details for the file speedups-1.4.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 263.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 901e1089db8b6d089dfc12327cbacadfb762277a36e1835e822d3258104f439a |
|
MD5 | 6671885c3bbb11718224d2e285197304 |
|
BLAKE2b-256 | e6a12a1aaec72c41fb18252cec1054398476f2b89befceda54e70ba78baeaf28 |
File details
Details for the file speedups-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 743.7 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f357c74e91922b1430061161aec240a69e3a993ccc51bcc13f584a25d69ca391 |
|
MD5 | 067d1c2e37f8f06242c9bd417d151c1c |
|
BLAKE2b-256 | e1b58a36e8c0b781402792bff3d007354684752bbf79b3923494caa955455623 |
File details
Details for the file speedups-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 276.8 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60be6a2276923bf3390101898a627b2f62410b75b20e053a75f8fb2e7d4c5135 |
|
MD5 | db543e3f8f095dc817a8c2ee8ca06f75 |
|
BLAKE2b-256 | 70f82f555ac47e6958dcf435f78b8cba3f7fd4a021f45c7e7b0fd1bc1ea6f11a |
File details
Details for the file speedups-1.4.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 263.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbc1652d7c9dfd5b358939460feb7c064581cb52421f0e1f77246350f6eca557 |
|
MD5 | ecc478e91af4de2002e84a091dc22d2f |
|
BLAKE2b-256 | 0d472ccd790a6be8ffa1137dee0123257b5998ce092d5ba282db07799002d72d |
File details
Details for the file speedups-1.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 746.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 510f03ea39805afc8f6126e546915dc29e1579e959ed68303af6d110ff3c3244 |
|
MD5 | 034fec68f3223532348af63a9085b790 |
|
BLAKE2b-256 | dcb8be2f5448734f670099ee8ad4401f5b2975608084c8d53a05701cc2b7f3a1 |
File details
Details for the file speedups-1.4.0-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 277.4 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51b1c49baf0626352986a62b974aaaba63a535c4064c161e4f7ad880dff75b61 |
|
MD5 | 7df50957a5ce73bfff176060fb690e12 |
|
BLAKE2b-256 | 1d08cc7039a7567d90554a1018e15994225716f05497a75343ae355afdbcd16b |
File details
Details for the file speedups-1.4.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 263.6 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d66ec97f52456900093a708a0aec838e70c1c9f7975056ced5ceb42ca801e33 |
|
MD5 | 0fa5edf5343ce2ff326222b4e2da9ea1 |
|
BLAKE2b-256 | 3a3d693d319361ee2a644b2abdf5b3e0f5c7e9f57acc0ce21a3af8642f018bfb |
File details
Details for the file speedups-1.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 754.2 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | baea077f04bd61bdf0858fed72d23e01d6b36d8a7f61ad6531a15414a0c0dbf1 |
|
MD5 | 6cfe97195f2a16c0ba2dd3b90f5397bc |
|
BLAKE2b-256 | b8ff4fd6191434df0f203590f2d7539a3f4be763fcbb847ad861f4b2b907df07 |
File details
Details for the file speedups-1.4.0-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: speedups-1.4.0-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 275.7 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25e21c93ce06d1621c0da18155af799b7524e60b9a40423e550c036ba9b27ef6 |
|
MD5 | 629892fb311c8955ae4e5b8d1d2f0e18 |
|
BLAKE2b-256 | c92ec7e1d695f5f24d894c1b49d193789c3211100e7b7c7e898984e3af46ac71 |