Git Product home page Git Product logo

byteclasses's Introduction

Byteclasses Python Package

Version Status Libraries.io dependency status for latest release Wheel Downloads License Python Implementation Python Version

Lint Test Release Publish

Pre-Commit Ruff

Logo

A python package designed to ease data manipulation tasks and improve efficiency when handling binary data.

Installation

> pip install byteclasses

Description

Byteclasses provides a variety of convenience wrapper classes to simplify data handling. These wrapper classes automatically pack and unpack data values.

Additionally, certains types, such as byteclass integers, impose type specific constraints. For example, assigning the value 256 to a UInt8 will raise an OverflowError exception.

This library contains a variety of fixed size primitive byteclasses. These primitive classes can be used in conjunction with the byteclass collections to build more complicated data elements.

Similiar to a Python dataclass, byteclass collections are constructured using the structure or union class decorators. Whereas dataclasses have fields, byteclass collections have members. Collection members must be a byteclass type and cannot have a default value unless using the member constructor function. Each member will be instantiated using its type hint as a factory.

A byteclass structure and union behaves similar to a C struct and union respectively.

The ByteArray and String collections can be instantiated directly using the provided classes.

Byteclasses

  • Primitives

    • Generic - BitField, Byte, Word,DWord, QWord
    • Characters - UChar (Char), SChar
    • Floats - Float16 (Half), Float32 (Float),Float64 (Double)
    • Integers - Int8, UInt8, Int16 (Short), UInt16 (UShort), Int32 (Int), UInt32 (UInt), Long, ULong, Int64 (LongLong), UInt64 (ULongLong)
    • Special - ByteEnum
  • Collections

    • ByteArray - Class
    • String - Class
    • structure - Class Decorator
    • union - Class Decorator

Simple Byteclass Structure Example

from byteclasses.types.collections import structure
from byteclasses.types.primitives.integer import UInt8, UInt32

@structure
class MyStruct:
  """My custom byteclass structure."""

  member1: UInt8
  member2: UInt32

my_var = MyStruct()

Docs

Byteclasses Documentation

References

C data types

byteclasses's People

Contributors

thetacom avatar

Stargazers

 avatar xrkk avatar  avatar Vladimir Sklyar avatar  avatar LowLevelLearning avatar Roland Thomas Jr avatar

Watchers

 avatar  avatar

Forkers

heruix

byteclasses's Issues

Adjust all byteclasses to have a consistent instantiation parameters

Adjust classes and decorators so nearly all byteclasses can be instantiated with a standard set of parameters.

class Byteclass(data: ByteString | None = None, byte_order: bytes = b'@', check_constraints: bool = True)

  • Numeric classes will also have a value parameter. The value and data parameters will be mutually exclusive.
  • FixedArray will have a required item_count parameter and an optional item_type parameter.

Add high contrast colors to Data Handler pages

Some colors are difficult to see against a white background (especially yellow and teal) in the jupyter notebooks sections of the Data Handler pages. A way to toggle the colors on/off would help readability.

Make byteclass collections iterable

  • Iterating over a collection will iterate over its members
  • Create CollectionIterator class
  • Add __iter__ to all collection classes and factories.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.