Skip to main content

Partition Like It's 1999

Project description

plinn: Partition Like It's 1999

PyPI version

The partition function

This module implements a function called "partition."

It is an optimized version of the following python function:

def partition(pred, it):
    f = []
    t = []
    for item in it:
        (t if pred(item) else f).append(item)
    return f, t

Benchmarks

Here are some benchmarks on my i7-6600U laptop with python 3.9.0 comparing against several pure-python variants of the same function:

Variant Time for 32 iterations (seconds)
stdlib 3.2970685160253197
mariy 3.5445828151423484
trevor 2.6459597239736468
byers 2.3595181389246136
scara 2.2327406019903720
scara2 2.1951448819600046
plinn 1.5203454510774463

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

plinn-0.0.2.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file plinn-0.0.2.tar.gz.

File metadata

  • Download URL: plinn-0.0.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for plinn-0.0.2.tar.gz
Algorithm Hash digest
SHA256 884cb06592390e27499b16f7a34c90940c43e6a0a3ef92f3ab4074cab5d8bb81
MD5 8b654e24b7bf14e0aaa134c87aa787ea
BLAKE2b-256 4410e690b9a6c1b9ef8f2a3adce9f0bea737d188bc4005949c314cca178d7c42

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