Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Sequence Tokenizer (seqtok)

A Python implementation mimicking C's strtok() behavior for generic sequences, but without global state.

Features

  • Splits any sequence type (lists, tuples, strings) using separator elements
  • Memory efficient (yields tokens one at a time)
  • Follows C's strtok() conventions:
    • Skips leading/trailing separators
    • Treats consecutive separators as single delimiter
    • Never returns empty tokens
  • But with crucial differences:
    • State is encapsulated in the generator instance (no global state)
      • No thread safety concerns from global state
    • Each iterator maintains independent state (safe for separate instances)
      • Multiple tokenizers can operate simultaneously
    • Original sequence is never modified
    • Immutable tokens via COWList (Copy-On-Write List)

Installation

pip install seqtok

Examples

from seqtok import seqtok

# Tokenize a list of numbers
numbers = [1, 2, 0, 3, 4, 0, 0, 5]
for token in seqtok(numbers, {0}):
    print(token)
# Output: COWList([1, 2])
#         COWList([3, 4])
#         COWList([5])

# Tokenize a string
text = "..Hello...world.!"
for token in seqtok(text, {'.', '!'}):
    print(''.join(token))
# Output: Hello
#         world

Contributing

Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.

License

This project is licensed under the MIT License.

Release files for seqtok 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seqtok 0.1.0a1
File Size Uploaded
seqtok-0.1.0a1.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for seqtok 0.1.0a1
File Interpreter ABI Platform
seqtok-0.1.0a1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 7.0 kB

Release files / seqtok-0.1.0a1.tar.gz

Download URL seqtok-0.1.0a1.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c51bb4f9683096c66f3f765c9ab97f828ede5d875c48df4ae2fdda1555b2c024
BLAKE2b-256 checksum
How to use checksums
b1056564770f57a857e8bbeef1481db46f2cef2011cec80a12d3faf5e72f75cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release files / seqtok-0.1.0a1-py2.py3-none-any.whl

Download URL seqtok-0.1.0a1-py2.py3-none-any.whl
Size 3.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fbe5dc5a332a96f88a6944f826bf466a528f835f701a7f6e92e1e2311cd895a2
BLAKE2b-256 checksum
How to use checksums
a1dbc57efa4cc2d29f7225acc793ac3fea2254c22012398830bb060a4f038a79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page