Skip to main content

Pure Python, relatively-efficient reading of null-terminated lines

Project description

Read lines of data with an arbitrary delimiter, like a null, newline or even an x.

It passes pylint, passes pycodestyle, passes pydocstyle, is thoroughly unit tested, and runs on CPython 2.7, CPython 3.x, Pypy 7.3.1, Pypy3 7.3.1.

It gains a lot of speed by eschewing single-character reads.

Usage looks like: $ /usr/local/cpython-3.6/bin/python3 Python 3.6.0 (default, Apr 22 2017, 09:17:19) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

import readline0 file_ = open('/etc/shells', 'r') for line in readline0.readline0(file_=file_, separator=b' '): ... print(line) ... b'# /etc/shells: valid login shells' b'/bin/sh' b'/bin/dash' b'/bin/bash' b'/bin/rbash'

Of course separator need not be a newline; it defaults to a null byte.

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

readline0-1.3.tar.gz (4.0 kB view hashes)

Uploaded Source

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