Metadata-Version: 2.1
Name: rindex
Version: 1.0.1
Summary: rindex() function for sequences
Author: Krutyi 4el
License: Copyright 2023 Krutyi 4el
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Repository, https://github.com/Krutyi-4el/rindex
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

# rindex

This package provides `rindex()` function that returns last index of value in sequence.

## Installing

```bash
pip install rindex
```

## Examples

```python
from rindex import rindex


numbers = [5, 1, 3, 8, 10, 5, 8, 1, 8, 3]

print(rindex(numbers, 1))  # 7

print(rindex(numbers, 8, 4, 8))  # 6
```

## Goals

- Support all features of built-in `.index()`

- Speed

- Portability (support for different platforms)

## Supported platforms

Currently, the library includes three `rindex()` implementations:

- Cython

- Pure Python (when the Cython one is not available; slower)

- Pure Python for PyPy

## Features

- Supports any sequences

- Supports `start` and `stop` (both may be negative or out of bounds)

- Doesn't copy the sequence

## Controlling Cython extensions

You can set environment variable `ENABLE_RINDEX_EXTENSIONS` to `0` or `1` to forcefully disable/enable Cython extensions.
This can be useful if you face compilation problems and want to use pure Python version.

## Benchmarking

`tests/benchmark.py` can generate interactive plots with comparisons of different implementations.
