diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2017-04-13 11:18:45 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2017-04-13 11:20:36 -0400 |
| commit | 6640f53b9d25b041dfa410579119df4910fd915d (patch) | |
| tree | 73db2e76ef2235bb7a293d0a6094e1fcc03ad0e1 | |
| parent | ffbfca8e1117cb7ffe7515bcb14970c29694a8dd (diff) | |
| download | pyisda-6640f53b9d25b041dfa410579119df4910fd915d.tar.gz | |
add __hash__ method
| -rw-r--r-- | pyisda/curve.pyx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index cbe2174..730e066 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -34,7 +34,7 @@ cdef class Curve(object): def __getstate__(self): cdef TCurve* curve = self._thisptr.get() - cdef int num_items = curve.fNumItems; + cdef int num_items = curve.fNumItems return (num_items, <bytes>(<char*>curve.fArray)[:sizeof(TRatePt)*num_items], curve.fBaseDate, @@ -59,6 +59,15 @@ cdef class Curve(object): new_curve.fDayCountConv = dcc self._thisptr = make_shared(new_curve) + def __hash__(self): + cdef TCurve* curve = self._thisptr.get() + cdef int num_items = curve.fNumItems + return hash((num_items, + <bytes>(<char*>curve.fArray)[:sizeof(TRatePt)*num_items], + curve.fBaseDate, + curve.fBasis, + curve.fDayCountConv)) + def inspect(self): """ method to inspect the content of the C struct |
