Skip to main content

A high-performance abstract base class implementation for Python

Project description

Fast Abstract

Fast Abstract is a high-performance implementation of abstract base classes for Python, designed with optimized checks and minimal overhead. Created by Michael Avina, this module offers a lightweight solution for developers who want to leverage abstract classes without the additional overhead of Python's built-in abc module.

Why?

I wanted a lightweight, high-performance alternative to Python's abc module that still provides the essential functionality of abstract base classes. Fast Abstract is perfect for applications that require speed and minimal overhead while still enforcing interface contracts within your Python code.

Features

  • Optimized for Performance: Fast Abstract uses tuples and avoids dynamic checks wherever possible to minimize runtime overhead.
  • Lightweight: The module is small, simple, and easy to integrate into any Python project.
  • Flexible Enforcement Levels: Allows you to specify enforcement levels ('error', 'warning', 'none') for abstract method checks.

Installation

You can install Fast Abstract using pip

Usage

from fast_abstract import FastAbstract, abstractmethod, abstractproperty

class MyBase(FastAbstract):
    @abstractmethod
    def method(self):
        pass
    
    @abstractproperty
    def my_property(self):
        """Abstract property example."""
        pass

    @abstractmethod
    def abstract_another_method(self):
        """Abstract method example with prefix 'abstract_'."""
        pass

class ConcreteClass(MyBase):
    def method(self):
        print("Method implemented in ConcreteClass")

    @property
    def my_property(self):
        return "Property implemented in ConcreteClass"

    def abstract_another_method(self):
        print("Abstract method with prefix implemented")

obj = ConcreteClass()
obj.method()  # This will print: Method implemented in ConcreteClass
print(obj.my_property)  # This will print: Property implemented in ConcreteClass
obj.abstract_another_method()  # This will print: Abstract method with prefix implemented

### 5. `LICENSE` File

The license remains the same:

#### `LICENSE`

```plaintext
MIT License

MIT License

Copyright (c) 2024 Michael Avina

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 details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_abstract-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

fast_abstract-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file fast_abstract-0.1.0.tar.gz.

File metadata

  • Download URL: fast_abstract-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for fast_abstract-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3509e82ee4b5b59192fc0c282ba6b03ead9e351d1c2a6289a9a2de56633cc495
MD5 e22b73d54806321b366d2f10691ec98f
BLAKE2b-256 c392a56568489224a2db784c446c87cb4d9b88f25aec707a1ab18b3e1580a459

See more details on using hashes here.

File details

Details for the file fast_abstract-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fast_abstract-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 952bc7763ffbb313f58dadd9a4ee3d640a0d739197175aab9cbd88b2237cf146
MD5 b2f0deaf4cbd348e2c98543770ea70e8
BLAKE2b-256 d8be838b85bdbed0c321852d26f6d26d1c4d7ec106b261bbb0f280373073a5f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page