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
Hashes for speedups-1.2.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2b00c0efba16193b896de7883f4763be2ada4a4b242ae8a50eeeb6d31a3c829 |
|
MD5 | 436dd6fb0c753ec4e90d45ff7e631126 |
|
BLAKE2b-256 | 54d863f923857b6df582c75cdf69bad6fb95b469cc71936825b88604622b4afc |
Hashes for speedups-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3891d448a0e6c17539639f60b9c7e7fdc2ae05c779ce1ca3477e8c9c901ce4c7 |
|
MD5 | 8d26252b168d53adad636d2f3d553e43 |
|
BLAKE2b-256 | 5677a04ae4cd5a131d242dc9cbf13a842c555f7cfb31d7ff2dd60088208a9153 |
Hashes for speedups-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 352193d2fb88fbb91b169f43f39256f9088ab3b04e00dd4e7fddb3bb48b66c75 |
|
MD5 | 67cb4709a1eef9dc0230437b0262f140 |
|
BLAKE2b-256 | b37d28d1c86616c6c9dd56d5920158c02127876443f06a0da24ca3f855eb1707 |
Hashes for speedups-1.2.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dbc05420fc3fc64b5906d7cc6a7bf8aeac6041953133318f5e56db78f333292 |
|
MD5 | 5fbb2151e31eb4c27af3023c9f820012 |
|
BLAKE2b-256 | 832698c3e6e8443ccf083ba31c81613584e5135adcc8d825493cdb61f2a68d64 |
Hashes for speedups-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6c405449051434e810193086240c71cc37a831904cd9c065bf49145ecc1845d |
|
MD5 | cb111e3df871279545d10d827819396a |
|
BLAKE2b-256 | e278c57e452db7370a790adf597389da478edef9ce78bf84a61f4d2fc3e2be49 |
Hashes for speedups-1.2.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 293bc46f6ab538f95444c2bbf8893e0573e959169932cac18fa4e831790ae9b0 |
|
MD5 | cf8ede8ebfac5a5ac2d7717307f11891 |
|
BLAKE2b-256 | ee051d15fdf6fb083cd6ade5d16921165844d9496c31f5a9e9742a04d3580858 |
Hashes for speedups-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6127be1dedc82c163f53d6d53ef45b0bdd6b1092df3c75df9ed61b1d24d1055f |
|
MD5 | 443ea87d61fabf4c1d692ec3f2488211 |
|
BLAKE2b-256 | d16e8c4e175adf71ad88c24a3a6bd2042da5fc870b493338a2f3fce954441aab |
Hashes for speedups-1.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b89a06e62ef11c1eac87321ffdb99c2a2d3e310fc55d0af72a55321bd23394a |
|
MD5 | 607f98a0101dcce46c16a2892f7a1e3d |
|
BLAKE2b-256 | be151eb93368d7330fc8396c8be655c4bdcdf8e8490a40940ccc5d18064a44a4 |
Hashes for speedups-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e519e7b53b8b43a88e76070c1718922838f5397143b62331d9eeeb1456dc1a1 |
|
MD5 | 3d0ceef7abf62c74c184671f7cb2c6a2 |
|
BLAKE2b-256 | 75a54fb243432c8c0a5cb4c6c5d13932271e0c92f73e94f1523998bce435840c |
Hashes for speedups-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7578020006362620249e2cda9705be49c521161f2c5347407f47c63f27d6fb49 |
|
MD5 | d445296d441220328ed845ae78060fe2 |
|
BLAKE2b-256 | 8d5aa7d8337bcc6c14eb17f1c697d78d46dbf43b24f0451562a394024bffa438 |
Hashes for speedups-1.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d84e003dee8c8dedd1fba26b22938fcb9ebc2294253bc76bde9a81da6410ebc1 |
|
MD5 | 3de8bd86c420f3eee6bd9d12de35fa14 |
|
BLAKE2b-256 | 1cd561572b903943e0bbd1d2a29afd50eaf55d419ab8e04ff28620a4154cd784 |
Hashes for speedups-1.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e192bd3b6d3c1e4008ff324cc1a5aa52ec86121e1a73f4495c683ca268c90be8 |
|
MD5 | bc0f51af745d4667ac78ecf6a8cd00cd |
|
BLAKE2b-256 | 532356c60c80a74a7a9e9064ad8be929cf8f61d77eded42bd8ed5c8131f7549e |
Hashes for speedups-1.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90a81f00436ce8ea32b0bfcbdaef74f3391ecd6611a10d1461ccddac828c3aa0 |
|
MD5 | bea5a04c67a72c6732586c2d97a6dba3 |
|
BLAKE2b-256 | 26d2a827a1f484d5477459a69684fb75368f4e52e48d52f0faf519c365f80c9a |
Hashes for speedups-1.2.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b539475b8c4fb94f23d820ae951bef02bb299aa221aca43cc4907668d8053f56 |
|
MD5 | d40199e7299d0e9a66add241fed73be1 |
|
BLAKE2b-256 | 6a77f80d8913cdeb771b6e86d8864d8f2a0971bc1306be1f5d08953f13877e25 |
Hashes for speedups-1.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55e342815108a7ab4b64e9991442e33d9831efbcfe89a7f3ce809f27000e022c |
|
MD5 | 5bce4e9663affb096e82cb4ff901d979 |
|
BLAKE2b-256 | 332ee96fe12992c76068dcf0b2dd929fa090079fd50fd980478270acc0f3b7b2 |
Hashes for speedups-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b862fc06dfc9f4a90066ab8c53f329d9c4178b344d149b5ce273817133e0d423 |
|
MD5 | e5a3b83d966c974c40af7afa1a316a2e |
|
BLAKE2b-256 | 6c526b5be88801623eaa9b18cf443a5491ed8fb84b33bd77da752516e3f2aadb |