Skip to main content

Simple C++ ::std::this_thread::yield() call for Python, when sleep() calls have unknown effects.

Project description

pyyield: For when you don't know what time.sleep() does.

Keeping it at simple as possible, pyyield is a simple Python module build from C++ and executes 1 line of code:

::std::this_thread::yield()

The only reason for creating this was due to the inconsistencies when using time.sleep(), which until recently was not very well documented to how it's supposed to work when using with 0 or a small float, where some implementations don't seem to do anything on 0 and other implementations round up very small floats.

That is not to say the C++ yield is always the same either, but for that, read more

Usage:

Example usage, yield from a loop

from pyyield import pyyield

def workerLoop():
    while performSomeWork():
        pyyield()

Build and install from source:

pip install -r requirements.txt
python -m build -o ./dist
pip install ./dist/pyyield*.whl

Tests

pip install pytest        
pytest --verbose --log-cli-level=DEBUG

The tests are mainly there to make an extremely simple check of performance differences. Please change the tests and play around with it yourself to understand how it performs on the system you want to run it on!

For example, as of writing this, in GitHub Actions, ubuntu-latest, pyyield does not perform any better than sleep(0) on all python versions tested, printing the info:

Failed to at speed test: pyyield is not faster than sleep(0)!

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

pyyield-0.1.0.tar.gz (40.7 kB view details)

Uploaded Source

Built Distributions

pyyield-0.1.0-cp312-cp312-win_amd64.whl (31.8 kB view details)

Uploaded CPython 3.12 Windows x86-64

pyyield-0.1.0-cp312-cp312-manylinux2014_x86_64.whl (44.9 kB view details)

Uploaded CPython 3.12

pyyield-0.1.0-cp312-cp312-macosx_10_9_universal2.whl (31.1 kB view details)

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

pyyield-0.1.0-cp311-cp311-win_amd64.whl (31.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

pyyield-0.1.0-cp311-cp311-manylinux2014_x86_64.whl (44.9 kB view details)

Uploaded CPython 3.11

pyyield-0.1.0-cp311-cp311-macosx_10_9_universal2.whl (31.1 kB view details)

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

pyyield-0.1.0-cp310-cp310-win_amd64.whl (31.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

pyyield-0.1.0-cp310-cp310-manylinux2014_x86_64.whl (44.9 kB view details)

Uploaded CPython 3.10

pyyield-0.1.0-cp310-cp310-macosx_10_9_universal2.whl (31.1 kB view details)

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

pyyield-0.1.0-cp39-cp39-win_amd64.whl (31.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

pyyield-0.1.0-cp39-cp39-manylinux2014_x86_64.whl (44.7 kB view details)

Uploaded CPython 3.9

pyyield-0.1.0-cp39-cp39-macosx_10_9_universal2.whl (31.1 kB view details)

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

File details

Details for the file pyyield-0.1.0.tar.gz.

File metadata

  • Download URL: pyyield-0.1.0.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for pyyield-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99e71f362ec4dd44e0ccef53ddaf20367dc3df111e275d9e5888f840e87ba6de
MD5 bc81fa4d3e9a645ee11e07fc73a0293d
BLAKE2b-256 caf1f3406184498a82b656804a0be732c6618be1ea257251621781b23d9bc356

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyyield-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for pyyield-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6674fa10661afd57096a5c246b700b4d988f587a85bdda9d15dfbc2ecf4cbc91
MD5 98acf64a4efa67d230eba69992ca189e
BLAKE2b-256 622a08b5de58fe61448f576ba519ae1ed5fff7f0c8077a5dd37599529923a993

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26b459176970a392ede554b4da81e0567edb407fde3fda564920aede637f09f9
MD5 e002962101b86b4b843b1d3a84a9c566
BLAKE2b-256 2fe94e5644155f195318f654943045b1ac110b88f8037f187aa35ab192d58640

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp312-cp312-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp312-cp312-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 26a40a7afd32ecd914d4c1f56aaae0c7a83202ca83c94a41e084998d2113b81f
MD5 37b80604f58e8ae8342d801442f0e622
BLAKE2b-256 d7f24029883702dc4c24190440222edd57e421e5ae4235f9c198d6e66137804f

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyyield-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for pyyield-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 81255c87a2c48348288cca4b761dd96e5be494c2b802207ef91d7dc31cb7890c
MD5 bc2286fb93c5a5fb32df417e7f428a9f
BLAKE2b-256 be38e6d85c5292633e68ed7017dc503b2e85b9a12c12cd15b1f65a11453ba31b

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3af9b317feb1280d1dd2f4d08535c2ff848e93c3ebf815d18613545316fe0f6a
MD5 62c3f81da96afca83c71bc84652ca7b6
BLAKE2b-256 5d580a9151538b52a37ca7a7d1c81aec01ee1a2d418c9feaf311cda485ba9400

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d3f30ec0f3ab78351f8a342ab32ce27a5d72f064f76e19d4ff7b8356434eb547
MD5 61edf2d223b794fe3284ba48db2c51cf
BLAKE2b-256 1abecea6d790e45c88a08b24a7b9eacf359766fe3a768b25f56431c5a9959c69

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyyield-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for pyyield-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d35aaa3d8a109f0ea8628d30f482e175cbd8dd46abcb04e5a8ca06ee230a1f0f
MD5 eac58390216ead473d22e877d5771fb0
BLAKE2b-256 5fa0e71c207170b3a0cdc4cda128e7355d3c2c02482a13288c7ea167a2a232a2

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fda57ba81df57968ce8048659e81a0d84d8e966a2c7f1280334f347fdfbb9b2b
MD5 70b960c5b8620951bb4837554a665984
BLAKE2b-256 85ce91cde523e2c9d9124c8489f88adccab95f89b9eafc1b5475291437722609

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a65fc206c7a06186adcb9c74f8c5ecc63a7c18e67ae39e43f0bfb392684d63a0
MD5 e211db905f31d5b5d6a884cda1585b6b
BLAKE2b-256 d16ff443c1d4eed5b4259fe96531102487aebeb948051b32d85d95bafa9db3f2

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyyield-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for pyyield-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a60f3790c59e1dd7565172bf8281493bf3436e87193814b18b64810931ba7e83
MD5 f36e2723b8a3904364e03e34638d8c3c
BLAKE2b-256 4e0656f4bad9fdc4aa24d336a458a79df1d868153545a939b6876a432b5dfc5b

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a504c8e4857f8ac8850edbb03352310bc2bd1c8f96d58863d45281befee734b3
MD5 78dbd8318af37b73da89a7d0067d3c91
BLAKE2b-256 1d3515f0ceb6961e4e9f56bd41eda9596ccae05619ef660d8db36ab8f867b05e

See more details on using hashes here.

File details

Details for the file pyyield-0.1.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyyield-0.1.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 e7dd75306f8868b5a51b9dda3c406d16a73236fb4c10b353906dd53335c08c03
MD5 46973ca420f6badee8db33245658a20c
BLAKE2b-256 132a0d9784fad5e97030842c531b21e6d51d5b3b753dc5169a7dabc0552eae6f

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