Skip to content

A python library using private/hidden features

License

Notifications You must be signed in to change notification settings

fastats/privates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

privates

Build Status codecov Codacy Badge Documentation Status

A python library using private/hidden python language features

documentation

Click here for the documentation

installation

There are no published packages yet. Soon you will be able to pip install...

features

from privates import no_mutations

x = {a: 1, b: 2}

with no_mutations(x):
    value = x['a']  # this is fine

with no_mutations(x):
    x['c'] = 3  # this will throw a MutationError

# The mutation check is `ex-post`,
# therefore the change is still made.
assert 'c' in x
  • A NamedStruct to facilitate calling external native/jitted APIs, which allows inheritance of attributes, among other behaviours. This also features as a better namedtuple/typing.NamedTuple, without the errors and performance issues of the existing implementations.
from privates import NamedStruct


class Point(NamedStruct):
    x: int
    y: int


class Rectangle(Point):
    height: int
    width: int

    def area(self):
        return self.height * self.width


# This creates a `numba` jitclass.
r = Rectangle.create(x=0, y=0, height=3, width=4)
assert r.area() == 12

development/contributing

  • To report a bug, please open a PR with a new (failing) unit-test showing the problem.
  • To request a feature, please open a PR with a new (failing) unit-test showing the preferred API.
  • To make a contribution, please open a PR with new (passing) unit-tests, inline doctest examples and documentation updates.

requirements

  • Python 3.6 or later
  • py.test
  • coverage
  • numba >= 0.33

About

A python library using private/hidden features

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages