Skip to main content

Character Occurrence Counter with Caching

This Python package calculates the number of unique characters in a given string or text file, while using caching to optimize performance for repeated calculations.

Features

  • Unique Character Counting: Identify characters that occur only once in a string or file.
  • Caching Mechanism: Uses lru_cache to speed up repeated character counting operations.
  • Command-Line Interface (CLI): Allows processing of input directly from the terminal.
  • Optimized Performance: Leverages the collections module for efficient counting.
  • Robust Testing: Comprehensive tests written with pytest to handle various edge cases and performance scenarios.
  • Coverage Reports: Ability to generate coverage reports to ensure all code is thoroughly tested.

Prerequisites

Before installing, ensure you have the following:

  • Python 3.6 or later installed.

Installation

You can install the package directly from PyPI:

pip install unique_character_counter

Usage

1. As a Module

You can import and use the module in your Python scripts as follows:

from collection.unique_char_count import get_unique_character_count

result = get_unique_character_count("abcdefg")
print(f"Number of unique characters: {result}")

2. Command-Line Interface

After installing, you can use the provided CLI commands to process strings or files:

To Process a String:

unique-counter --string "abcdefg"

To Process a File:

unique-counter --file path/to/your/file.txt

Testing

This package includes tests to ensure all features are working as expected. You can use pytest to run the tests after installation.

Important Note About Tests

Ensure that the tests folder contains an __init__.py file. This file is necessary to make tests a proper package that can be discovered by pytest during the installation process.

Run All Tests

Specify the package name to run all tests:

pytest --pyargs collection.tests

This ensures pytest can locate and run all test files included in the installed package.

Alternatively, Specify the Path to the Tests Folder:

pytest collection/tests

Generate a Coverage Report

To generate a coverage report, use the following commands:

coverage run -m pytest --pyargs collection.tests
coverage report

Ensure pytest is installed if it isn't already:

pip install pytest

Optional: Create a Virtual Environment

It is recommended to use a virtual environment to keep dependencies isolated. This step is optional but can help maintain a clean development environment.

To create a virtual environment:

python -m venv venv

Activate the virtual environment:

  • On Windows:
    venv\Scripts\activate
    
  • On macOS/Linux:
    source venv/bin/activate
    

License

This project is licensed under the MIT License. See the LICENSE file for more details.


Support

If you encounter any issues or have suggestions, please feel free to open an issue on the GitLab repository.

Metadata

Release files for unique-character-counter 0.1.3

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

Source distribution (sdist)

Source distribution for unique-character-counter 0.1.3
File Size Uploaded Provenance Actions
unique_character_counter-0.1.3.tar.gz 7.7 kB Without provenance Details for unique_character_counter-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unique-character-counter 0.1.3
File Interpreter ABI Platform Actions
unique_character_counter-0.1.3-py3-none-any.whl Python 3 none any Details for unique_character_counter-0.1.3-py3-none-any.whl

Total release size: 13.5 kB

Release files / unique_character_counter-0.1.3.tar.gz

Download URL unique_character_counter-0.1.3.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d3df8d092c0f49f354cd81db6a3c618957a06ae8ed95598624d472c92a3555d8
BLAKE2b-256 checksum
How to use checksums
a85946819ad57d5056bbb0accff0358b596405d86fc838a4ceafaf42e1789bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release files / unique_character_counter-0.1.3-py3-none-any.whl

Download URL unique_character_counter-0.1.3-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de92b47920258541f830f3f5b044956a31c01f58083f5eec00053cf710e701ef
BLAKE2b-256 checksum
How to use checksums
28dfbef9ec445b55e93d167213c4585cfd148d21f6d38179f8a8011afbd84e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Security for unique-character-counter 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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