Skip to main content

Viper

A Python library full of useful Python tools.

Viper adds many missing tools and improves many existing tools in Python. For example, this includes frozendicts, a more advanced IO interface, improved ABCs, debugging tools, new decorators, types of classes, even new types of modules, etc. It is designed to feel very Python-like.

To list all of the available packages, simply Python's interactive prompt and explore:

>>> from Viper import *
>>> import Viper
>>> dir(Viper)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'abc', 'debugging', 'exceptions', 'format', 'frozendict', 'interactive', 'io', 'meta', 'pickle_utils', 'warnings']
>>> help(io)
Help on module Viper.io in Viper:

NAME
    Viper.io - This module adds some useful IO tools. This includes IO buffer and pipe/circular buffers for both bytes and strings.

CLASSES
    Viper.abc.io.BytesIO(Viper.abc.io.BytesReader, Viper.abc.io.BytesWriter, Viper.abc.io.IO)
        BytesBuffer
        BytesIO
    Viper.abc.io.StringIO(Viper.abc.io.StringReader, Viper.abc.io.StringWriter, Viper.abc.io.IO)
        StringBuffer
        StringIO

    class BytesBuffer(Viper.abc.io.BytesIO)
...

Some practical and classical examples of the content of Viper include:

  • Making iterable classes:
>>> class MyClass(metaclass = Viper.meta.iterable.InstanceReferencingClass):
...     pass
... 
>>> c = MyClass()
>>> list(MyClass)[0] is c
True
>>> del c
>>> len(list(MyClass))
0

This is useful for classes for which you want to keep track of the instances or for which you need to perform some operations on.

  • Timing function calls and generate performance reports:
>>> c = Viper.debugging.chrono.Chrono()
>>> @c
... def fibo(n):
...     if n <= 0:
...         return 0
...     if n == 1:
...         return 1
...     return fibo(n - 1) + fibo(n - 2)
...
>>> fibo(25)
75025
>>> Viper.debugging.chrono.print_report(c)
Execution report featuring 1 functions or methods, over 375ms.
Per function results :
Function __main__.fibo
        Calls : 242785, Total :   375ms   , Average : 1µs, 545ns, Proportion : 100.0% of the time

You can use one Chrono object on multiple functions. It becomes useful if you need to know what part of your code you should optimize first.

  • Flux operators:
>>> buffer = Viper.io.BytesIO()
>>> buffer << Viper.pickle_utils.StreamPickler("This is a test object")
>>> buffer.seek(0)
0
>>> Viper.pickle_utils.StreamUnpickler() << buffer
'This is a test object'

Flux operator define a much stronger, safer and handy interface than Python IOs. Furthermore, this syntax is revertible and stackable for constants:

>>> buffer = Viper.io.StringIO()
>>> "Good!\n" >> (buffer << "Hello!\n" << "How are you doing?\n")
<Viper.io.StringIO object at 0x000002A2F862E4A0>
>>> buffer.seek(0)
0
>>> buffer.readable
Budget(32)
>>> print(buffer.read(buffer.readable.value))
Hello!
How are you doing?
Good!
  • And many other useful random features!

Note that this library is extensively documented. Use Python's help system (for example the help function while in an interactive interpreter) to learn how to use all the modules and classes.

Metadata

Release files for viper-lib 1.5.2

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

Source distribution (sdist)

Source distribution for viper-lib 1.5.2
File Size Uploaded Provenance Actions
viper_lib-1.5.2.tar.gz 53.1 kB Without provenance Details for viper_lib-1.5.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for viper-lib 1.5.2
File Interpreter ABI Platform Actions
viper_lib-1.5.2-py3-none-any.whl Python 3 none any Details for viper_lib-1.5.2-py3-none-any.whl

Total release size: 118.1 kB

Release files / viper_lib-1.5.2.tar.gz

Download URL viper_lib-1.5.2.tar.gz
Size 53.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ae3abaddefd4694a91e0952eab4f892e9f49ca81ac3993751e8adb577275cc29
BLAKE2b-256 checksum
How to use checksums
a2ccd729dc160e49127d2e0ec43cef8fb8727dc6c0cbb7fa8f340f9d85285a3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.4

Release files / viper_lib-1.5.2-py3-none-any.whl

Download URL viper_lib-1.5.2-py3-none-any.whl
Size 65.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
079d4843764f8c12c53029181e6e9549e9c80960cca2c5a1b6aa94fb18e928f3
BLAKE2b-256 checksum
How to use checksums
55c8ed1dda1d387b82f95913fd0c5b43415fe69f7f4166652acfc9d26a7914bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.4

Security for viper-lib 1.5.2

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.

Release history Release notifications | RSS feed

This release

1.5.2 This release

2 release files No provenance

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