semvec/pypi-packages huggingface dataset:
dynamic-segment-tree 0.1.0
Dynamic segment tree with Python bindings
Requires Python: >=3.7

# Dynamic Segment Tree

A high-performance dynamic segment tree implemented in C++ with Python bindings using pybind11.  
Supports efficient range queries and updates on large arrays without reserving memory upfront.

## About Dynamic Segment Tree

This package implements a **dynamic segment tree** data structure for efficient use in Python programs.

### What is a dynamic segment tree?

- A **segment tree** is a powerful data structure used to perform **range queries and updates** efficiently on an array.
- The **dynamic** variant does **not pre-allocate memory for the entire array size**, but instead **creates nodes only when needed**, saving memory.
- This makes it practical for very large arrays (e.g., length 10 million or more) where many elements are initially zero or default.

### What problem does this solve?

- Suppose you have **M categories** and an array of length N.
- At each position, exactly one category is assigned.
- You want to:
  - **Update** the category at any index dynamically.
  - **Query** how many elements of a given category exist in any range `[L, R]`.
- This package supports exactly that efficiently, using minimal memory.

## Main Functions

### `DynamicSegTree(N)`

- Creates a dynamic segment tree for an array of size `N`.
- Initially, all positions are empty (or a default invalid category).

### `build(arr)`

- Builds the tree from a given list/array `arr` of categories.
- This initializes the data structure with known values.

### `set(pos, category)`

- Updates the element at position `pos` to belong to `category`.
- If the position already had a category, it updates it accordingly.

### `get(pos)`

- Returns the current category at position `pos`.
- Returns `-1` if the position is unset or empty.

### `query(l, r, category)`

- Returns the **count** of elements belonging to `category` in the range `[l, r]`.
- This is the main query function and works efficiently even for large `N`.

## Why Use This Package?

- Designed for very large arrays where a classical segment tree would be memory-heavy.
- Provides a Python interface for easy integration into your projects.
- Efficiently supports queries and updates with **logarithmic time complexity**.
- Ideal for problems involving category counts over large ranges with sparse updates.

## Installation

```bash
pip install dynamic-segment-tree
smpl-logger 0.1.5
A simple logging library with colored output and file rotation support
Requires Python: >=3.6
Keywords: logging, logger, colored, rotation, python

# SiMPLe Logger

A simple logging library with colored output and file rotation support

## Installation

```bash
pip install smpl-logger
```

Or install from source:

```bash
pip install git+https://github.com/greengoblinalex/simple-logger.git
```

## Usage

```python
from smpl_logger import get_logger

# It is recommended to use __name__ as the logger name —
# this is convenient for structuring logs in large projects
logger = get_logger(__name__)

# You can also explicitly pass a string, for example:
# logger = get_logger("my_app")
logger.info("This is an info message")
logger.error("This is an error message")

# Logging to file and console
file_logger = get_logger(__name__, log_file="app.log")
file_logger.info("This message will appear in both file and console")
```

## Configuration

You can configure the logger using additional parameters:

```python
logger = get_logger(
    name=__name__,  # Recommended to use __name__, but you can use a string
    log_file="app.log",
    level="DEBUG",  # Logging level
    rotation_size=5 * 1024 * 1024,  # 5 MB for rotation
    backup_count=3  # Keep 3 backup files
)
```

## Configuration via .env file

You can also configure logging parameters via a `.env` file in your project root:

```
LOG_DIR=logs                # Directory for log files
LOG_LEVEL=INFO              # Logging level
LOG_ROTATION_SIZE=5242880   # File size for rotation (5MB)
LOG_BACKUP_COUNT=3          # Number of backup files
```

## Features

- 🎨 **Colored output** - different log levels are highlighted with different colors
- 🔄 **File rotation** - automatic log rotation when the file reaches the maximum size
- ⚙️ **Flexible configuration** - configure via function parameters or environment variables
- 📦 **Lightweight** - no external dependencies, uses only the Python standard library
- 🔧 **Easy to use** - minimal code to get started

## Example of colored output

When using console logging, you will see:
- 🟢 **INFO** - green for informational messages
- 🟡 **WARNING** - yellow for warnings
- 🔴 **ERROR** - red for errors
- 🔵 **DEBUG** - cyan for debug information
- 🟥 **CRITICAL** - red background for critical errors
pydantic-nested 0.1.2
Pydantic models from nested dictionaries
Requires Python: >=3.11

# Pydantic Nested


This Python library allows you to create **Pydantic models** with support for nested dictionaries, lists, default values, and field constraints. The schema is defined using standard Python types and Pydantic's features.

## Features
- Supports simple fields (e.g., `str`, `int`, `float`)
- Nested dictionaries and lists
- Default values for fields
- Pydantic field constraints (e.g., `conint`, `conlist`)
- Full validation with dynamically created models


## Usage

Where could this be useful?
Sometimes data models can be very nested. Also, API queries exposing search engines such as elasticsearch can get convoluted and required validation.
Models defined in dictionary format instead of classes could be easier to read.

### Define the model

```python
from pydantic import Field, conint, conlist
from pydantic_nested.model import create_nested_model

schema = {
    "str1": str,
    "str2": (str, "default_string"),
    "str3": (str | None, None),
    "str4": (str, Field("str4 default value", description="str4 description")),
    "list1": list,
    "list2": list | tuple,
    "list3": list[int | str],
    "list4": (list, None),
    "list5": (list[float], Field(default_factory=list)),
    "dict1": {
        "str1": (str | None, None),
        "str2": (str, "default_string"),
    },
    "dict2": {"product_ids": conlist(int, min_length=1, max_length=20)},
    "dict3": {"include": {"product_ids": list[conint(ge=1)]}},
    "dict_list_nullable": (
        {
            "str1": (str | None, None),
            "str2": (str, "default_string"),
        },
        None,
    ),
    "list_of_objects1": [{"str1": str}],
    "list_of_objects2": [{"str1": str}, {"bool1": bool}],
    "list_of_objects3": ([{"str1": str}, {"bool1": bool}], None),
    "list_of_objects4": ([{"str1": str}, {"bool1": bool}], Field(default_factory=list, max_length=5)),
}
```

### Create the model

###
```python
TestModel = create_nested_model(schema, "TestModel")

sample_data = {
    "str1": "example string",
    "list1": [1, 2, 3],
    "list2": (1, 2),
    "list3": ["1", 2],
    "dict1": {},
    "dict2": {"product_ids": [1, 2, 3]},
    "dict3": {"include": {"product_ids": [1, 2, 3]}},
    "list_of_objects1": [{"str1": "object1"}],
    "list_of_objects2": [{"bool1": True}],
}

# Instantiate the model and validate the data
model_instance = TestModel(**sample_data)
print(model_instance.dict())
```