Skip to main content

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

https://github.com/wolph/speedups/actions/workflows/build_wheels.yml/badge.svg https://github.com/wolph/speedups/actions/workflows/tox.yml/badge.svg

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

speedups-1.3.2-cp312-cp312-win_amd64.whl (263.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

speedups-1.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (787.5 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

speedups-1.3.2-cp312-cp312-macosx_10_9_x86_64.whl (279.4 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

speedups-1.3.2-cp311-cp311-win_amd64.whl (263.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

speedups-1.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (793.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

speedups-1.3.2-cp311-cp311-macosx_12_0_x86_64.whl (274.6 kB view details)

Uploaded CPython 3.11 macOS 12.0+ x86-64

speedups-1.3.2-cp311-cp311-macosx_10_9_x86_64.whl (276.4 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

speedups-1.3.2-cp310-cp310-win_amd64.whl (263.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

speedups-1.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (743.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

speedups-1.3.2-cp310-cp310-macosx_10_9_x86_64.whl (276.8 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

speedups-1.3.2-cp39-cp39-win_amd64.whl (263.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

speedups-1.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (746.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

speedups-1.3.2-cp39-cp39-macosx_10_9_x86_64.whl (277.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

speedups-1.3.2-cp38-cp38-win_amd64.whl (263.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

speedups-1.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (754.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

speedups-1.3.2-cp38-cp38-macosx_10_9_x86_64.whl (275.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file speedups-1.3.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: speedups-1.3.2-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

Hashes for speedups-1.3.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6ee2dac73ee1144c335ec80a0f9218dcea0f2aae50b9c1c535702bedacbe446b
MD5 014a3cf3bc55904868094db730d64bda
BLAKE2b-256 b9d17096be0824d4f09114321c558935eb15422d955131ce804f6c6840a31c54

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a62c828272d443537601cc5fcab8a99acd68aa33267ff43b23aeb8c3c0aef08
MD5 682cb5f6a0385c25501cc01e271ef947
BLAKE2b-256 3f3db63c8568082e7ff03edd8a3a4cd8e0e4f12f52dc526af01e2818a041db6e

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3be38f0ccbf8b275e8234bb85f6fbc079ac15a547de2c90ea54e32cdf70e13b2
MD5 8b430a538ef6aca605d3827efc544063
BLAKE2b-256 932eab0bc0b339badc4c4c875199867d9b9c72466642fc310c666fd8b392b831

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: speedups-1.3.2-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

Hashes for speedups-1.3.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5592a4116a35fa685aef2098a09b91e0013993874bef68d7eea568933980409c
MD5 9244e58df85523894b6212633eefde17
BLAKE2b-256 557e18377f300f0191288ae683d00c1942ffb1d2d9494066aeb23546cdb2468c

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e43f2d4232c7e4fce7cbbb598799dd398ff58c8c9df3713da23ed23ab891668
MD5 d0069c64a6915d7624a9ef8668558050
BLAKE2b-256 da860e88ded6fd0a279daa447a038573d3c2a657a62ff78aaceb87d63bad3c47

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp311-cp311-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 4b2f75e6d08dc72562483df9bb905b8df554981e5910724e97a2a4cbbe26cd2f
MD5 d6a66d59e803f6ee609ad03dcb0794b8
BLAKE2b-256 36664714366ccab753d9a3959601f980f807f1d68c7ce538418be4de49e532d9

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 10079ab4aee92df45d2a187e701e16e5a48b3747601d6d525e0ab910ea38ba21
MD5 fbfb8c0096e2314601c0f0faa2ccb154
BLAKE2b-256 4197ed9dd2292f839ceb447b13a89862be49da3f5dab09d9936fa5297a272040

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: speedups-1.3.2-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

Hashes for speedups-1.3.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fa57eeb2fd2298b76c7a47a509e7ab5a784a77414956f56826c17f4665a7eddd
MD5 18cc8b7426e1780a9c406a0283e18932
BLAKE2b-256 a0af97a458c97148ec5ebcb410698b268fb419eb3d5c7b7a0505463e0c893d0e

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8fa732f2ca78d85ee7bafd9349cc061da8de2d29964fd1071469f500192ebb34
MD5 1e7b84566032b9f4541dc078a3e654c0
BLAKE2b-256 3e7bc620421c0a262a21b33bb5f8e24e58ec11aef215abc2b177ef051082c1d8

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 555800c62105b045ace0466d7cb38456f4944019f29e161d3c238cdd83d77ae9
MD5 4f6778f2dfcdf8767dbce00215b572a6
BLAKE2b-256 211dfdbd367f7319cced5b0aee06aac00992ae8e4db6f32fed95ac5db84fede9

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: speedups-1.3.2-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

Hashes for speedups-1.3.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6c11eeb82c0165f8e160251cbc644a801f5e50cfd473b0ecdb0ae61aad2bceb1
MD5 52c596e22e496a8148bd982af962a022
BLAKE2b-256 97c5b3a96a42635177d506d4264964e860883afa3e4f69eb0db039d7abf341c3

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84384aaf487a1c5e966785ada1cad79376dc1128b49b392b7906009bf9abd1df
MD5 e9a59677336f44b34d5e1488e978402a
BLAKE2b-256 cecafb435d32a394329cdd71abddefd3a3fd17d07f5448c973e8bc12b70dfd19

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9a0147c1277993f02e1a585b6597eddb2f909b6a8c774f402835bbcb129ae4b4
MD5 702b98e6d5a18a28ebb319115c0dfced
BLAKE2b-256 832cc68cf890f689671b0f31f6c5ea819cc6ef9cbde71bf026a518c5c64b5519

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: speedups-1.3.2-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

Hashes for speedups-1.3.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e86fc61400ad8f7b8fe75acf05f39c4d0cad9a6e2598b1bc0082d6afd37d2014
MD5 119c8a7bed9cce03852e4d6162bc771f
BLAKE2b-256 457bd8f874dd63ea250022b2691b5da6000a72e2a581c873f477b0b9c546cc83

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36f68f17f5b2103d321844998250bc68830d2b7fb7a945bb09195b261d1cf7bf
MD5 6d3fb7658a8371ac4c7491d008353cec
BLAKE2b-256 73ebf6dde75cab9333c8b5d26f2ac5e703239517fa8dc0ad6ae9e66514653899

See more details on using hashes here.

File details

Details for the file speedups-1.3.2-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e896a2015002302a4cb16fa732da13c9802510c37e6b4d96477fc7ff114d44c0
MD5 3d3451274a9fdef1ca83ca73a11edccc
BLAKE2b-256 72b49959f98c07643ccf379ad5807aa868c3765b7130f0ee7dc94160b41b9d32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page