From f95331004542b4ca2673cdf02cf32beb1c73063c Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 8 Feb 2017 11:01:55 -0500 Subject: small speedup --- pyisda/curve.pyx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index de64437..57f7ecd 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -47,7 +47,7 @@ cdef class Curve(object): contains `base_date`, `basis`, `day_count_counvention` and `data` """ - return {'base_date': TDate_to_pydate(self._thisptr.fBaseDate), + return {'base_date': self.base_date, 'basis': self._thisptr.fBasis, 'day_count_convention': dcc_tostring(self._thisptr.fDayCountConv), 'data': fArray_to_list(self._thisptr.fArray, self._thisptr.fNumItems)} @@ -252,7 +252,8 @@ cdef class SpreadCurve(Curve): Default to True """ - + @cython.boundscheck(False) + @cython.wraparound(False) def __init__(self, today, YieldCurve yc, start_date, step_in_date, cash_settle_date, list end_dates, double[:] coupon_rates, double[:] upfront_rates, @@ -266,9 +267,9 @@ cdef class SpreadCurve(Curve): cdef TDate* end_dates_c = malloc(n_dates * sizeof(TDate)) self._thisptr = NULL cdef size_t i - if cash_settle_date < yc.inspect()['base_date']: + if cash_settle_date_c < yc._thisptr.fBaseDate: raise ValueError("cash_settle_date: {0} is anterior to yc's base_date: {1}". - format(cash_settle_date, yc.inspect()['base_date'])) + format(cash_settle_date, yc.base_date)) for i, d in enumerate(end_dates): end_dates_c[i] = pydate_to_TDate(d) @@ -277,7 +278,7 @@ cdef class SpreadCurve(Curve): raise ValueError("can't convert stub") cdef long dc JpmcdsStringToDayCountConv('ACT/360', &dc) - with nogil, cython.boundscheck(False): + with nogil: self._thisptr = JpmcdsCleanSpreadCurve(today_c, yc._thisptr, start_date_c, -- cgit v1.2.3-70-g09d2