Skip to content

Commit

Permalink
Merge pull request #10 from jtraglia/subclass
Browse files Browse the repository at this point in the history
Change `#[pyclass]` to `#[pyclass(subclass)]` for structs
  • Loading branch information
kevaundray authored Sep 24, 2024
2 parents c0cb3e6 + 5120382 commit 96d8516
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion examples/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@

# Conversion to int
assert int(Scalar(0)) == 0
assert int(Scalar(12345)) == 12345
assert int(Scalar(12345)) == 12345

# The ability to inherit Scalar
class NewScalar(Scalar):
pass

assert NewScalar(1) == Scalar(1)
8 changes: 4 additions & 4 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const G2_COMPRESSED_SIZE: usize = 96;
const SCALAR_SIZE: usize = 32;

#[derive(Copy, Clone)]
#[pyclass]
#[pyclass(subclass)]
pub struct G1Point(G1Projective);

#[pymethods]
Expand Down Expand Up @@ -99,7 +99,7 @@ impl G1Point {
}

#[derive(Copy, Clone)]
#[pyclass]
#[pyclass(subclass)]
pub struct G2Point(G2Projective);

#[pymethods]
Expand Down Expand Up @@ -184,7 +184,7 @@ impl G2Point {
}

#[derive(Copy, Clone)]
#[pyclass]
#[pyclass(subclass)]
pub struct Scalar(ark_bls12_381::Fr);

#[pymethods]
Expand Down Expand Up @@ -264,7 +264,7 @@ impl Scalar {
}

#[derive(Copy, Clone)]
#[pyclass]
#[pyclass(subclass)]
pub struct GT(ark_bls12_381::Fq12);

#[pymethods]
Expand Down

0 comments on commit 96d8516

Please sign in to comment.