Skip to content

Investigate using a pyi file for numeric types #14

Description

@SamWilsn

We used to directly subclass int to implement our numeric types. Unfortunately that approach violated the Liskov substitution principle: replacing any arbitrary int with an instance of Uint could break the program.

Instead, our integer types are fully separate classes, and with that comes significant performance penalties.

Based on some quick experimentation on my part, we should be able to make our integer types inherit from int but convince mypy that they aren't actually subclasses of int by using a custom *.pyi file. This would give us the performance benefits of being an int subclass, but the stronger typing guarantees of our current approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions