<commit_before># keypool

`keypool` is a collection of classes to generate and maintain a pool of unique integer keys.  
Priority is given to reusing freed keys rather than generating new ones.

This package is meant for situations where keys for a dict are irrelevant or
arbitrary.

## The basics
```python
      from keypool import KeypoolDict
      items = KeypoolDict()
      
      # Assign a value with a unique, generated key
      items[items.next()] = 'hello, world'
      
      # Assign a value but capture the key
      key = items.setitem('hello again, world')
      
      # Assign anything except an integer, like a normal dict
      items['hello'] = 'world'
```
## Examples

Let's say you're wrapping a timer function in some horrible API:
```python
      def timer(unique_name, **kwargs):
            ...
```
            
and each active timer needs to be stored for efficient lookup (i.e. a dict)
Usually a timestamp or uuid will suffice for this type of problem:

```python
      import time
      
      timers = {}<commit_msg>Fixed syntax highlighting<commit_after># keypool

`keypool` is a collection of classes to generate and maintain a pool of unique integer keys.  
Priority is given to reusing freed keys rather than generating new ones.

This package is meant for situations where keys for a dict are irrelevant or
arbitrary.

## The basics
```python
      from keypool import KeypoolDict
      items = KeypoolDict()
      
      # Assign a value with a unique, generated key
      items[items.next()] = 'hello, world'
      
      # Assign a value but capture the key
      key = items.setitem('hello again, world')
      
      # Assign anything except an integer, like a normal dict
      items['hello'] = 'world'
```
## Examples

Let's say you're wrapping a timer function in some horrible API:

```python
      def timer(unique_name, **kwargs):
            ...
```
            
and each active timer needs to be stored for efficient lookup (i.e. a dict)
Usually a timestamp or uuid will suffice for this type of problem:

```python
      import time
      
      timers = {}
{'fraction_non_alphanumeric': 0.07498813478879925, 'fraction_numerical': 0.0, 'mean_word_length': 2.711267605633803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '849030', 'n_tokens_mistral': 577, 'n_tokens_neox': 545, 'n_words': 268}