semvec/pypi-packages huggingface dataset:
kcp-py 0.1.4
Python bindings and networking for the KCP protocol.
License: MIT
Requires Python: >=3.7
Keywords: kcp,server,client,async,asyncio

# kcp.py
Python bindings and networking for the KCP protocol.

## What is KCP?
KCP is a protocol focusing on low latency data delivery with a guarantee of data delivery. It serves as an alternative to the TCP protocol.

## How to install?
kcp.py is available on [PyPi](https://pypi.org/project/kcp-py/), meaning installing is as simple as running
```sh
pip install kcp.py
```

## Examples
### Asynchronous Server
kcp.py features an implementation of an asynchronous server using the event loop protocol API.
```py
from kcp.server import Connection
from kcp.server import KCPServerAsync

# Create the initial server instance.
server = KCPServerAsync(
    "127.0.0.1",
    9999,
    conv_id=1,
    no_delay=True,
)

# Ability to set performance options after initialisation.
server.set_performance_options(
    update_interval=10,
)


# Ran when the server starts.
@server.on_start
async def on_start() -> None:
    print("Server started!")


# Ran when a connection is made.
@server.on_data
async def on_data(connection: Connection, data: bytes) -> None:
    print(f"Received data from {connection.address}: {data}")


server.start()
```

### Client
kcp.py also implements a KCP client using Python's sockets and threads.
```py
from kcp import KCPClientSync

client = KCPClientSync(
    "127.0.0.1",
    9999,
    conv_id=1,
)


@client.on_data
def handle_data(data: bytes) -> None:
    print(data)


@client.on_start
def on_start() -> None:
    print("Connected to server!")

    while True:
        client.send(b"Data!")


client.start()
```

You may find more examples in the `examples` directory within the repo.

## Features
- [x] Bindings to the C implementation of KCP
- [x] Pythonic API over said C bindings
- [ ] Asynchronous KCP Client
- [x] Synchronous KCP Client
- [x] Asynchronous KCP Server
- [x] Full support for installation through pip

## Credit
kcp.py uses [the official KCP implementation](https://github.com/skywind3000/kcp) behind the scenes.
torch-grammar 0.3.3
Restrict LLM generations to a context-free grammar
License: MIT
Requires Python: >=3.9,<4.0

# torch-grammar

**Alpha Quality: This might do what you want. It's likely to not do what you
want. Please open issues!**

Torch-Grammar restricts a model to output a token sequence that conforms to a
provided EBNF grammar.

For example:

```python
import torch
from torch_grammar import GrammarSampler
from transformers import LlamaTokenizer
tokenizer = LlamaTokenizer.from_pretrained("huggyllama/llama-7b")

with open("examples/grammar.ebnf", "r") as file:
    input_text = file.read()
grammar = GrammarSampler(input_text, "root", tokenizer)

ids = [[1]]
logits_processor = grammar.logits_processor()

vocab_size = len(tokenizer.get_vocab())
for i in range(10):
  logits = torch.randn((1, vocab_size))
  logits = logits_processor(ids, logits)
  token = torch.argmax(logits).item()
  # logits_processor.accept_token(token)
  ids[0].append(token)
print(f"\x1b[1mfirst 10 tokens: \x1b[1;35m{tokenizer.decode(ids[0])}\x1b[0m")
```

`logits_processor` is meant to be passed to `model.generate` in a HuggingFace
transformers model but this integration is not yet super clean.

### TODO / possible features

* UTF-8 support... a bit of fiddling but not terribly hard
* More expressive grammars... lookahead would be challenging.
* Easier integration with various tokenizers... LLaMA works well; T5 presents
  significant challenges; haven't even tried others.
* Testing and automatic benchmarking.
* Binary parse is probably not carrying its weight with all the caching and
  precomputation we're doing now; it should be rewritten to something less
  confusing. In fact it might work to just hijack Lark or something?

### Broken seeds

* 11833882144218229242

### Related Work

The code was originally adapted from
https://github.com/ggerganov/llama.cpp/pull/1773. In particular, the grammar
parser is a pretty straightforward mechanical translation and the binary grammar
format is identical.
micropython-motor 0.2.0
MicroPython Helpers for controlling PWM based motors and servos
License: MIT
Keywords: sensor,micropython,motor,pwm,motor,servo,drv8833,stepper

Introduction
============


.. image:: https://readthedocs.org/projects/micropython-motor/badge/?version=latest
    :target: https://micropython-motor.readthedocs.io/en/latest/
    :alt: Documentation Status


.. image:: https://img.shields.io/badge/micropython-Ok-purple.svg
    :target: https://micropython.org
    :alt: micropython

.. image:: https://img.shields.io/pypi/v/micropython-motor.svg
    :alt: latest version on PyPI
    :target: https://pypi.python.org/pypi/micropython-motor

.. image:: https://static.pepy.tech/personalized-badge/micropython-motor?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Pypi%20Downloads
    :alt: Total PyPI downloads
    :target: https://pepy.tech/project/micropython-motor

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: Code Style: Black

MicroPython Helpers for controlling PWM based motors and servos This has been adapted to use in the
Raspberry Pi Pico from the excellent Adafruit_CircuitPython_Motor Library here:
https://github.com/adafruit/Adafruit_CircuitPython_Motor

This library can work with other MCU (Not tested) that used the following PWM methods:

* freq
* duty_u16


Installing with mip
====================
To install using mpremote

.. code-block:: shell

    mpremote mip install github:jposada202020/MicroPython_MOTOR

To install directly using a WIFI capable board

.. code-block:: shell

    mip install github:jposada202020/MicroPython_MOTOR


Installing Library Examples
============================

If you want to install library examples:

.. code-block:: shell

    mpremote mip install github:jposada202020/MicroPython_MOTOR/examples.json

To install directly using a WIFI capable board

.. code-block:: shell

    mip install github:jposada202020/MicroPython_MOTOR/examples.json


Installing from PyPI
=====================

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/micropython-motor/>`_.
To install for current user:

.. code-block:: shell

    pip3 install micropython-motor

To install system-wide (this may be required in some cases):

.. code-block:: shell

    sudo pip3 install micropython-motor

To install in a virtual environment in your current project:

.. code-block:: shell

    mkdir project-name && cd project-name
    python3 -m venv .venv
    source .env/bin/activate
    pip3 install micropython-motor


Usage Example
=============

Take a look at the examples directory

Documentation
=============
API documentation for this library can be found on `Read the Docs <https://micropython-motor.readthedocs.io/en/latest/>`_.