Skip to content

Commit f347f18

Browse files
committed
Add pickling support for fmpz/fmpq
1 parent 08bd191 commit f347f18

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/flint/fmpq.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ cdef class fmpq(flint_scalar):
105105
numerator = property(numer)
106106
denominator = property(denom)
107107

108+
def __reduce__(self):
109+
return (fmpq, (int(self.p), int(self.q)))
110+
108111
def repr(self):
109112
if self.q == 1:
110113
return "fmpq(%s)" % self.p

src/flint/fmpz.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ cdef class fmpz(flint_scalar):
9999
def denominator(self):
100100
return fmpz(1)
101101

102+
def __reduce__(self):
103+
return (fmpz, (int(self),))
104+
102105
# XXX: improve!
103106
def __int__(self):
104107
return fmpz_get_intlong(self.val)

0 commit comments

Comments
 (0)