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

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

speedups-1.0.0.tar.gz (138.4 kB view details)

Uploaded Source

Built Distributions

speedups-1.0.0-cp310-cp310-win_amd64.whl (210.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

speedups-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (624.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

speedups-1.0.0-cp310-cp310-macosx_12_0_x86_64.whl (234.6 kB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

speedups-1.0.0-cp310-cp310-macosx_11_0_x86_64.whl (225.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ x86-64

speedups-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl (225.4 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

speedups-1.0.0-cp39-cp39-win_amd64.whl (210.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

speedups-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (624.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

speedups-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl (225.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

speedups-1.0.0-cp39-cp39-macosx_10_9_universal2.whl (331.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

speedups-1.0.0-cp38-cp38-win_amd64.whl (210.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

speedups-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (627.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

speedups-1.0.0-cp38-cp38-macosx_10_9_x86_64.whl (223.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

speedups-1.0.0-cp37-cp37m-win_amd64.whl (209.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

speedups-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (590.4 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

speedups-1.0.0-cp37-cp37m-macosx_12_0_x86_64.whl (241.3 kB view details)

Uploaded CPython 3.7m macOS 12.0+ x86-64

speedups-1.0.0-cp37-cp37m-macosx_10_9_x86_64.whl (223.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

Details for the file speedups-1.0.0.tar.gz.

File metadata

  • Download URL: speedups-1.0.0.tar.gz
  • Upload date:
  • Size: 138.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for speedups-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bc9e9fd82528a798a53741da355dadb344c5909bff899b2367834173773720e0
MD5 2701123a6a2a6762a79ef7f953a89e83
BLAKE2b-256 9a1209dfad67aefeb81290a628020d9ec23e494190d5f05495a30baf9804c526

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speedups-1.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 210.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5a99686f7967133d1707f2394f89a738474a0cdd724807e1df2b077fef1b6dbf
MD5 ff38a111ff570453e5ee8454dd2c0c40
BLAKE2b-256 03c576372e22b772f9e7e9c621ab0d000aeaf0241d526fd529f7f680f36851a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for speedups-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb6272c2bf4144b29484a665644592e3bf1dd709ef143a2d65dbe4ed2f818f9c
MD5 cf149fec7a7dd801990c50299a33dbaa
BLAKE2b-256 4896ac74628f1205c5a77843838707960271976322c1fb73e4973df832fe4e1e

See more details on using hashes here.

File details

Details for the file speedups-1.0.0-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.0.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 3798b76c46d1151369c9c7d21bb390eae80871fc50cf37dedcb3556606c8009f
MD5 a4ae649f509de5e992093a71dfe52213
BLAKE2b-256 6517990fee91c0e4d6c1a7d3ecc820ab75841aa57a316ae4443a617d9087aa2d

See more details on using hashes here.

File details

Details for the file speedups-1.0.0-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: speedups-1.0.0-cp310-cp310-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 225.6 kB
  • Tags: CPython 3.10, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for speedups-1.0.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c64e01c490dd388d33803c333fde20a2ca2c0c0b01a29c1492c8a631f859ea0b
MD5 c5d1ccbab3a49f69b6865a66e5b168c0
BLAKE2b-256 8152cb26335eba5c74586c2711007a73c8bc2b1629818298aef935ab5a0fa094

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speedups-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 225.4 kB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 48e45a283fda2903d7c749f2e11705d38b1807648f7a4b316ec6efc56eb51343
MD5 cf6e3de4a6a34e05854e528d78ab805b
BLAKE2b-256 f2387933c6ff81a326fe3b767a9db5c271e0b7849bc4253a32f59c2fcd3b8ec2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speedups-1.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 210.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7f5e3f3f222262909e0d7cce5667be622dd261421866149fd71a6325dbb9cc70
MD5 258430978f9151876bbb08e2e6f1b82f
BLAKE2b-256 5ce2b6c79aa5cc9c77855f4cacc43aab60b40f36eaccf4af8b544a30b9cf9d5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for speedups-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c8fec2487da7b0a94460561d46ce4328c060a71d7787a498d56e3cd079024c6
MD5 4f014b4f884cf3403e48934ffb48ce02
BLAKE2b-256 677e74284dfa0867062393a5680883f458b1efdfe3dbb4261ddbc0df595dea6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speedups-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 225.4 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c370b348f2f08652cd7b950ca4df0537563a82c15939cd9dc4cf9317b39e8dc9
MD5 4549b9746dfbb744ca419ac0f2164fc7
BLAKE2b-256 83bebbf96658b65660771f237484115de36bce9dde7f91f66fd904b17186d888

See more details on using hashes here.

File details

Details for the file speedups-1.0.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for speedups-1.0.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 22a54d18a42c81da1dd489faf1fe48a21ffc02cde311d403e509c7cca3a4636e
MD5 ab2005592c67bb148dc9017a7371504c
BLAKE2b-256 f3a8ae5a1aa1a668247f28a0fe919b7d208c211fdc5ef5d411ce3f7e5b3e0168

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speedups-1.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 210.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f2ff2034316b57340ee51f08b073a1711a91c61c93636baa2d570fdfd7c98601
MD5 171ab8ab251be351d8150db369746b8c
BLAKE2b-256 2e4223b3a3cbe760c97b535697bc4a3ff9afab901085eaf6ef57eebd647ec3e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for speedups-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4b9c344b2611f9b869d9d1c1588227eeba5543114d522c5c9e2785162d74ceff
MD5 84c239e2f28382cb4b74c861ac420f31
BLAKE2b-256 715e567028da8d8f00ca9d2ee94669e35e112193daa6eaed3eb257844c030a03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speedups-1.0.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 223.1 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 adae3770970c6e96be66c3143fd1ac3b8e44fa0f60afadf1ef9df7b734cc7b5e
MD5 cdbb0322186d9264196a35579fb5325e
BLAKE2b-256 e0a0e56cf5e348489900c7335a727ea204925c3bb0765cf77a36783b761e431b

See more details on using hashes here.

File details

Details for the file speedups-1.0.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: speedups-1.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 209.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5f8896bc754a8914db1f45487f9cc22f3d2dfa1a0b4d74ecd29dc71623c0d0a7
MD5 d866f0e74241ca59f8ca3e7eaae0a86a
BLAKE2b-256 d24effecea5096bcfd5aba8754d7d49e5a6ad78f60074b57aa64ad05a9de6785

See more details on using hashes here.

File details

Details for the file speedups-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86a66490d4d88e0adb4b5b7980b1614e8900bd72c6f150ab06ac53bed62987a8
MD5 6bdf333164a897240b4e29c33a3039b3
BLAKE2b-256 491d34bd3a77ff90f01cc0f620f67305998eba6e3e48312b48be6e2794527b00

See more details on using hashes here.

File details

Details for the file speedups-1.0.0-cp37-cp37m-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for speedups-1.0.0-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 4884dc5e6943b855286d1205f8f5167e9f25a4283c7f69686d3651f0fb47bf46
MD5 05511a11e40f926dfec190098a8f1d18
BLAKE2b-256 0947d38288c2fefe9865c2bdfed039195673216b54722870d06ca1f17ac0ca45

See more details on using hashes here.

File details

Details for the file speedups-1.0.0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: speedups-1.0.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 223.1 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for speedups-1.0.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e5128fd7d5afc49319ea2b6048b6b159252ddb9b38053176cefc33583e0ccc55
MD5 b46c8f2b31320adb1ab0d630b25d1a05
BLAKE2b-256 1ccf14dfa1311962835f04bf92ecd305f9fe093978f5a452f6432dcb09f23e9a

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