/* Generated by Cython 0.24.1 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_24_1"
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
  #define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
typedef struct {
    unaryfunc am_await;
    unaryfunc am_aiter;
    unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)

#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif


#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}

#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__pandas___period
#define __PYX_HAVE_API__pandas___period
#include "string.h"
#include "stdio.h"
#include "pythread.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "datetime_helper.h"
#include "headers/stdint.h"
#include "datetime.h"
#include "numpy/ndarrayobject.h"
#include "numpy_helper.h"
#include "numpy/npy_common.h"
#include "datetime/np_datetime.h"
#include "datetime/np_datetime_strings.h"
#include "period_helper.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

/* None.proto */
#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "pandas/src/period.pyx",
  "pandas/src/util.pxd",
  "pandas/src/datetime.pxd",
  "pandas/src/numpy.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};
/* BufferFormatStructs.proto */
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name;
  struct __Pyx_StructField_* fields;
  size_t size;
  size_t arraysize[8];
  int ndim;
  char typegroup;
  char is_unsigned;
  int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;
typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  size_t new_count, enc_count;
  size_t struct_alignment;
  int is_complex;
  char enc_type;
  char new_packmode;
  char enc_packmode;
  char is_valid_array;
} __Pyx_BufFmt_Context;


/* "numpy.pxd":726
 * # in Cython to enable them only on the right systems.
 * 
 * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 */
typedef npy_int8 __pyx_t_5numpy_int8_t;

/* "numpy.pxd":727
 * 
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t
 */
typedef npy_int16 __pyx_t_5numpy_int16_t;

/* "numpy.pxd":728
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int64      int64_t
 * #ctypedef npy_int96      int96_t
 */
typedef npy_int32 __pyx_t_5numpy_int32_t;

/* "numpy.pxd":729
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_int96      int96_t
 * #ctypedef npy_int128     int128_t
 */
typedef npy_int64 __pyx_t_5numpy_int64_t;

/* "numpy.pxd":733
 * #ctypedef npy_int128     int128_t
 * 
 * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 */
typedef npy_uint8 __pyx_t_5numpy_uint8_t;

/* "numpy.pxd":734
 * 
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t
 */
typedef npy_uint16 __pyx_t_5numpy_uint16_t;

/* "numpy.pxd":735
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint64     uint64_t
 * #ctypedef npy_uint96     uint96_t
 */
typedef npy_uint32 __pyx_t_5numpy_uint32_t;

/* "numpy.pxd":736
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_uint96     uint96_t
 * #ctypedef npy_uint128    uint128_t
 */
typedef npy_uint64 __pyx_t_5numpy_uint64_t;

/* "numpy.pxd":740
 * #ctypedef npy_uint128    uint128_t
 * 
 * ctypedef npy_float16    float16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t
 */
typedef npy_float16 __pyx_t_5numpy_float16_t;

/* "numpy.pxd":741
 * 
 * ctypedef npy_float16    float16_t
 * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float64    float64_t
 * #ctypedef npy_float80    float80_t
 */
typedef npy_float32 __pyx_t_5numpy_float32_t;

/* "numpy.pxd":742
 * ctypedef npy_float16    float16_t
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_float80    float80_t
 * #ctypedef npy_float128   float128_t
 */
typedef npy_float64 __pyx_t_5numpy_float64_t;

/* "numpy.pxd":751
 * # The int types are mapped a bit surprising --
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t
 */
typedef npy_long __pyx_t_5numpy_int_t;

/* "numpy.pxd":752
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   longlong_t
 * 
 */
typedef npy_longlong __pyx_t_5numpy_long_t;

/* "numpy.pxd":753
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_ulong      uint_t
 */
typedef npy_longlong __pyx_t_5numpy_longlong_t;

/* "numpy.pxd":755
 * ctypedef npy_longlong   longlong_t
 * 
 * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t
 */
typedef npy_ulong __pyx_t_5numpy_uint_t;

/* "numpy.pxd":756
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "numpy.pxd":757
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_intp       intp_t
 */
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;

/* "numpy.pxd":759
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "numpy.pxd":760
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "numpy.pxd":762
 * ctypedef npy_uintp      uintp_t
 * 
 * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t
 */
typedef npy_double __pyx_t_5numpy_float_t;

/* "numpy.pxd":763
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "numpy.pxd":764
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cfloat      cfloat_t
 */
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
/* None.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif

/* None.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif


/*--- Type declarations ---*/
struct __pyx_obj_6pandas_7_period__Period;

/* "numpy.pxd":766
 * ctypedef npy_longdouble longdouble_t
 * 
 * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t
 */
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

/* "numpy.pxd":767
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "numpy.pxd":768
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cdouble     complex_t
 */
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "numpy.pxd":770
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_opt_args_6pandas_7_period_resolution;

/* "pandas/src/period.pyx":403
 * # period accessors
 * 
 * ctypedef int (*accessor)(int64_t ordinal, int freq) except INT32_MIN             # <<<<<<<<<<<<<<
 * 
 * 
 */
typedef int (*__pyx_t_6pandas_7_period_accessor)(__pyx_t_5numpy_int64_t, int);

/* "pandas/src/period.pyx":515
 * 
 * 
 * cpdef resolution(ndarray[int64_t] stamps, tz=None):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(stamps)
 */
struct __pyx_opt_args_6pandas_7_period_resolution {
  int __pyx_n;
  PyObject *tz;
};

/* "pandas/src/period.pyx":690
 * 
 * 
 * cdef class _Period(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef public:
 */
struct __pyx_obj_6pandas_7_period__Period {
  PyObject_HEAD
  struct __pyx_vtabstruct_6pandas_7_period__Period *__pyx_vtab;
  __pyx_t_5numpy_int64_t ordinal;
  PyObject *freq;
};



struct __pyx_vtabstruct_6pandas_7_period__Period {
  PyObject *(*_field)(struct __pyx_obj_6pandas_7_period__Period *, PyObject *);
};
static struct __pyx_vtabstruct_6pandas_7_period__Period *__pyx_vtabptr_6pandas_7_period__Period;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* None.proto */
static CYTHON_INLINE __pyx_t_5numpy_int64_t __Pyx_div___pyx_t_5numpy_int64_t(__pyx_t_5numpy_int64_t, __pyx_t_5numpy_int64_t);

/* UnaryNegOverflows.proto */
#define UNARY_NEG_WOULD_OVERFLOW(x)\
        (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))

/* PyThreadStateGet.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_GET();
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* ArgTypeTest.proto */
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact);

/* BufferFormatCheck.proto */
static CYTHON_INLINE int  __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type); // PROTO

/* GetModuleGlobalName.proto */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* BufferFallbackError.proto */
static void __Pyx_RaiseBufferFallbackError(void);

#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* BufferIndexError.proto */
static void __Pyx_RaiseBufferIndexError(int axis);

/* None.proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* None.proto */
static CYTHON_INLINE long __Pyx_mod_long(long, long);

/* None.proto */
static CYTHON_INLINE __pyx_t_5numpy_int64_t __Pyx_mod___pyx_t_5numpy_int64_t(__pyx_t_5numpy_int64_t, __pyx_t_5numpy_int64_t);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

/* SaveResetException.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetException.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyIntFromDouble.proto */
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value);
#else
#define __Pyx_PyInt_FromDouble(value) PyLong_FromDouble(value)
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

/* PyObjectSetAttrStr.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_RemainderObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceRemainder(op1, op2) : PyNumber_Remainder(op1, op2))
#endif

/* dict_getitem_default.proto */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* GetNameInClass.proto */
static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunction.proto */
#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* BufferStructDeclare.proto */
typedef struct {
  Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
  size_t refcount;
  Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
  __Pyx_Buffer *rcbuffer;
  char *data;
  __Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;

#if PY_MAJOR_VERSION < 3
    static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
    static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
    #define __Pyx_GetBuffer PyObject_GetBuffer
    #define __Pyx_ReleaseBuffer PyBuffer_Release
#endif


/* None.proto */
static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int64(npy_int64 value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int32(npy_int32 value);

/* ClassMethod.proto */
#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method);

/* None.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(__cplusplus) && CYTHON_CCOMPLEX         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

/* None.proto */
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

/* None.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eqf(a, b)   ((a)==(b))
    #define __Pyx_c_sumf(a, b)  ((a)+(b))
    #define __Pyx_c_difff(a, b) ((a)-(b))
    #define __Pyx_c_prodf(a, b) ((a)*(b))
    #define __Pyx_c_quotf(a, b) ((a)/(b))
    #define __Pyx_c_negf(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zerof(z) ((z)==(float)0)
    #define __Pyx_c_conjf(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_absf(z)     (::std::abs(z))
        #define __Pyx_c_powf(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zerof(z) ((z)==0)
    #define __Pyx_c_conjf(z)    (conjf(z))
    #if 1
        #define __Pyx_c_absf(z)     (cabsf(z))
        #define __Pyx_c_powf(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

/* None.proto */
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);

/* None.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq(a, b)   ((a)==(b))
    #define __Pyx_c_sum(a, b)  ((a)+(b))
    #define __Pyx_c_diff(a, b) ((a)-(b))
    #define __Pyx_c_prod(a, b) ((a)*(b))
    #define __Pyx_c_quot(a, b) ((a)/(b))
    #define __Pyx_c_neg(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero(z) ((z)==(double)0)
    #define __Pyx_c_conj(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (::std::abs(z))
        #define __Pyx_c_pow(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero(z) ((z)==0)
    #define __Pyx_c_conj(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (cabs(z))
        #define __Pyx_c_pow(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ptrdiff_t(ptrdiff_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE npy_int64 __Pyx_PyInt_As_npy_int64(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* PyIdentifierFromString.proto */
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

/* ModuleImport.proto */
static PyObject *__Pyx_ImportModule(const char *name);

/* TypeImport.proto */
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);

/* VoidPtrImport.proto */
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_6pandas_7_period_7_Period__field(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_alias); /* proto*/

/* Module declarations from 'cpython.version' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'numpy' */

/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/

/* Module declarations from 'cython' */

/* Module declarations from 'datetime' */

/* Module declarations from 'datetime' */
static PyTypeObject *__pyx_ptype_8datetime_date = 0;
static PyTypeObject *__pyx_ptype_8datetime_datetime = 0;
static PyTypeObject *__pyx_ptype_8datetime_timedelta = 0;
static CYTHON_INLINE int __pyx_f_8datetime__cstring_to_dts(char *, int, pandas_datetimestruct *, int *, int *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_8datetime__dts_to_pydatetime(pandas_datetimestruct *); /*proto*/

/* Module declarations from 'util' */
static CYTHON_INLINE PyObject *__pyx_f_4util_set_value_at_unsafe(PyArrayObject *, PyObject *, PyObject *); /*proto*/

/* Module declarations from 'pandas.lib' */
static int (*__pyx_f_6pandas_3lib_is_null_datetimelike)(PyObject *); /*proto*/
static int (*__pyx_f_6pandas_3lib_is_period)(PyObject *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'pandas.tslib' */
static int (*__pyx_vp_6pandas_5tslib__nat_scalar_rules)[6] = 0;
#define __pyx_v_6pandas_5tslib__nat_scalar_rules (*__pyx_vp_6pandas_5tslib__nat_scalar_rules)
static PyObject *(*__pyx_f_6pandas_5tslib_maybe_get_tz)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_6pandas_5tslib__is_utc)(PyObject *); /*proto*/
static int (*__pyx_f_6pandas_5tslib__is_tzlocal)(PyObject *); /*proto*/
static PyObject *(*__pyx_f_6pandas_5tslib__get_dst_info)(PyObject *); /*proto*/

/* Module declarations from 'pandas._period' */
static PyTypeObject *__pyx_ptype_6pandas_7_period__Period = 0;
static int __pyx_v_6pandas_7_period_PY2;
static __pyx_t_5numpy_int64_t __pyx_v_6pandas_7_period_NPY_NAT;
static int __pyx_v_6pandas_7_period_US_RESO;
static int __pyx_v_6pandas_7_period_MS_RESO;
static int __pyx_v_6pandas_7_period_S_RESO;
static int __pyx_v_6pandas_7_period_T_RESO;
static int __pyx_v_6pandas_7_period_H_RESO;
static int __pyx_v_6pandas_7_period_D_RESO;
static char __pyx_v_6pandas_7_period_START;
static char __pyx_v_6pandas_7_period_END;
static PyObject *__pyx_v_6pandas_7_period_extra_fmts = 0;
static PyObject *__pyx_v_6pandas_7_period_str_extra_fmts = 0;
static __pyx_t_5numpy_int64_t __pyx_f_6pandas_7_period_period_asfreq(__pyx_t_5numpy_int64_t, int, int, int, int __pyx_skip_dispatch); /*proto*/
static __pyx_t_5numpy_int64_t __pyx_f_6pandas_7_period_period_ordinal_to_dt64(__pyx_t_5numpy_int64_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_6pandas_7_period__period_strftime(__pyx_t_5numpy_int64_t, int, PyObject *); /*proto*/
static __pyx_t_6pandas_7_period_accessor __pyx_f_6pandas_7_period__get_accessor_func(int); /*proto*/
static PyObject *__pyx_f_6pandas_7_period_resolution(PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6pandas_7_period_resolution *__pyx_optional_args); /*proto*/
static CYTHON_INLINE int __pyx_f_6pandas_7_period__reso_stamp(pandas_datetimestruct *); /*proto*/
static PyObject *__pyx_f_6pandas_7_period__reso_local(PyArrayObject *, PyObject *); /*proto*/
static PyArrayObject *__pyx_f_6pandas_7_period_localize_dt64arr_to_period(PyArrayObject *, int, PyObject *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t = { "int64_t", NULL, sizeof(__pyx_t_5numpy_int64_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int64_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int64_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_object = { "Python object", NULL, sizeof(PyObject *), { 0 }, 0, 'O', 0, 0 };
#define __Pyx_MODULE_NAME "pandas._period"
int __pyx_module_is_main_pandas___period = 0;

/* Implementation of 'pandas._period' */
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_RuntimeError;
static const char __pyx_k_E[] = "E";
static const char __pyx_k_F[] = "%F";
static const char __pyx_k_S[] = "S";
static const char __pyx_k_Y[] = "%Y";
static const char __pyx_k_d[] = "d";
static const char __pyx_k_f[] = "%f";
static const char __pyx_k_h[] = "h";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_l[] = "l";
static const char __pyx_k_m[] = "m";
static const char __pyx_k_n[] = "n";
static const char __pyx_k_p[] = "p";
static const char __pyx_k_q[] = "%q";
static const char __pyx_k_s[] = "s";
static const char __pyx_k_u[] = "%u";
static const char __pyx_k_y[] = "y";
static const char __pyx_k_2d[] = "%.2d";
static const char __pyx_k_AB[] = "^`AB`^";
static const char __pyx_k_CD[] = "^`CD`^";
static const char __pyx_k_EF[] = "^`EF`^";
static const char __pyx_k_GH[] = "^`GH`^";
static const char __pyx_k_IJ[] = "^`IJ`^";
static const char __pyx_k_KL[] = "^`KL`^";
static const char __pyx_k_dt[] = "dt";
static const char __pyx_k_i8[] = "i8";
static const char __pyx_k_np[] = "np";
static const char __pyx_k_ps[] = "ps";
static const char __pyx_k_sz[] = "sz";
static const char __pyx_k_tz[] = "tz";
static const char __pyx_k_us[] = "us";
static const char __pyx_k_03d[] = "%03d";
static const char __pyx_k_06d[] = "%06d";
static const char __pyx_k_09d[] = "%09d";
static const char __pyx_k_END[] = "END";
static const char __pyx_k_NaT[] = "NaT";
static const char __pyx_k_Y_m[] = "%Y-%m";
static const char __pyx_k__51[] = "_";
static const char __pyx_k_any[] = "any";
static const char __pyx_k_arr[] = "arr";
static const char __pyx_k_cls[] = "cls";
static const char __pyx_k_d_2[] = "%d";
static const char __pyx_k_day[] = "day";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_dts[] = "dts";
static const char __pyx_k_end[] = "end";
static const char __pyx_k_f_2[] = "f";
static const char __pyx_k_fmt[] = "fmt";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_how[] = "how";
static const char __pyx_k_inf[] = "inf";
static const char __pyx_k_l_2[] = "%l";
static const char __pyx_k_lib[] = "lib";
static const char __pyx_k_min[] = "min";
static const char __pyx_k_msg[] = "msg";
static const char __pyx_k_n_2[] = "%n";
static const char __pyx_k_nan[] = "nan";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_now[] = "now";
static const char __pyx_k_out[] = "out";
static const char __pyx_k_s_2[] = "%s";
static const char __pyx_k_s_s[] = "%s/%s";
static const char __pyx_k_sub[] = "__sub__";
static const char __pyx_k_sys[] = "sys";
static const char __pyx_k_typ[] = "_typ";
static const char __pyx_k_val[] = "val";
static const char __pyx_k_FQ_q[] = "%FQ%q";
static const char __pyx_k_Tick[] = "Tick";
static const char __pyx_k_base[] = "base";
static const char __pyx_k_code[] = "code";
static const char __pyx_k_date[] = "date";
static const char __pyx_k_freq[] = "freq";
static const char __pyx_k_func[] = "func";
static const char __pyx_k_hour[] = "hour";
static const char __pyx_k_iNaT[] = "iNaT";
static const char __pyx_k_left[] = "left";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mask[] = "mask";
static const char __pyx_k_mnum[] = "mnum";
static const char __pyx_k_mult[] = "mult";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_pytz[] = "pytz";
static const char __pyx_k_reso[] = "reso";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_side[] = "side";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_year[] = "year";
static const char __pyx_k_BEGIN[] = "BEGIN";
static const char __pyx_k_START[] = "START";
static const char __pyx_k_Y_m_d[] = "%Y-%m-%d";
static const char __pyx_k_dtarr[] = "dtarr";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_empty[] = "empty";
static const char __pyx_k_finfo[] = "finfo";
static const char __pyx_k_freq1[] = "freq1";
static const char __pyx_k_freq2[] = "freq2";
static const char __pyx_k_int64[] = "int64";
static const char __pyx_k_month[] = "month";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_other[] = "other";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_right[] = "right";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_tslib[] = "tslib";
static const char __pyx_k_upper[] = "upper";
static const char __pyx_k_utf_8[] = "utf-8";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_D_RESO[] = "D_RESO";
static const char __pyx_k_FINISH[] = "FINISH";
static const char __pyx_k_H_RESO[] = "H_RESO";
static const char __pyx_k_Period[] = "Period";
static const char __pyx_k_S_RESO[] = "S_RESO";
static const char __pyx_k_T_RESO[] = "T_RESO";
static const char __pyx_k_asfreq[] = "asfreq";
static const char __pyx_k_astype[] = "astype";
static const char __pyx_k_compat[] = "compat";
static const char __pyx_k_decode[] = "decode";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_ignore[] = "ignore";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_minute[] = "minute";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_name_2[] = "name";
static const char __pyx_k_pandas[] = "pandas";
static const char __pyx_k_period[] = "period";
static const char __pyx_k_result[] = "result";
static const char __pyx_k_second[] = "second";
static const char __pyx_k_stamps[] = "stamps";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_MS_RESO[] = "MS_RESO";
static const char __pyx_k_US_RESO[] = "US_RESO";
static const char __pyx_k_freqstr[] = "freqstr";
static const char __pyx_k_offsets[] = "offsets";
static const char __pyx_k_ordinal[] = "ordinal";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_quarter[] = "quarter";
static const char __pyx_k_replace[] = "replace";
static const char __pyx_k_unicode[] = "__unicode__";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_datetime[] = "datetime";
static const char __pyx_k_dateutil[] = "dateutil";
static const char __pyx_k_get_freq[] = "get_freq";
static const char __pyx_k_how_dict[] = "how_dict";
static const char __pyx_k_operator[] = "operator";
static const char __pyx_k_ordinals[] = "ordinals";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_relation[] = "relation";
static const char __pyx_k_Exception[] = "Exception";
static const char __pyx_k_Timedelta[] = "Timedelta";
static const char __pyx_k_Timestamp[] = "Timestamp";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_Y_m_d_H_M[] = "%Y-%m-%d %H:%M";
static const char __pyx_k_add_delta[] = "_add_delta";
static const char __pyx_k_converted[] = "converted";
static const char __pyx_k_dayofweek[] = "dayofweek";
static const char __pyx_k_have_pytz[] = "have_pytz";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_periodarr[] = "periodarr";
static const char __pyx_k_rule_code[] = "rule_code";
static const char __pyx_k_timedelta[] = "timedelta";
static const char __pyx_k_to_offset[] = "to_offset";
static const char __pyx_k_DateOffset[] = "DateOffset";
static const char __pyx_k_IndexError[] = "IndexError";
static const char __pyx_k_Period_s_s[] = "Period('%s', '%s')";
static const char __pyx_k_Resolution[] = "Resolution";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_Y_m_d_H_00[] = "%Y-%m-%d %H:00";
static const char __pyx_k_datetime64[] = "datetime64";
static const char __pyx_k_freq_group[] = "freq_group";
static const char __pyx_k_is_integer[] = "is_integer";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_start_time[] = "start_time";
static const char __pyx_k_weekofyear[] = "weekofyear";
static const char __pyx_k_Y_m_d_H_M_S[] = "%Y-%m-%d %H:%M:%S";
static const char __pyx_k_comparables[] = "_comparables";
static const char __pyx_k_frequencies[] = "frequencies";
static const char __pyx_k_microsecond[] = "microsecond";
static const char __pyx_k_nat_strings[] = "_nat_strings";
static const char __pyx_k_periodindex[] = "periodindex";
static const char __pyx_k_timedelta64[] = "timedelta64";
static const char __pyx_k_Period___new[] = "Period.__new__";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_extract_freq[] = "extract_freq";
static const char __pyx_k_from_ordinal[] = "_from_ordinal";
static const char __pyx_k_get_freq_str[] = "_get_freq_str";
static const char __pyx_k_searchsorted[] = "searchsorted";
static const char __pyx_k_string_types[] = "string_types";
static const char __pyx_k_to_timestamp[] = "to_timestamp";
static const char __pyx_k_version_info[] = "version_info";
static const char __pyx_k_Y_m_d_H_M_S_l[] = "%Y-%m-%d %H:%M:%S.%l";
static const char __pyx_k_Y_m_d_H_M_S_n[] = "%Y-%m-%d %H:%M:%S.%n";
static const char __pyx_k_Y_m_d_H_M_S_u[] = "%Y-%m-%d %H:%M:%S.%u";
static const char __pyx_k_days_in_month[] = "days_in_month";
static const char __pyx_k_get_freq_code[] = "get_freq_code";
static const char __pyx_k_get_utcoffset[] = "_get_utcoffset";
static const char __pyx_k_month_numbers[] = "_month_numbers";
static const char __pyx_k_period_format[] = "period_format";
static const char __pyx_k_AttributeError[] = "AttributeError";
static const char __pyx_k_DIFFERENT_FREQ[] = "_DIFFERENT_FREQ";
static const char __pyx_k_NotImplemented[] = "NotImplemented";
static const char __pyx_k_Unknown_freq_d[] = "Unknown freq: %d";
static const char __pyx_k_get_base_alias[] = "get_base_alias";
static const char __pyx_k_get_rule_month[] = "_get_rule_month";
static const char __pyx_k_pandas__period[] = "pandas._period";
static const char __pyx_k_pandas_tseries[] = "pandas.tseries";
static const char __pyx_k_period_ordinal[] = "period_ordinal";
static const char __pyx_k_extract_ordinals[] = "extract_ordinals";
static const char __pyx_k_get_period_field[] = "get_period_field";
static const char __pyx_k_quarter_to_myear[] = "_quarter_to_myear";
static const char __pyx_k_Unable_to_parse_s[] = "Unable to parse %s";
static const char __pyx_k_parse_time_string[] = "parse_time_string";
static const char __pyx_k_period_asfreq_arr[] = "period_asfreq_arr";
static const char __pyx_k_maybe_convert_freq[] = "_maybe_convert_freq";
static const char __pyx_k_validate_end_alias[] = "_validate_end_alias";
static const char __pyx_k_index_out_of_bounds[] = "index out of bounds";
static const char __pyx_k_ordinal_from_fields[] = "_ordinal_from_fields";
static const char __pyx_k_DIFFERENT_FREQ_INDEX[] = "_DIFFERENT_FREQ_INDEX";
static const char __pyx_k_delta_to_nanoseconds[] = "_delta_to_nanoseconds";
static const char __pyx_k_dt64arr_to_periodarr[] = "dt64arr_to_periodarr";
static const char __pyx_k_get_period_field_arr[] = "get_period_field_arr";
static const char __pyx_k_pandas_tseries_tools[] = "pandas.tseries.tools";
static const char __pyx_k_periodarr_to_dt64arr[] = "periodarr_to_dt64arr";
static const char __pyx_k_IncompatibleFrequency[] = "IncompatibleFrequency";
static const char __pyx_k_Quarter_must_be_1_q_4[] = "Quarter must be 1 <= q <= 4";
static const char __pyx_k_get_to_timestamp_base[] = "get_to_timestamp_base";
static const char __pyx_k_Period_strftime_line_980[] = "_Period.strftime (line 980)";
static const char __pyx_k_How_must_be_one_of_S_or_E[] = "How must be one of S or E";
static const char __pyx_k_Could_not_find_pytz_module[] = "Could not find pytz module";
static const char __pyx_k_Ordinal_must_be_an_integer[] = "Ordinal must be an integer";
static const char __pyx_k_Unrecognized_period_code_d[] = "Unrecognized period code: %d";
static const char __pyx_k_Frequency_conversion_failed[] = "Frequency conversion failed";
static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static const char __pyx_k_Unable_to_get_quarter_and_year[] = "Unable to get quarter and year";
static const char __pyx_k_home_joris_scipy_pandas_pandas[] = "/home/joris/scipy/pandas/pandas/src/period.pyx";
static const char __pyx_k_Cannot_compare_type_r_with_type[] = "Cannot compare type %r with type %r";
static const char __pyx_k_If_value_is_None_freq_cannot_be[] = "If value is None, freq cannot be None";
static const char __pyx_k_Input_has_different_freq_1_from[] = "Input has different freq={1} from Period(freq={0})";
static const char __pyx_k_Represents_an_period_of_time_Pa[] = "\n    Represents an period of time\n\n    Parameters\n    ----------\n    value : Period or compat.string_types, default None\n        The time period represented (e.g., '4Q2005')\n    freq : str, default None\n        One of pandas period strings or corresponding objects\n    year : int, default None\n    month : int, default 1\n    quarter : int, default None\n    day : int, default 1\n    hour : int, default 0\n    minute : int, default 0\n    second : int, default 0\n    ";
static const char __pyx_k_Returns_the_string_representati[] = "\n        Returns the string representation of the :class:`Period`, depending\n        on the selected :keyword:`format`. :keyword:`format` must be a string\n        containing one or several directives.  The method recognizes the same\n        directives as the :func:`time.strftime` function of the standard Python\n        distribution, as well as the specific additional directives ``%f``,\n        ``%F``, ``%q``. (formatting & docs originally from scikits.timeries)\n\n        +-----------+--------------------------------+-------+\n        | Directive | Meaning                        | Notes |\n        +===========+================================+=======+\n        | ``%a``    | Locale's abbreviated weekday   |       |\n        |           | name.                          |       |\n        +-----------+--------------------------------+-------+\n        | ``%A``    | Locale's full weekday name.    |       |\n        +-----------+--------------------------------+-------+\n        | ``%b``    | Locale's abbreviated month     |       |\n        |           | name.                          |       |\n        +-----------+--------------------------------+-------+\n        | ``%B``    | Locale's full month name.      |       |\n        +-----------+--------------------------------+-------+\n        | ``%c``    | Locale's appropriate date and  |       |\n        |           | time representation.           |       |\n        +-----------+--------------------------------+-------+\n        | ``%d``    | Day of the month as a decimal  |       |\n        |           | number [01,31].                |       |\n        +-----------+--------------------------------+-------+\n        | ``%f``    | 'Fiscal' year without a        | \\(1)  |\n        |           | century  as a decimal number   |       |\n        |           | [00,99]                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%F``    | 'Fiscal' year with a century  "" | \\(2)  |\n        |           | as a decimal number            |       |\n        +-----------+--------------------------------+-------+\n        | ``%H``    | Hour (24-hour clock) as a      |       |\n        |           | decimal number [00,23].        |       |\n        +-----------+--------------------------------+-------+\n        | ``%I``    | Hour (12-hour clock) as a      |       |\n        |           | decimal number [01,12].        |       |\n        +-----------+--------------------------------+-------+\n        | ``%j``    | Day of the year as a decimal   |       |\n        |           | number [001,366].              |       |\n        +-----------+--------------------------------+-------+\n        | ``%m``    | Month as a decimal number      |       |\n        |           | [01,12].                       |       |\n        +-----------+--------------------------------+-------+\n        | ``%M``    | Minute as a decimal number     |       |\n        |           | [00,59].                       |       |\n        +-----------+--------------------------------+-------+\n        | ``%p``    | Locale's equivalent of either  | \\(3)  |\n        |           | AM or PM.                      |       |\n        +-----------+--------------------------------+-------+\n        | ``%q``    | Quarter as a decimal number    |       |\n        |           | [01,04]                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%S``    | Second as a decimal number     | \\(4)  |\n        |           | [00,61].                       |       |\n        +-----------+--------------------------------+-------+\n        | ``%U``    | Week number of the year        | \\(5)  |\n        |           | (Sunday as the first day of    |       |\n        |           | the week) as a decimal number  |       |\n        |           | [00,53].  All days in a new    |       |\n        |           | year preceding the first       |       |""\n        |           | Sunday are considered to be in |       |\n        |           | week 0.                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%w``    | Weekday as a decimal number    |       |\n        |           | [0(Sunday),6].                 |       |\n        +-----------+--------------------------------+-------+\n        | ``%W``    | Week number of the year        | \\(5)  |\n        |           | (Monday as the first day of    |       |\n        |           | the week) as a decimal number  |       |\n        |           | [00,53].  All days in a new    |       |\n        |           | year preceding the first       |       |\n        |           | Monday are considered to be in |       |\n        |           | week 0.                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%x``    | Locale's appropriate date      |       |\n        |           | representation.                |       |\n        +-----------+--------------------------------+-------+\n        | ``%X``    | Locale's appropriate time      |       |\n        |           | representation.                |       |\n        +-----------+--------------------------------+-------+\n        | ``%y``    | Year without century as a      |       |\n        |           | decimal number [00,99].        |       |\n        +-----------+--------------------------------+-------+\n        | ``%Y``    | Year with century as a decimal |       |\n        |           | number.                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%Z``    | Time zone name (no characters  |       |\n        |           | if no time zone exists).       |       |\n        +-----------+--------------------------------+-------+\n        | ``%%``    | A literal ``'%'`` character.   |       |\n        +-----------+--------------------------------+-------+\n\n        .. ""note::\n\n            (1)\n                The ``%f`` directive is the same as ``%y`` if the frequency is\n                not quarterly.\n                Otherwise, it corresponds to the 'fiscal' year, as defined by\n                the :attr:`qyear` attribute.\n\n            (2)\n                The ``%F`` directive is the same as ``%Y`` if the frequency is\n                not quarterly.\n                Otherwise, it corresponds to the 'fiscal' year, as defined by\n                the :attr:`qyear` attribute.\n\n            (3)\n                The ``%p`` directive only affects the output hour field\n                if the ``%I`` directive is used to parse the hour.\n\n            (4)\n                The range really is ``0`` to ``61``; this accounts for leap\n                seconds and the (very rare) double leap seconds.\n\n            (5)\n                The ``%U`` and ``%W`` directives are only used in calculations\n                when the day of the week and the year are specified.\n\n        .. rubric::  Examples\n\n            >>> a = Period(freq='Q@JUL', year=2006, quarter=1)\n            >>> a.strftime('%F-Q%q')\n            '2006-Q1'\n            >>> # Output the last month in the quarter of this date\n            >>> a.strftime('%b-%Y')\n            'Oct-2005'\n            >>>\n            >>> a = Period(freq='D', year=2001, month=1, day=1)\n            >>> a.strftime('%d-%b-%Y')\n            '01-Jan-2006'\n            >>> a.strftime('%b. %d, %Y was a %A')\n            'Jan. 01, 2001 was a Monday'\n        ";
static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static const char __pyx_k_Frequency_must_be_positive_becau[] = "Frequency must be positive, because it represents span: {0}";
static const char __pyx_k_Input_cannot_be_converted_to_Per[] = "Input cannot be converted to Period(freq={0})";
static const char __pyx_k_Invalid_frequency_or_could_not_i[] = "Invalid frequency or could not infer: %s";
static const char __pyx_k_Must_supply_freq_for_datetime_va[] = "Must supply freq for datetime value";
static const char __pyx_k_Must_supply_freq_for_ordinal_val[] = "Must supply freq for ordinal value";
static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
static const char __pyx_k_Only_value_or_ordinal_but_not_bo[] = "Only value or ordinal but not both should be given but not both";
static const char __pyx_k_Unable_to_convert_to_desired_fre[] = "Unable to convert to desired frequency.";
static const char __pyx_k_Value_must_be_Period_string_inte[] = "Value must be Period, string, integer, or datetime";
static const char __pyx_k_assignment_destination_is_read_o[] = "assignment destination is read-only";
static const char __pyx_k_freq_not_specified_and_cannot_be[] = "freq not specified and cannot be inferred";
static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static const char __pyx_k_Input_has_different_freq_1_from_2[] = "Input has different freq={1} from PeriodIndex(freq={0})";
static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static PyObject *__pyx_kp_s_03d;
static PyObject *__pyx_kp_s_06d;
static PyObject *__pyx_kp_s_09d;
static PyObject *__pyx_kp_s_2d;
static PyObject *__pyx_kp_b_AB;
static PyObject *__pyx_kp_s_AB;
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_n_s_BEGIN;
static PyObject *__pyx_kp_b_CD;
static PyObject *__pyx_kp_s_CD;
static PyObject *__pyx_kp_s_Cannot_compare_type_r_with_type;
static PyObject *__pyx_kp_s_Could_not_find_pytz_module;
static PyObject *__pyx_n_s_DIFFERENT_FREQ;
static PyObject *__pyx_n_s_DIFFERENT_FREQ_INDEX;
static PyObject *__pyx_n_s_D_RESO;
static PyObject *__pyx_n_s_DateOffset;
static PyObject *__pyx_n_s_E;
static PyObject *__pyx_kp_b_EF;
static PyObject *__pyx_kp_s_EF;
static PyObject *__pyx_n_s_END;
static PyObject *__pyx_n_s_Exception;
static PyObject *__pyx_kp_b_F;
static PyObject *__pyx_n_s_FINISH;
static PyObject *__pyx_kp_b_FQ_q;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
static PyObject *__pyx_kp_s_Frequency_conversion_failed;
static PyObject *__pyx_kp_s_Frequency_must_be_positive_becau;
static PyObject *__pyx_kp_b_GH;
static PyObject *__pyx_kp_s_GH;
static PyObject *__pyx_n_s_H_RESO;
static PyObject *__pyx_kp_s_How_must_be_one_of_S_or_E;
static PyObject *__pyx_kp_b_IJ;
static PyObject *__pyx_kp_s_IJ;
static PyObject *__pyx_kp_s_If_value_is_None_freq_cannot_be;
static PyObject *__pyx_n_s_IncompatibleFrequency;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_s_Input_cannot_be_converted_to_Per;
static PyObject *__pyx_kp_s_Input_has_different_freq_1_from;
static PyObject *__pyx_kp_s_Input_has_different_freq_1_from_2;
static PyObject *__pyx_kp_s_Invalid_frequency_or_could_not_i;
static PyObject *__pyx_kp_b_KL;
static PyObject *__pyx_kp_s_KL;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_MS_RESO;
static PyObject *__pyx_kp_s_Must_supply_freq_for_datetime_va;
static PyObject *__pyx_kp_s_Must_supply_freq_for_ordinal_val;
static PyObject *__pyx_n_s_NaT;
static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
static PyObject *__pyx_n_s_NotImplemented;
static PyObject *__pyx_kp_s_Only_value_or_ordinal_but_not_bo;
static PyObject *__pyx_kp_s_Ordinal_must_be_an_integer;
static PyObject *__pyx_n_s_Period;
static PyObject *__pyx_n_s_Period___new;
static PyObject *__pyx_kp_s_Period_s_s;
static PyObject *__pyx_kp_u_Period_strftime_line_980;
static PyObject *__pyx_kp_s_Quarter_must_be_1_q_4;
static PyObject *__pyx_kp_s_Represents_an_period_of_time_Pa;
static PyObject *__pyx_n_s_Resolution;
static PyObject *__pyx_kp_u_Returns_the_string_representati;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_n_s_S;
static PyObject *__pyx_n_s_START;
static PyObject *__pyx_n_s_S_RESO;
static PyObject *__pyx_n_s_T_RESO;
static PyObject *__pyx_n_s_Tick;
static PyObject *__pyx_n_s_Timedelta;
static PyObject *__pyx_n_s_Timestamp;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_n_s_US_RESO;
static PyObject *__pyx_kp_s_Unable_to_convert_to_desired_fre;
static PyObject *__pyx_kp_s_Unable_to_get_quarter_and_year;
static PyObject *__pyx_kp_s_Unable_to_parse_s;
static PyObject *__pyx_kp_s_Unknown_freq_d;
static PyObject *__pyx_kp_s_Unrecognized_period_code_d;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s_Value_must_be_Period_string_inte;
static PyObject *__pyx_kp_b_Y;
static PyObject *__pyx_kp_b_Y_m;
static PyObject *__pyx_kp_b_Y_m_d;
static PyObject *__pyx_kp_b_Y_m_d_H_00;
static PyObject *__pyx_kp_b_Y_m_d_H_M;
static PyObject *__pyx_kp_b_Y_m_d_H_M_S;
static PyObject *__pyx_kp_b_Y_m_d_H_M_S_l;
static PyObject *__pyx_kp_b_Y_m_d_H_M_S_n;
static PyObject *__pyx_kp_b_Y_m_d_H_M_S_u;
static PyObject *__pyx_n_s__51;
static PyObject *__pyx_n_s_add_delta;
static PyObject *__pyx_n_s_any;
static PyObject *__pyx_n_s_arr;
static PyObject *__pyx_n_s_asfreq;
static PyObject *__pyx_kp_s_assignment_destination_is_read_o;
static PyObject *__pyx_n_s_astype;
static PyObject *__pyx_n_s_base;
static PyObject *__pyx_n_s_cls;
static PyObject *__pyx_n_s_code;
static PyObject *__pyx_n_s_comparables;
static PyObject *__pyx_n_s_compat;
static PyObject *__pyx_n_s_converted;
static PyObject *__pyx_n_s_d;
static PyObject *__pyx_kp_s_d_2;
static PyObject *__pyx_n_s_date;
static PyObject *__pyx_n_s_datetime;
static PyObject *__pyx_n_s_datetime64;
static PyObject *__pyx_n_s_dateutil;
static PyObject *__pyx_n_s_day;
static PyObject *__pyx_n_s_dayofweek;
static PyObject *__pyx_n_s_days_in_month;
static PyObject *__pyx_n_s_decode;
static PyObject *__pyx_n_s_delta_to_nanoseconds;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_dt;
static PyObject *__pyx_n_s_dt64arr_to_periodarr;
static PyObject *__pyx_n_s_dtarr;
static PyObject *__pyx_n_s_dts;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_empty;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_extract_freq;
static PyObject *__pyx_n_s_extract_ordinals;
static PyObject *__pyx_kp_b_f;
static PyObject *__pyx_n_s_f_2;
static PyObject *__pyx_n_s_finfo;
static PyObject *__pyx_n_s_fmt;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_freq;
static PyObject *__pyx_n_s_freq1;
static PyObject *__pyx_n_s_freq2;
static PyObject *__pyx_n_s_freq_group;
static PyObject *__pyx_kp_s_freq_not_specified_and_cannot_be;
static PyObject *__pyx_n_s_freqstr;
static PyObject *__pyx_n_s_frequencies;
static PyObject *__pyx_n_s_from_ordinal;
static PyObject *__pyx_n_s_func;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_base_alias;
static PyObject *__pyx_n_s_get_freq;
static PyObject *__pyx_n_s_get_freq_code;
static PyObject *__pyx_n_s_get_freq_str;
static PyObject *__pyx_n_s_get_period_field;
static PyObject *__pyx_n_s_get_period_field_arr;
static PyObject *__pyx_n_s_get_rule_month;
static PyObject *__pyx_n_s_get_to_timestamp_base;
static PyObject *__pyx_n_s_get_utcoffset;
static PyObject *__pyx_n_s_h;
static PyObject *__pyx_n_s_have_pytz;
static PyObject *__pyx_kp_s_home_joris_scipy_pandas_pandas;
static PyObject *__pyx_n_s_hour;
static PyObject *__pyx_n_s_how;
static PyObject *__pyx_n_s_how_dict;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_i8;
static PyObject *__pyx_n_s_iNaT;
static PyObject *__pyx_n_s_ignore;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_kp_s_index_out_of_bounds;
static PyObject *__pyx_n_s_inf;
static PyObject *__pyx_n_s_int64;
static PyObject *__pyx_n_s_is_integer;
static PyObject *__pyx_n_s_l;
static PyObject *__pyx_kp_b_l_2;
static PyObject *__pyx_n_s_left;
static PyObject *__pyx_n_s_lib;
static PyObject *__pyx_n_s_m;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_mask;
static PyObject *__pyx_n_s_maybe_convert_freq;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_microsecond;
static PyObject *__pyx_n_s_min;
static PyObject *__pyx_n_s_minute;
static PyObject *__pyx_n_s_mnum;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_month;
static PyObject *__pyx_n_s_month_numbers;
static PyObject *__pyx_n_s_msg;
static PyObject *__pyx_n_s_mult;
static PyObject *__pyx_n_s_n;
static PyObject *__pyx_kp_b_n_2;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_nan;
static PyObject *__pyx_n_s_nat_strings;
static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_now;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_offsets;
static PyObject *__pyx_n_s_operator;
static PyObject *__pyx_n_s_ordinal;
static PyObject *__pyx_n_s_ordinal_from_fields;
static PyObject *__pyx_n_s_ordinals;
static PyObject *__pyx_n_s_other;
static PyObject *__pyx_n_s_out;
static PyObject *__pyx_n_s_p;
static PyObject *__pyx_n_s_pandas;
static PyObject *__pyx_n_s_pandas__period;
static PyObject *__pyx_n_s_pandas_tseries;
static PyObject *__pyx_n_s_pandas_tseries_tools;
static PyObject *__pyx_n_s_parse_time_string;
static PyObject *__pyx_n_s_period;
static PyObject *__pyx_n_s_period_asfreq_arr;
static PyObject *__pyx_n_s_period_format;
static PyObject *__pyx_n_s_period_ordinal;
static PyObject *__pyx_n_s_periodarr;
static PyObject *__pyx_n_s_periodarr_to_dt64arr;
static PyObject *__pyx_n_s_periodindex;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_ps;
static PyObject *__pyx_n_s_pytz;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_kp_b_q;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_quarter;
static PyObject *__pyx_n_s_quarter_to_myear;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_relation;
static PyObject *__pyx_n_s_replace;
static PyObject *__pyx_n_s_reso;
static PyObject *__pyx_n_s_result;
static PyObject *__pyx_n_s_right;
static PyObject *__pyx_n_s_rule_code;
static PyObject *__pyx_n_s_s;
static PyObject *__pyx_kp_s_s_2;
static PyObject *__pyx_kp_s_s_s;
static PyObject *__pyx_n_s_searchsorted;
static PyObject *__pyx_n_s_second;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_side;
static PyObject *__pyx_n_s_stamps;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_start_time;
static PyObject *__pyx_n_s_string_types;
static PyObject *__pyx_n_s_sub;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_sz;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_timedelta;
static PyObject *__pyx_n_s_timedelta64;
static PyObject *__pyx_n_s_to_offset;
static PyObject *__pyx_n_s_to_timestamp;
static PyObject *__pyx_n_s_tslib;
static PyObject *__pyx_n_s_typ;
static PyObject *__pyx_n_s_tz;
static PyObject *__pyx_kp_b_u;
static PyObject *__pyx_n_s_unicode;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_upper;
static PyObject *__pyx_n_s_us;
static PyObject *__pyx_kp_s_utf_8;
static PyObject *__pyx_n_s_val;
static PyObject *__pyx_n_s_validate_end_alias;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_version_info;
static PyObject *__pyx_n_s_weekofyear;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_n_s_year;
static PyObject *__pyx_pf_6pandas_7_period_dt64arr_to_periodarr(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dtarr, int __pyx_v_freq, PyObject *__pyx_v_tz); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_2periodarr_to_dt64arr(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_periodarr, int __pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_4period_asfreq(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_5numpy_int64_t __pyx_v_period_ordinal, int __pyx_v_freq1, int __pyx_v_freq2, int __pyx_v_end); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_6period_asfreq_arr(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_arr, int __pyx_v_freq1, int __pyx_v_freq2, int __pyx_v_end); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_8period_ordinal(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_y, int __pyx_v_m, int __pyx_v_d, int __pyx_v_h, int __pyx_v_min, int __pyx_v_s, int __pyx_v_us, int __pyx_v_ps, int __pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_10period_ordinal_to_dt64(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_5numpy_int64_t __pyx_v_ordinal, int __pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_12period_format(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_5numpy_int64_t __pyx_v_value, int __pyx_v_freq, PyObject *__pyx_v_fmt); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_14get_period_field(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_code, __pyx_t_5numpy_int64_t __pyx_v_value, int __pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_16get_period_field_arr(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_code, PyArrayObject *__pyx_v_arr, int __pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_18extract_ordinals(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_values, PyObject *__pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_20extract_freq(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_values); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_22resolution(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_stamps, PyObject *__pyx_v_tz); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period__maybe_convert_freq(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_2_from_ordinal(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_ordinal, PyObject *__pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_4__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_op); /* proto */
static Py_hash_t __pyx_pf_6pandas_7_period_7_Period_6__hash__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_8_add_delta(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_10__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_12__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_14asfreq(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_freq, PyObject *__pyx_v_how); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_10start_time___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_8end_time___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_16to_timestamp(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_freq, PyObject *__pyx_v_how, PyObject *__pyx_v_tz); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_4year___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_5month___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_3day___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_4hour___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_6minute___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_6second___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_10weekofyear___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_4week___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_9dayofweek___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_7weekday___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_9dayofyear___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_7quarter___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_5qyear___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_13days_in_month___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_11daysinmonth___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_12is_leap_year___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_18now(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_20__str__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_7freqstr___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_22__repr__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_24__unicode__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_26__setstate__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_28__reduce__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_30strftime(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_fmt); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_7ordinal___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static int __pyx_pf_6pandas_7_period_7_Period_7ordinal_2__set__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_7_Period_4freq___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static int __pyx_pf_6pandas_7_period_7_Period_4freq_2__set__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_6pandas_7_period_7_Period_4freq_4__del__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_6Period___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_value, PyObject *__pyx_v_freq, PyObject *__pyx_v_ordinal, PyObject *__pyx_v_year, PyObject *__pyx_v_month, PyObject *__pyx_v_quarter, PyObject *__pyx_v_day, PyObject *__pyx_v_hour, PyObject *__pyx_v_minute, PyObject *__pyx_v_second); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_24_ordinal_from_fields(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_year, PyObject *__pyx_v_month, PyObject *__pyx_v_quarter, PyObject *__pyx_v_day, PyObject *__pyx_v_hour, PyObject *__pyx_v_minute, PyObject *__pyx_v_second, PyObject *__pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_26_quarter_to_myear(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_year, PyObject *__pyx_v_quarter, PyObject *__pyx_v_freq); /* proto */
static PyObject *__pyx_pf_6pandas_7_period_28_validate_end_alias(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_how); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static PyObject *__pyx_tp_new_6pandas_7_period__Period(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_5;
static PyObject *__pyx_int_6;
static PyObject *__pyx_int_7;
static PyObject *__pyx_int_8;
static PyObject *__pyx_int_9;
static PyObject *__pyx_int_10;
static PyObject *__pyx_int_11;
static PyObject *__pyx_int_12;
static PyObject *__pyx_int_15;
static PyObject *__pyx_int_6000;
static PyObject *__pyx_int_1000000000;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_codeobj__28;
static PyObject *__pyx_codeobj__30;
static PyObject *__pyx_codeobj__32;
static PyObject *__pyx_codeobj__34;
static PyObject *__pyx_codeobj__36;
static PyObject *__pyx_codeobj__44;
static PyObject *__pyx_codeobj__46;
static PyObject *__pyx_codeobj__48;
static PyObject *__pyx_codeobj__50;
static PyObject *__pyx_codeobj__53;
static PyObject *__pyx_codeobj__56;
static PyObject *__pyx_codeobj__58;
static PyObject *__pyx_codeobj__60;

/* "pandas/src/period.pyx":121
 * #----------------------------------------------------------------------
 * 
 * cdef inline int64_t apply_mult(int64_t period_ord, int64_t mult):             # <<<<<<<<<<<<<<
 *     """
 *     Get freq+multiple ordinal value from corresponding freq-only ordinal value.
 */

static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_6pandas_7_period_apply_mult(__pyx_t_5numpy_int64_t __pyx_v_period_ord, __pyx_t_5numpy_int64_t __pyx_v_mult) {
  __pyx_t_5numpy_int64_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __pyx_t_5numpy_int64_t __pyx_t_2;
  __Pyx_RefNannySetupContext("apply_mult", 0);

  /* "pandas/src/period.pyx":127
 *     integer).
 *     """
 *     if mult == 1:             # <<<<<<<<<<<<<<
 *         return period_ord
 * 
 */
  __pyx_t_1 = ((__pyx_v_mult == 1) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":128
 *     """
 *     if mult == 1:
 *         return period_ord             # <<<<<<<<<<<<<<
 * 
 *     return (period_ord - 1) // mult
 */
    __pyx_r = __pyx_v_period_ord;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":127
 *     integer).
 *     """
 *     if mult == 1:             # <<<<<<<<<<<<<<
 *         return period_ord
 * 
 */
  }

  /* "pandas/src/period.pyx":130
 *         return period_ord
 * 
 *     return (period_ord - 1) // mult             # <<<<<<<<<<<<<<
 * 
 * cdef inline int64_t remove_mult(int64_t period_ord_w_mult, int64_t mult):
 */
  __pyx_t_2 = (__pyx_v_period_ord - 1);
  if (unlikely(__pyx_v_mult == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 130, __pyx_L1_error)
  }
  else if (sizeof(__pyx_t_5numpy_int64_t) == sizeof(long) && (!(((__pyx_t_5numpy_int64_t)-1) > 0)) && unlikely(__pyx_v_mult == (__pyx_t_5numpy_int64_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_2))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 130, __pyx_L1_error)
  }
  __pyx_r = __Pyx_div___pyx_t_5numpy_int64_t(__pyx_t_2, __pyx_v_mult);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":121
 * #----------------------------------------------------------------------
 * 
 * cdef inline int64_t apply_mult(int64_t period_ord, int64_t mult):             # <<<<<<<<<<<<<<
 *     """
 *     Get freq+multiple ordinal value from corresponding freq-only ordinal value.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pandas._period.apply_mult", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":132
 *     return (period_ord - 1) // mult
 * 
 * cdef inline int64_t remove_mult(int64_t period_ord_w_mult, int64_t mult):             # <<<<<<<<<<<<<<
 *     """
 *     Get freq-only ordinal value from corresponding freq+multiple ordinal.
 */

static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_6pandas_7_period_remove_mult(__pyx_t_5numpy_int64_t __pyx_v_period_ord_w_mult, __pyx_t_5numpy_int64_t __pyx_v_mult) {
  __pyx_t_5numpy_int64_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("remove_mult", 0);

  /* "pandas/src/period.pyx":136
 *     Get freq-only ordinal value from corresponding freq+multiple ordinal.
 *     """
 *     if mult == 1:             # <<<<<<<<<<<<<<
 *         return period_ord_w_mult
 * 
 */
  __pyx_t_1 = ((__pyx_v_mult == 1) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":137
 *     """
 *     if mult == 1:
 *         return period_ord_w_mult             # <<<<<<<<<<<<<<
 * 
 *     return period_ord_w_mult * mult + 1;
 */
    __pyx_r = __pyx_v_period_ord_w_mult;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":136
 *     Get freq-only ordinal value from corresponding freq+multiple ordinal.
 *     """
 *     if mult == 1:             # <<<<<<<<<<<<<<
 *         return period_ord_w_mult
 * 
 */
  }

  /* "pandas/src/period.pyx":139
 *         return period_ord_w_mult
 * 
 *     return period_ord_w_mult * mult + 1;             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((__pyx_v_period_ord_w_mult * __pyx_v_mult) + 1);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":132
 *     return (period_ord - 1) // mult
 * 
 * cdef inline int64_t remove_mult(int64_t period_ord_w_mult, int64_t mult):             # <<<<<<<<<<<<<<
 *     """
 *     Get freq-only ordinal value from corresponding freq+multiple ordinal.
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":144
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def dt64arr_to_periodarr(ndarray[int64_t] dtarr, int freq, tz=None):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array of datetime64 values (passed in as 'i8' dtype) to a set of
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_1dt64arr_to_periodarr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6pandas_7_period_dt64arr_to_periodarr[] = "\n    Convert array of datetime64 values (passed in as 'i8' dtype) to a set of\n    periods corresponding to desired frequency, per period convention.\n    ";
static PyMethodDef __pyx_mdef_6pandas_7_period_1dt64arr_to_periodarr = {"dt64arr_to_periodarr", (PyCFunction)__pyx_pw_6pandas_7_period_1dt64arr_to_periodarr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6pandas_7_period_dt64arr_to_periodarr};
static PyObject *__pyx_pw_6pandas_7_period_1dt64arr_to_periodarr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_dtarr = 0;
  int __pyx_v_freq;
  PyObject *__pyx_v_tz = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dt64arr_to_periodarr (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dtarr,&__pyx_n_s_freq,&__pyx_n_s_tz,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtarr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("dt64arr_to_periodarr", 0, 2, 3, 1); __PYX_ERR(0, 144, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tz);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dt64arr_to_periodarr") < 0)) __PYX_ERR(0, 144, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dtarr = ((PyArrayObject *)values[0]);
    __pyx_v_freq = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_freq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L3_error)
    __pyx_v_tz = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dt64arr_to_periodarr", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 144, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.dt64arr_to_periodarr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dtarr), __pyx_ptype_5numpy_ndarray, 1, "dtarr", 0))) __PYX_ERR(0, 144, __pyx_L1_error)
  __pyx_r = __pyx_pf_6pandas_7_period_dt64arr_to_periodarr(__pyx_self, __pyx_v_dtarr, __pyx_v_freq, __pyx_v_tz);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_dt64arr_to_periodarr(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dtarr, int __pyx_v_freq, PyObject *__pyx_v_tz) {
  PyArrayObject *__pyx_v_out = 0;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_l;
  pandas_datetimestruct __pyx_v_dts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dtarr;
  __Pyx_Buffer __pyx_pybuffer_dtarr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
  __Pyx_Buffer __pyx_pybuffer_out;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  __pyx_t_5numpy_int64_t __pyx_t_17;
  Py_ssize_t __pyx_t_18;
  __Pyx_RefNannySetupContext("dt64arr_to_periodarr", 0);
  __pyx_pybuffer_out.pybuffer.buf = NULL;
  __pyx_pybuffer_out.refcount = 0;
  __pyx_pybuffernd_out.data = NULL;
  __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
  __pyx_pybuffer_dtarr.pybuffer.buf = NULL;
  __pyx_pybuffer_dtarr.refcount = 0;
  __pyx_pybuffernd_dtarr.data = NULL;
  __pyx_pybuffernd_dtarr.rcbuffer = &__pyx_pybuffer_dtarr;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dtarr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dtarr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 144, __pyx_L1_error)
  }
  __pyx_pybuffernd_dtarr.diminfo[0].strides = __pyx_pybuffernd_dtarr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dtarr.diminfo[0].shape = __pyx_pybuffernd_dtarr.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":154
 *         pandas_datetimestruct dts
 * 
 *     l = len(dtarr)             # <<<<<<<<<<<<<<
 * 
 *     out = np.empty(l, dtype='i8')
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_dtarr)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 154, __pyx_L1_error)
  __pyx_v_l = __pyx_t_1;

  /* "pandas/src/period.pyx":156
 *     l = len(dtarr)
 * 
 *     out = np.empty(l, dtype='i8')             # <<<<<<<<<<<<<<
 * 
 *     if tz is None:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_l); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_n_s_i8) < 0) __PYX_ERR(0, 156, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 156, __pyx_L1_error)
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 156, __pyx_L1_error)
  }
  __pyx_t_6 = 0;
  __pyx_v_out = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":158
 *     out = np.empty(l, dtype='i8')
 * 
 *     if tz is None:             # <<<<<<<<<<<<<<
 *         with nogil:
 *             for i in range(l):
 */
  __pyx_t_11 = (__pyx_v_tz == Py_None);
  __pyx_t_12 = (__pyx_t_11 != 0);
  if (__pyx_t_12) {

    /* "pandas/src/period.pyx":159
 * 
 *     if tz is None:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for i in range(l):
 *                 if dtarr[i] == NPY_NAT:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        #endif
        /*try:*/ {

          /* "pandas/src/period.pyx":160
 *     if tz is None:
 *         with nogil:
 *             for i in range(l):             # <<<<<<<<<<<<<<
 *                 if dtarr[i] == NPY_NAT:
 *                     out[i] = NPY_NAT
 */
          __pyx_t_1 = __pyx_v_l;
          for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_1; __pyx_t_13+=1) {
            __pyx_v_i = __pyx_t_13;

            /* "pandas/src/period.pyx":161
 *         with nogil:
 *             for i in range(l):
 *                 if dtarr[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     out[i] = NPY_NAT
 *                     continue
 */
            __pyx_t_14 = __pyx_v_i;
            __pyx_t_12 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_dtarr.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_dtarr.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
            if (__pyx_t_12) {

              /* "pandas/src/period.pyx":162
 *             for i in range(l):
 *                 if dtarr[i] == NPY_NAT:
 *                     out[i] = NPY_NAT             # <<<<<<<<<<<<<<
 *                     continue
 *                 pandas_datetime_to_datetimestruct(dtarr[i], PANDAS_FR_ns, &dts)
 */
              __pyx_t_15 = __pyx_v_i;
              *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_v_6pandas_7_period_NPY_NAT;

              /* "pandas/src/period.pyx":163
 *                 if dtarr[i] == NPY_NAT:
 *                     out[i] = NPY_NAT
 *                     continue             # <<<<<<<<<<<<<<
 *                 pandas_datetime_to_datetimestruct(dtarr[i], PANDAS_FR_ns, &dts)
 *                 out[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 */
              goto __pyx_L7_continue;

              /* "pandas/src/period.pyx":161
 *         with nogil:
 *             for i in range(l):
 *                 if dtarr[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     out[i] = NPY_NAT
 *                     continue
 */
            }

            /* "pandas/src/period.pyx":164
 *                     out[i] = NPY_NAT
 *                     continue
 *                 pandas_datetime_to_datetimestruct(dtarr[i], PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *                 out[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 *                                             dts.hour, dts.min, dts.sec,
 */
            __pyx_t_16 = __pyx_v_i;
            pandas_datetime_to_datetimestruct((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_dtarr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_dtarr.diminfo[0].strides)), PANDAS_FR_ns, (&__pyx_v_dts));

            /* "pandas/src/period.pyx":165
 *                     continue
 *                 pandas_datetime_to_datetimestruct(dtarr[i], PANDAS_FR_ns, &dts)
 *                 out[i] = get_period_ordinal(dts.year, dts.month, dts.day,             # <<<<<<<<<<<<<<
 *                                             dts.hour, dts.min, dts.sec,
 *                                             dts.us, dts.ps, freq)
 */
            __pyx_t_17 = get_period_ordinal(__pyx_v_dts.year, __pyx_v_dts.month, __pyx_v_dts.day, __pyx_v_dts.hour, __pyx_v_dts.min, __pyx_v_dts.sec, __pyx_v_dts.us, __pyx_v_dts.ps, __pyx_v_freq); if (unlikely(__pyx_t_17 == INT32_MIN)) __PYX_ERR(0, 165, __pyx_L5_error)
            __pyx_t_18 = __pyx_v_i;
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_t_17;
            __pyx_L7_continue:;
          }
        }

        /* "pandas/src/period.pyx":159
 * 
 *     if tz is None:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for i in range(l):
 *                 if dtarr[i] == NPY_NAT:
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L6;
          }
          __pyx_L5_error: {
            #ifdef WITH_THREAD
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L1_error;
          }
          __pyx_L6:;
        }
    }

    /* "pandas/src/period.pyx":158
 *     out = np.empty(l, dtype='i8')
 * 
 *     if tz is None:             # <<<<<<<<<<<<<<
 *         with nogil:
 *             for i in range(l):
 */
    goto __pyx_L3;
  }

  /* "pandas/src/period.pyx":169
 *                                             dts.us, dts.ps, freq)
 *     else:
 *         out = localize_dt64arr_to_period(dtarr, freq, tz)             # <<<<<<<<<<<<<<
 *     return out
 * 
 */
  /*else*/ {
    __pyx_t_5 = ((PyObject *)__pyx_f_6pandas_7_period_localize_dt64arr_to_period(((PyArrayObject *)__pyx_v_dtarr), __pyx_v_freq, __pyx_v_tz)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 169, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_5), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
        }
      }
      __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 169, __pyx_L1_error)
    }
    __Pyx_DECREF_SET(__pyx_v_out, ((PyArrayObject *)__pyx_t_5));
    __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "pandas/src/period.pyx":170
 *     else:
 *         out = localize_dt64arr_to_period(dtarr, freq, tz)
 *     return out             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_r = ((PyObject *)__pyx_v_out);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":144
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def dt64arr_to_periodarr(ndarray[int64_t] dtarr, int freq, tz=None):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array of datetime64 values (passed in as 'i8' dtype) to a set of
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dtarr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.dt64arr_to_periodarr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dtarr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":175
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def periodarr_to_dt64arr(ndarray[int64_t] periodarr, int freq):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array to datetime64 values from a set of ordinals corresponding to
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_3periodarr_to_dt64arr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6pandas_7_period_2periodarr_to_dt64arr[] = "\n    Convert array to datetime64 values from a set of ordinals corresponding to\n    periods per period convention.\n    ";
static PyMethodDef __pyx_mdef_6pandas_7_period_3periodarr_to_dt64arr = {"periodarr_to_dt64arr", (PyCFunction)__pyx_pw_6pandas_7_period_3periodarr_to_dt64arr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6pandas_7_period_2periodarr_to_dt64arr};
static PyObject *__pyx_pw_6pandas_7_period_3periodarr_to_dt64arr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_periodarr = 0;
  int __pyx_v_freq;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("periodarr_to_dt64arr (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_periodarr,&__pyx_n_s_freq,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_periodarr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("periodarr_to_dt64arr", 1, 2, 2, 1); __PYX_ERR(0, 175, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "periodarr_to_dt64arr") < 0)) __PYX_ERR(0, 175, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_periodarr = ((PyArrayObject *)values[0]);
    __pyx_v_freq = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_freq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 175, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("periodarr_to_dt64arr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 175, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.periodarr_to_dt64arr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_periodarr), __pyx_ptype_5numpy_ndarray, 1, "periodarr", 0))) __PYX_ERR(0, 175, __pyx_L1_error)
  __pyx_r = __pyx_pf_6pandas_7_period_2periodarr_to_dt64arr(__pyx_self, __pyx_v_periodarr, __pyx_v_freq);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_2periodarr_to_dt64arr(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_periodarr, int __pyx_v_freq) {
  PyArrayObject *__pyx_v_out = 0;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_l;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
  __Pyx_Buffer __pyx_pybuffer_out;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_periodarr;
  __Pyx_Buffer __pyx_pybuffer_periodarr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  __Pyx_RefNannySetupContext("periodarr_to_dt64arr", 0);
  __pyx_pybuffer_out.pybuffer.buf = NULL;
  __pyx_pybuffer_out.refcount = 0;
  __pyx_pybuffernd_out.data = NULL;
  __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
  __pyx_pybuffer_periodarr.pybuffer.buf = NULL;
  __pyx_pybuffer_periodarr.refcount = 0;
  __pyx_pybuffernd_periodarr.data = NULL;
  __pyx_pybuffernd_periodarr.rcbuffer = &__pyx_pybuffer_periodarr;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_periodarr.rcbuffer->pybuffer, (PyObject*)__pyx_v_periodarr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 175, __pyx_L1_error)
  }
  __pyx_pybuffernd_periodarr.diminfo[0].strides = __pyx_pybuffernd_periodarr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_periodarr.diminfo[0].shape = __pyx_pybuffernd_periodarr.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":184
 *         Py_ssize_t i, l
 * 
 *     l = len(periodarr)             # <<<<<<<<<<<<<<
 * 
 *     out = np.empty(l, dtype='i8')
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_periodarr)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 184, __pyx_L1_error)
  __pyx_v_l = __pyx_t_1;

  /* "pandas/src/period.pyx":186
 *     l = len(periodarr)
 * 
 *     out = np.empty(l, dtype='i8')             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_l); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_n_s_i8) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 186, __pyx_L1_error)
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 186, __pyx_L1_error)
  }
  __pyx_t_6 = 0;
  __pyx_v_out = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":188
 *     out = np.empty(l, dtype='i8')
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         for i in range(l):
 *             if periodarr[i] == NPY_NAT:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pandas/src/period.pyx":189
 * 
 *     with nogil:
 *         for i in range(l):             # <<<<<<<<<<<<<<
 *             if periodarr[i] == NPY_NAT:
 *                 out[i] = NPY_NAT
 */
        __pyx_t_1 = __pyx_v_l;
        for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_1; __pyx_t_11+=1) {
          __pyx_v_i = __pyx_t_11;

          /* "pandas/src/period.pyx":190
 *     with nogil:
 *         for i in range(l):
 *             if periodarr[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 out[i] = NPY_NAT
 *                 continue
 */
          __pyx_t_12 = __pyx_v_i;
          __pyx_t_13 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_periodarr.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_periodarr.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
          if (__pyx_t_13) {

            /* "pandas/src/period.pyx":191
 *         for i in range(l):
 *             if periodarr[i] == NPY_NAT:
 *                 out[i] = NPY_NAT             # <<<<<<<<<<<<<<
 *                 continue
 *             out[i] = period_ordinal_to_dt64(periodarr[i], freq)
 */
            __pyx_t_14 = __pyx_v_i;
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_v_6pandas_7_period_NPY_NAT;

            /* "pandas/src/period.pyx":192
 *             if periodarr[i] == NPY_NAT:
 *                 out[i] = NPY_NAT
 *                 continue             # <<<<<<<<<<<<<<
 *             out[i] = period_ordinal_to_dt64(periodarr[i], freq)
 * 
 */
            goto __pyx_L6_continue;

            /* "pandas/src/period.pyx":190
 *     with nogil:
 *         for i in range(l):
 *             if periodarr[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 out[i] = NPY_NAT
 *                 continue
 */
          }

          /* "pandas/src/period.pyx":193
 *                 out[i] = NPY_NAT
 *                 continue
 *             out[i] = period_ordinal_to_dt64(periodarr[i], freq)             # <<<<<<<<<<<<<<
 * 
 *     return out
 */
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_16 = __pyx_v_i;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_f_6pandas_7_period_period_ordinal_to_dt64((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_periodarr.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_periodarr.diminfo[0].strides)), __pyx_v_freq, 0);
          __pyx_L6_continue:;
        }
      }

      /* "pandas/src/period.pyx":188
 *     out = np.empty(l, dtype='i8')
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         for i in range(l):
 *             if periodarr[i] == NPY_NAT:
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "pandas/src/period.pyx":195
 *             out[i] = period_ordinal_to_dt64(periodarr[i], freq)
 * 
 *     return out             # <<<<<<<<<<<<<<
 * 
 * cdef char START = 'S'
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_r = ((PyObject *)__pyx_v_out);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":175
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def periodarr_to_dt64arr(ndarray[int64_t] periodarr, int freq):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array to datetime64 values from a set of ordinals corresponding to
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_periodarr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.periodarr_to_dt64arr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_periodarr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":200
 * cdef char END = 'E'
 * 
 * cpdef int64_t period_asfreq(int64_t period_ordinal, int freq1, int freq2,             # <<<<<<<<<<<<<<
 *                             bint end):
 *     """
 */

static PyObject *__pyx_pw_6pandas_7_period_5period_asfreq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static __pyx_t_5numpy_int64_t __pyx_f_6pandas_7_period_period_asfreq(__pyx_t_5numpy_int64_t __pyx_v_period_ordinal, int __pyx_v_freq1, int __pyx_v_freq2, int __pyx_v_end, CYTHON_UNUSED int __pyx_skip_dispatch) {
  __pyx_t_5numpy_int64_t __pyx_v_retval;
  __pyx_t_5numpy_int64_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __pyx_t_5numpy_int64_t __pyx_t_5;
  __Pyx_RefNannySetupContext("period_asfreq", 0);

  /* "pandas/src/period.pyx":209
 *         int64_t retval
 * 
 *     if period_ordinal == iNaT:             # <<<<<<<<<<<<<<
 *         return iNaT
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_period_ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_iNaT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 209, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "pandas/src/period.pyx":210
 * 
 *     if period_ordinal == iNaT:
 *         return iNaT             # <<<<<<<<<<<<<<
 * 
 *     if end:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_iNaT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 210, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyInt_As_npy_int64(__pyx_t_3); if (unlikely((__pyx_t_5 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 210, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_5;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":209
 *         int64_t retval
 * 
 *     if period_ordinal == iNaT:             # <<<<<<<<<<<<<<
 *         return iNaT
 * 
 */
  }

  /* "pandas/src/period.pyx":212
 *         return iNaT
 * 
 *     if end:             # <<<<<<<<<<<<<<
 *         retval = asfreq(period_ordinal, freq1, freq2, END)
 *     else:
 */
  __pyx_t_4 = (__pyx_v_end != 0);
  if (__pyx_t_4) {

    /* "pandas/src/period.pyx":213
 * 
 *     if end:
 *         retval = asfreq(period_ordinal, freq1, freq2, END)             # <<<<<<<<<<<<<<
 *     else:
 *         retval = asfreq(period_ordinal, freq1, freq2, START)
 */
    __pyx_t_5 = asfreq(__pyx_v_period_ordinal, __pyx_v_freq1, __pyx_v_freq2, __pyx_v_6pandas_7_period_END); if (unlikely(__pyx_t_5 == INT32_MIN)) __PYX_ERR(0, 213, __pyx_L1_error)
    __pyx_v_retval = __pyx_t_5;

    /* "pandas/src/period.pyx":212
 *         return iNaT
 * 
 *     if end:             # <<<<<<<<<<<<<<
 *         retval = asfreq(period_ordinal, freq1, freq2, END)
 *     else:
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":215
 *         retval = asfreq(period_ordinal, freq1, freq2, END)
 *     else:
 *         retval = asfreq(period_ordinal, freq1, freq2, START)             # <<<<<<<<<<<<<<
 * 
 *     if retval == INT32_MIN:
 */
  /*else*/ {
    __pyx_t_5 = asfreq(__pyx_v_period_ordinal, __pyx_v_freq1, __pyx_v_freq2, __pyx_v_6pandas_7_period_START); if (unlikely(__pyx_t_5 == INT32_MIN)) __PYX_ERR(0, 215, __pyx_L1_error)
    __pyx_v_retval = __pyx_t_5;
  }
  __pyx_L4:;

  /* "pandas/src/period.pyx":217
 *         retval = asfreq(period_ordinal, freq1, freq2, START)
 * 
 *     if retval == INT32_MIN:             # <<<<<<<<<<<<<<
 *         raise ValueError('Frequency conversion failed')
 * 
 */
  __pyx_t_4 = ((__pyx_v_retval == INT32_MIN) != 0);
  if (__pyx_t_4) {

    /* "pandas/src/period.pyx":218
 * 
 *     if retval == INT32_MIN:
 *         raise ValueError('Frequency conversion failed')             # <<<<<<<<<<<<<<
 * 
 *     return retval
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 218, __pyx_L1_error)

    /* "pandas/src/period.pyx":217
 *         retval = asfreq(period_ordinal, freq1, freq2, START)
 * 
 *     if retval == INT32_MIN:             # <<<<<<<<<<<<<<
 *         raise ValueError('Frequency conversion failed')
 * 
 */
  }

  /* "pandas/src/period.pyx":220
 *         raise ValueError('Frequency conversion failed')
 * 
 *     return retval             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_retval;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":200
 * cdef char END = 'E'
 * 
 * cpdef int64_t period_asfreq(int64_t period_ordinal, int freq1, int freq2,             # <<<<<<<<<<<<<<
 *                             bint end):
 *     """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("pandas._period.period_asfreq", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_5period_asfreq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6pandas_7_period_4period_asfreq[] = "\n    Convert period ordinal from one frequency to another, and if upsampling,\n    choose to use start ('S') or end ('E') of period.\n    ";
static PyObject *__pyx_pw_6pandas_7_period_5period_asfreq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __pyx_t_5numpy_int64_t __pyx_v_period_ordinal;
  int __pyx_v_freq1;
  int __pyx_v_freq2;
  int __pyx_v_end;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("period_asfreq (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_period_ordinal,&__pyx_n_s_freq1,&__pyx_n_s_freq2,&__pyx_n_s_end,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_period_ordinal)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_asfreq", 1, 4, 4, 1); __PYX_ERR(0, 200, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_asfreq", 1, 4, 4, 2); __PYX_ERR(0, 200, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_asfreq", 1, 4, 4, 3); __PYX_ERR(0, 200, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "period_asfreq") < 0)) __PYX_ERR(0, 200, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_period_ordinal = __Pyx_PyInt_As_npy_int64(values[0]); if (unlikely((__pyx_v_period_ordinal == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L3_error)
    __pyx_v_freq1 = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_freq1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L3_error)
    __pyx_v_freq2 = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_freq2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L3_error)
    __pyx_v_end = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 201, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("period_asfreq", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 200, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.period_asfreq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_4period_asfreq(__pyx_self, __pyx_v_period_ordinal, __pyx_v_freq1, __pyx_v_freq2, __pyx_v_end);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_4period_asfreq(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_5numpy_int64_t __pyx_v_period_ordinal, int __pyx_v_freq1, int __pyx_v_freq2, int __pyx_v_end) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("period_asfreq", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_f_6pandas_7_period_period_asfreq(__pyx_v_period_ordinal, __pyx_v_freq1, __pyx_v_freq2, __pyx_v_end, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period.period_asfreq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":223
 * 
 * 
 * def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end):             # <<<<<<<<<<<<<<
 *     """
 *     Convert int64-array of period ordinals from one frequency to another, and
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7period_asfreq_arr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6pandas_7_period_6period_asfreq_arr[] = "\n    Convert int64-array of period ordinals from one frequency to another, and\n    if upsampling, choose to use start ('S') or end ('E') of period.\n    ";
static PyMethodDef __pyx_mdef_6pandas_7_period_7period_asfreq_arr = {"period_asfreq_arr", (PyCFunction)__pyx_pw_6pandas_7_period_7period_asfreq_arr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6pandas_7_period_6period_asfreq_arr};
static PyObject *__pyx_pw_6pandas_7_period_7period_asfreq_arr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_arr = 0;
  int __pyx_v_freq1;
  int __pyx_v_freq2;
  int __pyx_v_end;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("period_asfreq_arr (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_freq1,&__pyx_n_s_freq2,&__pyx_n_s_end,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_asfreq_arr", 1, 4, 4, 1); __PYX_ERR(0, 223, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_asfreq_arr", 1, 4, 4, 2); __PYX_ERR(0, 223, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_asfreq_arr", 1, 4, 4, 3); __PYX_ERR(0, 223, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "period_asfreq_arr") < 0)) __PYX_ERR(0, 223, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_arr = ((PyArrayObject *)values[0]);
    __pyx_v_freq1 = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_freq1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 223, __pyx_L3_error)
    __pyx_v_freq2 = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_freq2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 223, __pyx_L3_error)
    __pyx_v_end = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 223, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("period_asfreq_arr", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 223, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.period_asfreq_arr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_5numpy_ndarray, 1, "arr", 0))) __PYX_ERR(0, 223, __pyx_L1_error)
  __pyx_r = __pyx_pf_6pandas_7_period_6period_asfreq_arr(__pyx_self, __pyx_v_arr, __pyx_v_freq1, __pyx_v_freq2, __pyx_v_end);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_6period_asfreq_arr(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_arr, int __pyx_v_freq1, int __pyx_v_freq2, int __pyx_v_end) {
  PyArrayObject *__pyx_v_result = 0;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  freq_conv_func __pyx_v_func;
  asfreq_info __pyx_v_finfo;
  __pyx_t_5numpy_int64_t __pyx_v_val;
  char __pyx_v_relation;
  PyObject *__pyx_v_mask = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_arr;
  __Pyx_Buffer __pyx_pybuffer_arr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  __Pyx_RefNannySetupContext("period_asfreq_arr", 0);
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  __pyx_pybuffer_arr.pybuffer.buf = NULL;
  __pyx_pybuffer_arr.refcount = 0;
  __pyx_pybuffernd_arr.data = NULL;
  __pyx_pybuffernd_arr.rcbuffer = &__pyx_pybuffer_arr;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_arr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 223, __pyx_L1_error)
  }
  __pyx_pybuffernd_arr.diminfo[0].strides = __pyx_pybuffernd_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_arr.diminfo[0].shape = __pyx_pybuffernd_arr.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":236
 *         char relation
 * 
 *     n = len(arr)             # <<<<<<<<<<<<<<
 *     result = np.empty(n, dtype=np.int64)
 * 
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_arr)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 236, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "pandas/src/period.pyx":237
 * 
 *     n = len(arr)
 *     result = np.empty(n, dtype=np.int64)             # <<<<<<<<<<<<<<
 * 
 *     func = get_asfreq_func(freq1, freq2)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 237, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 237, __pyx_L1_error)
  }
  __pyx_t_7 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pandas/src/period.pyx":239
 *     result = np.empty(n, dtype=np.int64)
 * 
 *     func = get_asfreq_func(freq1, freq2)             # <<<<<<<<<<<<<<
 *     get_asfreq_info(freq1, freq2, &finfo)
 * 
 */
  __pyx_v_func = get_asfreq_func(__pyx_v_freq1, __pyx_v_freq2);

  /* "pandas/src/period.pyx":240
 * 
 *     func = get_asfreq_func(freq1, freq2)
 *     get_asfreq_info(freq1, freq2, &finfo)             # <<<<<<<<<<<<<<
 * 
 *     if end:
 */
  get_asfreq_info(__pyx_v_freq1, __pyx_v_freq2, (&__pyx_v_finfo));

  /* "pandas/src/period.pyx":242
 *     get_asfreq_info(freq1, freq2, &finfo)
 * 
 *     if end:             # <<<<<<<<<<<<<<
 *         relation = END
 *     else:
 */
  __pyx_t_12 = (__pyx_v_end != 0);
  if (__pyx_t_12) {

    /* "pandas/src/period.pyx":243
 * 
 *     if end:
 *         relation = END             # <<<<<<<<<<<<<<
 *     else:
 *         relation = START
 */
    __pyx_v_relation = __pyx_v_6pandas_7_period_END;

    /* "pandas/src/period.pyx":242
 *     get_asfreq_info(freq1, freq2, &finfo)
 * 
 *     if end:             # <<<<<<<<<<<<<<
 *         relation = END
 *     else:
 */
    goto __pyx_L3;
  }

  /* "pandas/src/period.pyx":245
 *         relation = END
 *     else:
 *         relation = START             # <<<<<<<<<<<<<<
 * 
 *     mask = arr == iNaT
 */
  /*else*/ {
    __pyx_v_relation = __pyx_v_6pandas_7_period_START;
  }
  __pyx_L3:;

  /* "pandas/src/period.pyx":247
 *         relation = START
 * 
 *     mask = arr == iNaT             # <<<<<<<<<<<<<<
 *     if mask.any():      # NaT process
 *         for i in range(n):
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_iNaT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_arr), __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_mask = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pandas/src/period.pyx":248
 * 
 *     mask = arr == iNaT
 *     if mask.any():      # NaT process             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             val = arr[i]
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_any); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_12) {

    /* "pandas/src/period.pyx":249
 *     mask = arr == iNaT
 *     if mask.any():      # NaT process
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             val = arr[i]
 *             if val != iNaT:
 */
    __pyx_t_1 = __pyx_v_n;
    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_1; __pyx_t_13+=1) {
      __pyx_v_i = __pyx_t_13;

      /* "pandas/src/period.pyx":250
 *     if mask.any():      # NaT process
 *         for i in range(n):
 *             val = arr[i]             # <<<<<<<<<<<<<<
 *             if val != iNaT:
 *                 val = func(val, relation, &finfo)
 */
      __pyx_t_14 = __pyx_v_i;
      __pyx_t_8 = -1;
      if (__pyx_t_14 < 0) {
        __pyx_t_14 += __pyx_pybuffernd_arr.diminfo[0].shape;
        if (unlikely(__pyx_t_14 < 0)) __pyx_t_8 = 0;
      } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_8 = 0;
      if (unlikely(__pyx_t_8 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_8);
        __PYX_ERR(0, 250, __pyx_L1_error)
      }
      __pyx_v_val = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_arr.diminfo[0].strides));

      /* "pandas/src/period.pyx":251
 *         for i in range(n):
 *             val = arr[i]
 *             if val != iNaT:             # <<<<<<<<<<<<<<
 *                 val = func(val, relation, &finfo)
 *                 if val == INT32_MIN:
 */
      __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_iNaT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_12) {

        /* "pandas/src/period.pyx":252
 *             val = arr[i]
 *             if val != iNaT:
 *                 val = func(val, relation, &finfo)             # <<<<<<<<<<<<<<
 *                 if val == INT32_MIN:
 *                     raise ValueError("Unable to convert to desired frequency.")
 */
        __pyx_v_val = __pyx_v_func(__pyx_v_val, __pyx_v_relation, (&__pyx_v_finfo));

        /* "pandas/src/period.pyx":253
 *             if val != iNaT:
 *                 val = func(val, relation, &finfo)
 *                 if val == INT32_MIN:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Unable to convert to desired frequency.")
 *             result[i] = val
 */
        __pyx_t_12 = ((__pyx_v_val == INT32_MIN) != 0);
        if (__pyx_t_12) {

          /* "pandas/src/period.pyx":254
 *                 val = func(val, relation, &finfo)
 *                 if val == INT32_MIN:
 *                     raise ValueError("Unable to convert to desired frequency.")             # <<<<<<<<<<<<<<
 *             result[i] = val
 *     else:
 */
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_Raise(__pyx_t_4, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __PYX_ERR(0, 254, __pyx_L1_error)

          /* "pandas/src/period.pyx":253
 *             if val != iNaT:
 *                 val = func(val, relation, &finfo)
 *                 if val == INT32_MIN:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Unable to convert to desired frequency.")
 *             result[i] = val
 */
        }

        /* "pandas/src/period.pyx":251
 *         for i in range(n):
 *             val = arr[i]
 *             if val != iNaT:             # <<<<<<<<<<<<<<
 *                 val = func(val, relation, &finfo)
 *                 if val == INT32_MIN:
 */
      }

      /* "pandas/src/period.pyx":255
 *                 if val == INT32_MIN:
 *                     raise ValueError("Unable to convert to desired frequency.")
 *             result[i] = val             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(n):
 */
      __pyx_t_15 = __pyx_v_i;
      __pyx_t_8 = -1;
      if (__pyx_t_15 < 0) {
        __pyx_t_15 += __pyx_pybuffernd_result.diminfo[0].shape;
        if (unlikely(__pyx_t_15 < 0)) __pyx_t_8 = 0;
      } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_8 = 0;
      if (unlikely(__pyx_t_8 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_8);
        __PYX_ERR(0, 255, __pyx_L1_error)
      }
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_val;
    }

    /* "pandas/src/period.pyx":248
 * 
 *     mask = arr == iNaT
 *     if mask.any():      # NaT process             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             val = arr[i]
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":257
 *             result[i] = val
 *     else:
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             val = func(arr[i], relation, &finfo)
 *             if val == INT32_MIN:
 */
  /*else*/ {
    __pyx_t_1 = __pyx_v_n;
    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_1; __pyx_t_13+=1) {
      __pyx_v_i = __pyx_t_13;

      /* "pandas/src/period.pyx":258
 *     else:
 *         for i in range(n):
 *             val = func(arr[i], relation, &finfo)             # <<<<<<<<<<<<<<
 *             if val == INT32_MIN:
 *                 raise ValueError("Unable to convert to desired frequency.")
 */
      __pyx_t_16 = __pyx_v_i;
      __pyx_t_8 = -1;
      if (__pyx_t_16 < 0) {
        __pyx_t_16 += __pyx_pybuffernd_arr.diminfo[0].shape;
        if (unlikely(__pyx_t_16 < 0)) __pyx_t_8 = 0;
      } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_8 = 0;
      if (unlikely(__pyx_t_8 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_8);
        __PYX_ERR(0, 258, __pyx_L1_error)
      }
      __pyx_v_val = __pyx_v_func((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_arr.diminfo[0].strides)), __pyx_v_relation, (&__pyx_v_finfo));

      /* "pandas/src/period.pyx":259
 *         for i in range(n):
 *             val = func(arr[i], relation, &finfo)
 *             if val == INT32_MIN:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Unable to convert to desired frequency.")
 *             result[i] = val
 */
      __pyx_t_12 = ((__pyx_v_val == INT32_MIN) != 0);
      if (__pyx_t_12) {

        /* "pandas/src/period.pyx":260
 *             val = func(arr[i], relation, &finfo)
 *             if val == INT32_MIN:
 *                 raise ValueError("Unable to convert to desired frequency.")             # <<<<<<<<<<<<<<
 *             result[i] = val
 * 
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 260, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 260, __pyx_L1_error)

        /* "pandas/src/period.pyx":259
 *         for i in range(n):
 *             val = func(arr[i], relation, &finfo)
 *             if val == INT32_MIN:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Unable to convert to desired frequency.")
 *             result[i] = val
 */
      }

      /* "pandas/src/period.pyx":261
 *             if val == INT32_MIN:
 *                 raise ValueError("Unable to convert to desired frequency.")
 *             result[i] = val             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
      __pyx_t_17 = __pyx_v_i;
      __pyx_t_8 = -1;
      if (__pyx_t_17 < 0) {
        __pyx_t_17 += __pyx_pybuffernd_result.diminfo[0].shape;
        if (unlikely(__pyx_t_17 < 0)) __pyx_t_8 = 0;
      } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_8 = 0;
      if (unlikely(__pyx_t_8 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_8);
        __PYX_ERR(0, 261, __pyx_L1_error)
      }
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_val;
    }
  }
  __pyx_L4:;

  /* "pandas/src/period.pyx":263
 *             result[i] = val
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":223
 * 
 * 
 * def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end):             # <<<<<<<<<<<<<<
 *     """
 *     Convert int64-array of period ordinals from one frequency to another, and
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.period_asfreq_arr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_mask);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":266
 * 
 * 
 * def period_ordinal(int y, int m, int d, int h, int min,             # <<<<<<<<<<<<<<
 *                    int s, int us, int ps, int freq):
 *     cdef:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_9period_ordinal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_9period_ordinal = {"period_ordinal", (PyCFunction)__pyx_pw_6pandas_7_period_9period_ordinal, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_9period_ordinal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_y;
  int __pyx_v_m;
  int __pyx_v_d;
  int __pyx_v_h;
  int __pyx_v_min;
  int __pyx_v_s;
  int __pyx_v_us;
  int __pyx_v_ps;
  int __pyx_v_freq;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("period_ordinal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_y,&__pyx_n_s_m,&__pyx_n_s_d,&__pyx_n_s_h,&__pyx_n_s_min,&__pyx_n_s_s,&__pyx_n_s_us,&__pyx_n_s_ps,&__pyx_n_s_freq,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 1); __PYX_ERR(0, 266, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_d)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 2); __PYX_ERR(0, 266, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 3); __PYX_ERR(0, 266, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 4); __PYX_ERR(0, 266, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_s)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 5); __PYX_ERR(0, 266, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_us)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 6); __PYX_ERR(0, 266, __pyx_L3_error)
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ps)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 7); __PYX_ERR(0, 266, __pyx_L3_error)
        }
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, 8); __PYX_ERR(0, 266, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "period_ordinal") < 0)) __PYX_ERR(0, 266, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
    }
    __pyx_v_y = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_y == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L3_error)
    __pyx_v_m = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_m == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L3_error)
    __pyx_v_d = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_d == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L3_error)
    __pyx_v_h = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_h == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L3_error)
    __pyx_v_min = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_min == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L3_error)
    __pyx_v_s = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_s == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L3_error)
    __pyx_v_us = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_us == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L3_error)
    __pyx_v_ps = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_ps == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L3_error)
    __pyx_v_freq = __Pyx_PyInt_As_int(values[8]); if (unlikely((__pyx_v_freq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("period_ordinal", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 266, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.period_ordinal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_8period_ordinal(__pyx_self, __pyx_v_y, __pyx_v_m, __pyx_v_d, __pyx_v_h, __pyx_v_min, __pyx_v_s, __pyx_v_us, __pyx_v_ps, __pyx_v_freq);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_8period_ordinal(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_y, int __pyx_v_m, int __pyx_v_d, int __pyx_v_h, int __pyx_v_min, int __pyx_v_s, int __pyx_v_us, int __pyx_v_ps, int __pyx_v_freq) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __pyx_t_5numpy_int64_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("period_ordinal", 0);

  /* "pandas/src/period.pyx":271
 *         int64_t ordinal
 * 
 *     return get_period_ordinal(y, m, d, h, min, s, us, ps, freq)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = get_period_ordinal(__pyx_v_y, __pyx_v_m, __pyx_v_d, __pyx_v_h, __pyx_v_min, __pyx_v_s, __pyx_v_us, __pyx_v_ps, __pyx_v_freq); if (unlikely(__pyx_t_1 == INT32_MIN)) __PYX_ERR(0, 271, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":266
 * 
 * 
 * def period_ordinal(int y, int m, int d, int h, int min,             # <<<<<<<<<<<<<<
 *                    int s, int us, int ps, int freq):
 *     cdef:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pandas._period.period_ordinal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":274
 * 
 * 
 * cpdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) nogil:             # <<<<<<<<<<<<<<
 *     cdef:
 *         pandas_datetimestruct dts
 */

static PyObject *__pyx_pw_6pandas_7_period_11period_ordinal_to_dt64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static __pyx_t_5numpy_int64_t __pyx_f_6pandas_7_period_period_ordinal_to_dt64(__pyx_t_5numpy_int64_t __pyx_v_ordinal, int __pyx_v_freq, CYTHON_UNUSED int __pyx_skip_dispatch) {
  pandas_datetimestruct __pyx_v_dts;
  date_info __pyx_v_dinfo;
  float __pyx_v_subsecond_fraction;
  __pyx_t_5numpy_int64_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "pandas/src/period.pyx":280
 *         float subsecond_fraction
 * 
 *     if ordinal == NPY_NAT:             # <<<<<<<<<<<<<<
 *         return NPY_NAT
 * 
 */
  __pyx_t_1 = ((__pyx_v_ordinal == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":281
 * 
 *     if ordinal == NPY_NAT:
 *         return NPY_NAT             # <<<<<<<<<<<<<<
 * 
 *     get_date_info(ordinal, freq, &dinfo)
 */
    __pyx_r = __pyx_v_6pandas_7_period_NPY_NAT;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":280
 *         float subsecond_fraction
 * 
 *     if ordinal == NPY_NAT:             # <<<<<<<<<<<<<<
 *         return NPY_NAT
 * 
 */
  }

  /* "pandas/src/period.pyx":283
 *         return NPY_NAT
 * 
 *     get_date_info(ordinal, freq, &dinfo)             # <<<<<<<<<<<<<<
 * 
 *     dts.year = dinfo.year
 */
  __pyx_t_2 = get_date_info(__pyx_v_ordinal, __pyx_v_freq, (&__pyx_v_dinfo)); if (unlikely(__pyx_t_2 == INT32_MIN)) __PYX_ERR(0, 283, __pyx_L1_error)

  /* "pandas/src/period.pyx":285
 *     get_date_info(ordinal, freq, &dinfo)
 * 
 *     dts.year = dinfo.year             # <<<<<<<<<<<<<<
 *     dts.month = dinfo.month
 *     dts.day = dinfo.day
 */
  __pyx_t_2 = __pyx_v_dinfo.year;
  __pyx_v_dts.year = __pyx_t_2;

  /* "pandas/src/period.pyx":286
 * 
 *     dts.year = dinfo.year
 *     dts.month = dinfo.month             # <<<<<<<<<<<<<<
 *     dts.day = dinfo.day
 *     dts.hour = dinfo.hour
 */
  __pyx_t_2 = __pyx_v_dinfo.month;
  __pyx_v_dts.month = __pyx_t_2;

  /* "pandas/src/period.pyx":287
 *     dts.year = dinfo.year
 *     dts.month = dinfo.month
 *     dts.day = dinfo.day             # <<<<<<<<<<<<<<
 *     dts.hour = dinfo.hour
 *     dts.min = dinfo.minute
 */
  __pyx_t_2 = __pyx_v_dinfo.day;
  __pyx_v_dts.day = __pyx_t_2;

  /* "pandas/src/period.pyx":288
 *     dts.month = dinfo.month
 *     dts.day = dinfo.day
 *     dts.hour = dinfo.hour             # <<<<<<<<<<<<<<
 *     dts.min = dinfo.minute
 *     dts.sec = int(dinfo.second)
 */
  __pyx_t_2 = __pyx_v_dinfo.hour;
  __pyx_v_dts.hour = __pyx_t_2;

  /* "pandas/src/period.pyx":289
 *     dts.day = dinfo.day
 *     dts.hour = dinfo.hour
 *     dts.min = dinfo.minute             # <<<<<<<<<<<<<<
 *     dts.sec = int(dinfo.second)
 *     subsecond_fraction = dinfo.second - dts.sec
 */
  __pyx_t_2 = __pyx_v_dinfo.minute;
  __pyx_v_dts.min = __pyx_t_2;

  /* "pandas/src/period.pyx":290
 *     dts.hour = dinfo.hour
 *     dts.min = dinfo.minute
 *     dts.sec = int(dinfo.second)             # <<<<<<<<<<<<<<
 *     subsecond_fraction = dinfo.second - dts.sec
 *     dts.us = int((subsecond_fraction) * 1e6)
 */
  __pyx_v_dts.sec = ((npy_int32)__pyx_v_dinfo.second);

  /* "pandas/src/period.pyx":291
 *     dts.min = dinfo.minute
 *     dts.sec = int(dinfo.second)
 *     subsecond_fraction = dinfo.second - dts.sec             # <<<<<<<<<<<<<<
 *     dts.us = int((subsecond_fraction) * 1e6)
 *     dts.ps = int(((subsecond_fraction) * 1e6 - dts.us) * 1e6)
 */
  __pyx_v_subsecond_fraction = (__pyx_v_dinfo.second - __pyx_v_dts.sec);

  /* "pandas/src/period.pyx":292
 *     dts.sec = int(dinfo.second)
 *     subsecond_fraction = dinfo.second - dts.sec
 *     dts.us = int((subsecond_fraction) * 1e6)             # <<<<<<<<<<<<<<
 *     dts.ps = int(((subsecond_fraction) * 1e6 - dts.us) * 1e6)
 * 
 */
  __pyx_v_dts.us = ((npy_int32)(__pyx_v_subsecond_fraction * 1e6));

  /* "pandas/src/period.pyx":293
 *     subsecond_fraction = dinfo.second - dts.sec
 *     dts.us = int((subsecond_fraction) * 1e6)
 *     dts.ps = int(((subsecond_fraction) * 1e6 - dts.us) * 1e6)             # <<<<<<<<<<<<<<
 * 
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, &dts)
 */
  __pyx_v_dts.ps = ((npy_int32)(((__pyx_v_subsecond_fraction * 1e6) - __pyx_v_dts.us) * 1e6));

  /* "pandas/src/period.pyx":295
 *     dts.ps = int(((subsecond_fraction) * 1e6 - dts.us) * 1e6)
 * 
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, (&__pyx_v_dts));
  goto __pyx_L0;

  /* "pandas/src/period.pyx":274
 * 
 * 
 * cpdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) nogil:             # <<<<<<<<<<<<<<
 *     cdef:
 *         pandas_datetimestruct dts
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pandas._period.period_ordinal_to_dt64", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_11period_ordinal_to_dt64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_11period_ordinal_to_dt64(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __pyx_t_5numpy_int64_t __pyx_v_ordinal;
  int __pyx_v_freq;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("period_ordinal_to_dt64 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ordinal,&__pyx_n_s_freq,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ordinal)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_ordinal_to_dt64", 1, 2, 2, 1); __PYX_ERR(0, 274, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "period_ordinal_to_dt64") < 0)) __PYX_ERR(0, 274, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_ordinal = __Pyx_PyInt_As_npy_int64(values[0]); if (unlikely((__pyx_v_ordinal == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 274, __pyx_L3_error)
    __pyx_v_freq = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_freq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 274, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("period_ordinal_to_dt64", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 274, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.period_ordinal_to_dt64", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_10period_ordinal_to_dt64(__pyx_self, __pyx_v_ordinal, __pyx_v_freq);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_10period_ordinal_to_dt64(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_5numpy_int64_t __pyx_v_ordinal, int __pyx_v_freq) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("period_ordinal_to_dt64", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_f_6pandas_7_period_period_ordinal_to_dt64(__pyx_v_ordinal, __pyx_v_freq, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period.period_ordinal_to_dt64", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":298
 * 
 * 
 * def period_format(int64_t value, int freq, object fmt=None):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int freq_group
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_13period_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_13period_format = {"period_format", (PyCFunction)__pyx_pw_6pandas_7_period_13period_format, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_13period_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __pyx_t_5numpy_int64_t __pyx_v_value;
  int __pyx_v_freq;
  PyObject *__pyx_v_fmt = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("period_format (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_freq,&__pyx_n_s_fmt,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("period_format", 0, 2, 3, 1); __PYX_ERR(0, 298, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fmt);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "period_format") < 0)) __PYX_ERR(0, 298, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_value = __Pyx_PyInt_As_npy_int64(values[0]); if (unlikely((__pyx_v_value == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L3_error)
    __pyx_v_freq = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_freq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L3_error)
    __pyx_v_fmt = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("period_format", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 298, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.period_format", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_12period_format(__pyx_self, __pyx_v_value, __pyx_v_freq, __pyx_v_fmt);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_12period_format(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_5numpy_int64_t __pyx_v_value, int __pyx_v_freq, PyObject *__pyx_v_fmt) {
  int __pyx_v_freq_group;
  __pyx_t_5numpy_int64_t __pyx_v_left;
  __pyx_t_5numpy_int64_t __pyx_v_right;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("period_format", 0);
  __Pyx_INCREF(__pyx_v_fmt);

  /* "pandas/src/period.pyx":302
 *         int freq_group
 * 
 *     if value == iNaT:             # <<<<<<<<<<<<<<
 *         return repr(NaT)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_iNaT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "pandas/src/period.pyx":303
 * 
 *     if value == iNaT:
 *         return repr(NaT)             # <<<<<<<<<<<<<<
 * 
 *     if fmt is None:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_NaT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Repr(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":302
 *         int freq_group
 * 
 *     if value == iNaT:             # <<<<<<<<<<<<<<
 *         return repr(NaT)
 * 
 */
  }

  /* "pandas/src/period.pyx":305
 *         return repr(NaT)
 * 
 *     if fmt is None:             # <<<<<<<<<<<<<<
 *         freq_group = (freq // 1000) * 1000
 *         if freq_group == 1000: # FR_ANN
 */
  __pyx_t_4 = (__pyx_v_fmt == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pandas/src/period.pyx":306
 * 
 *     if fmt is None:
 *         freq_group = (freq // 1000) * 1000             # <<<<<<<<<<<<<<
 *         if freq_group == 1000: # FR_ANN
 *             fmt = b'%Y'
 */
    __pyx_v_freq_group = (__Pyx_div_long(__pyx_v_freq, 0x3E8) * 0x3E8);

    /* "pandas/src/period.pyx":307
 *     if fmt is None:
 *         freq_group = (freq // 1000) * 1000
 *         if freq_group == 1000: # FR_ANN             # <<<<<<<<<<<<<<
 *             fmt = b'%Y'
 *         elif freq_group == 2000: # FR_QTR
 */
    switch (__pyx_v_freq_group) {
      case 0x3E8:

      /* "pandas/src/period.pyx":308
 *         freq_group = (freq // 1000) * 1000
 *         if freq_group == 1000: # FR_ANN
 *             fmt = b'%Y'             # <<<<<<<<<<<<<<
 *         elif freq_group == 2000: # FR_QTR
 *             fmt = b'%FQ%q'
 */
      __Pyx_INCREF(__pyx_kp_b_Y);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y);

      /* "pandas/src/period.pyx":307
 *     if fmt is None:
 *         freq_group = (freq // 1000) * 1000
 *         if freq_group == 1000: # FR_ANN             # <<<<<<<<<<<<<<
 *             fmt = b'%Y'
 *         elif freq_group == 2000: # FR_QTR
 */
      break;

      /* "pandas/src/period.pyx":309
 *         if freq_group == 1000: # FR_ANN
 *             fmt = b'%Y'
 *         elif freq_group == 2000: # FR_QTR             # <<<<<<<<<<<<<<
 *             fmt = b'%FQ%q'
 *         elif freq_group == 3000: # FR_MTH
 */
      case 0x7D0:

      /* "pandas/src/period.pyx":310
 *             fmt = b'%Y'
 *         elif freq_group == 2000: # FR_QTR
 *             fmt = b'%FQ%q'             # <<<<<<<<<<<<<<
 *         elif freq_group == 3000: # FR_MTH
 *             fmt = b'%Y-%m'
 */
      __Pyx_INCREF(__pyx_kp_b_FQ_q);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_FQ_q);

      /* "pandas/src/period.pyx":309
 *         if freq_group == 1000: # FR_ANN
 *             fmt = b'%Y'
 *         elif freq_group == 2000: # FR_QTR             # <<<<<<<<<<<<<<
 *             fmt = b'%FQ%q'
 *         elif freq_group == 3000: # FR_MTH
 */
      break;

      /* "pandas/src/period.pyx":311
 *         elif freq_group == 2000: # FR_QTR
 *             fmt = b'%FQ%q'
 *         elif freq_group == 3000: # FR_MTH             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m'
 *         elif freq_group == 4000: # WK
 */
      case 0xBB8:

      /* "pandas/src/period.pyx":312
 *             fmt = b'%FQ%q'
 *         elif freq_group == 3000: # FR_MTH
 *             fmt = b'%Y-%m'             # <<<<<<<<<<<<<<
 *         elif freq_group == 4000: # WK
 *             left = period_asfreq(value, freq, 6000, 0)
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m);

      /* "pandas/src/period.pyx":311
 *         elif freq_group == 2000: # FR_QTR
 *             fmt = b'%FQ%q'
 *         elif freq_group == 3000: # FR_MTH             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m'
 *         elif freq_group == 4000: # WK
 */
      break;

      /* "pandas/src/period.pyx":313
 *         elif freq_group == 3000: # FR_MTH
 *             fmt = b'%Y-%m'
 *         elif freq_group == 4000: # WK             # <<<<<<<<<<<<<<
 *             left = period_asfreq(value, freq, 6000, 0)
 *             right = period_asfreq(value, freq, 6000, 1)
 */
      case 0xFA0:

      /* "pandas/src/period.pyx":314
 *             fmt = b'%Y-%m'
 *         elif freq_group == 4000: # WK
 *             left = period_asfreq(value, freq, 6000, 0)             # <<<<<<<<<<<<<<
 *             right = period_asfreq(value, freq, 6000, 1)
 *             return '%s/%s' % (period_format(left, 6000),
 */
      __pyx_v_left = __pyx_f_6pandas_7_period_period_asfreq(__pyx_v_value, __pyx_v_freq, 0x1770, 0, 0);

      /* "pandas/src/period.pyx":315
 *         elif freq_group == 4000: # WK
 *             left = period_asfreq(value, freq, 6000, 0)
 *             right = period_asfreq(value, freq, 6000, 1)             # <<<<<<<<<<<<<<
 *             return '%s/%s' % (period_format(left, 6000),
 *                               period_format(right, 6000))
 */
      __pyx_v_right = __pyx_f_6pandas_7_period_period_asfreq(__pyx_v_value, __pyx_v_freq, 0x1770, 1, 0);

      /* "pandas/src/period.pyx":316
 *             left = period_asfreq(value, freq, 6000, 0)
 *             right = period_asfreq(value, freq, 6000, 1)
 *             return '%s/%s' % (period_format(left, 6000),             # <<<<<<<<<<<<<<
 *                               period_format(right, 6000))
 *         elif (freq_group == 5000 # BUS
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_period_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_left); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
      __Pyx_INCREF(__pyx_int_6000);
      __Pyx_GIVEREF(__pyx_int_6000);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_int_6000);
      __pyx_t_1 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pandas/src/period.pyx":317
 *             right = period_asfreq(value, freq, 6000, 1)
 *             return '%s/%s' % (period_format(left, 6000),
 *                               period_format(right, 6000))             # <<<<<<<<<<<<<<
 *         elif (freq_group == 5000 # BUS
 *               or freq_group == 6000): # DAY
 */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_period_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_right); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
          __pyx_t_7 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_t_1);
      __Pyx_INCREF(__pyx_int_6000);
      __Pyx_GIVEREF(__pyx_int_6000);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_int_6000);
      __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "pandas/src/period.pyx":316
 *             left = period_asfreq(value, freq, 6000, 0)
 *             right = period_asfreq(value, freq, 6000, 1)
 *             return '%s/%s' % (period_format(left, 6000),             # <<<<<<<<<<<<<<
 *                               period_format(right, 6000))
 *         elif (freq_group == 5000 # BUS
 */
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":313
 *         elif freq_group == 3000: # FR_MTH
 *             fmt = b'%Y-%m'
 *         elif freq_group == 4000: # WK             # <<<<<<<<<<<<<<
 *             left = period_asfreq(value, freq, 6000, 0)
 *             right = period_asfreq(value, freq, 6000, 1)
 */
      break;

      /* "pandas/src/period.pyx":318
 *             return '%s/%s' % (period_format(left, 6000),
 *                               period_format(right, 6000))
 *         elif (freq_group == 5000 # BUS             # <<<<<<<<<<<<<<
 *               or freq_group == 6000): # DAY
 *             fmt = b'%Y-%m-%d'
 */
      case 0x1388:

      /* "pandas/src/period.pyx":319
 *                               period_format(right, 6000))
 *         elif (freq_group == 5000 # BUS
 *               or freq_group == 6000): # DAY             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d'
 *         elif freq_group == 7000: # HR
 */
      case 0x1770:

      /* "pandas/src/period.pyx":320
 *         elif (freq_group == 5000 # BUS
 *               or freq_group == 6000): # DAY
 *             fmt = b'%Y-%m-%d'             # <<<<<<<<<<<<<<
 *         elif freq_group == 7000: # HR
 *             fmt = b'%Y-%m-%d %H:00'
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m_d);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m_d);

      /* "pandas/src/period.pyx":318
 *             return '%s/%s' % (period_format(left, 6000),
 *                               period_format(right, 6000))
 *         elif (freq_group == 5000 # BUS             # <<<<<<<<<<<<<<
 *               or freq_group == 6000): # DAY
 *             fmt = b'%Y-%m-%d'
 */
      break;

      /* "pandas/src/period.pyx":321
 *               or freq_group == 6000): # DAY
 *             fmt = b'%Y-%m-%d'
 *         elif freq_group == 7000: # HR             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:00'
 *         elif freq_group == 8000: # MIN
 */
      case 0x1B58:

      /* "pandas/src/period.pyx":322
 *             fmt = b'%Y-%m-%d'
 *         elif freq_group == 7000: # HR
 *             fmt = b'%Y-%m-%d %H:00'             # <<<<<<<<<<<<<<
 *         elif freq_group == 8000: # MIN
 *             fmt = b'%Y-%m-%d %H:%M'
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m_d_H_00);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m_d_H_00);

      /* "pandas/src/period.pyx":321
 *               or freq_group == 6000): # DAY
 *             fmt = b'%Y-%m-%d'
 *         elif freq_group == 7000: # HR             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:00'
 *         elif freq_group == 8000: # MIN
 */
      break;

      /* "pandas/src/period.pyx":323
 *         elif freq_group == 7000: # HR
 *             fmt = b'%Y-%m-%d %H:00'
 *         elif freq_group == 8000: # MIN             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M'
 *         elif freq_group == 9000: # SEC
 */
      case 0x1F40:

      /* "pandas/src/period.pyx":324
 *             fmt = b'%Y-%m-%d %H:00'
 *         elif freq_group == 8000: # MIN
 *             fmt = b'%Y-%m-%d %H:%M'             # <<<<<<<<<<<<<<
 *         elif freq_group == 9000: # SEC
 *             fmt = b'%Y-%m-%d %H:%M:%S'
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m_d_H_M);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m_d_H_M);

      /* "pandas/src/period.pyx":323
 *         elif freq_group == 7000: # HR
 *             fmt = b'%Y-%m-%d %H:00'
 *         elif freq_group == 8000: # MIN             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M'
 *         elif freq_group == 9000: # SEC
 */
      break;

      /* "pandas/src/period.pyx":325
 *         elif freq_group == 8000: # MIN
 *             fmt = b'%Y-%m-%d %H:%M'
 *         elif freq_group == 9000: # SEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S'
 *         elif freq_group == 10000: # MILLISEC
 */
      case 0x2328:

      /* "pandas/src/period.pyx":326
 *             fmt = b'%Y-%m-%d %H:%M'
 *         elif freq_group == 9000: # SEC
 *             fmt = b'%Y-%m-%d %H:%M:%S'             # <<<<<<<<<<<<<<
 *         elif freq_group == 10000: # MILLISEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%l'
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m_d_H_M_S);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m_d_H_M_S);

      /* "pandas/src/period.pyx":325
 *         elif freq_group == 8000: # MIN
 *             fmt = b'%Y-%m-%d %H:%M'
 *         elif freq_group == 9000: # SEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S'
 *         elif freq_group == 10000: # MILLISEC
 */
      break;

      /* "pandas/src/period.pyx":327
 *         elif freq_group == 9000: # SEC
 *             fmt = b'%Y-%m-%d %H:%M:%S'
 *         elif freq_group == 10000: # MILLISEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S.%l'
 *         elif freq_group == 11000: # MICROSEC
 */
      case 0x2710:

      /* "pandas/src/period.pyx":328
 *             fmt = b'%Y-%m-%d %H:%M:%S'
 *         elif freq_group == 10000: # MILLISEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%l'             # <<<<<<<<<<<<<<
 *         elif freq_group == 11000: # MICROSEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%u'
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m_d_H_M_S_l);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m_d_H_M_S_l);

      /* "pandas/src/period.pyx":327
 *         elif freq_group == 9000: # SEC
 *             fmt = b'%Y-%m-%d %H:%M:%S'
 *         elif freq_group == 10000: # MILLISEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S.%l'
 *         elif freq_group == 11000: # MICROSEC
 */
      break;

      /* "pandas/src/period.pyx":329
 *         elif freq_group == 10000: # MILLISEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%l'
 *         elif freq_group == 11000: # MICROSEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S.%u'
 *         elif freq_group == 12000: # NANOSEC
 */
      case 0x2AF8:

      /* "pandas/src/period.pyx":330
 *             fmt = b'%Y-%m-%d %H:%M:%S.%l'
 *         elif freq_group == 11000: # MICROSEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%u'             # <<<<<<<<<<<<<<
 *         elif freq_group == 12000: # NANOSEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%n'
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m_d_H_M_S_u);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m_d_H_M_S_u);

      /* "pandas/src/period.pyx":329
 *         elif freq_group == 10000: # MILLISEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%l'
 *         elif freq_group == 11000: # MICROSEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S.%u'
 *         elif freq_group == 12000: # NANOSEC
 */
      break;

      /* "pandas/src/period.pyx":331
 *         elif freq_group == 11000: # MICROSEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%u'
 *         elif freq_group == 12000: # NANOSEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S.%n'
 *         else:
 */
      case 0x2EE0:

      /* "pandas/src/period.pyx":332
 *             fmt = b'%Y-%m-%d %H:%M:%S.%u'
 *         elif freq_group == 12000: # NANOSEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%n'             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('Unknown freq: %d' % freq)
 */
      __Pyx_INCREF(__pyx_kp_b_Y_m_d_H_M_S_n);
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_kp_b_Y_m_d_H_M_S_n);

      /* "pandas/src/period.pyx":331
 *         elif freq_group == 11000: # MICROSEC
 *             fmt = b'%Y-%m-%d %H:%M:%S.%u'
 *         elif freq_group == 12000: # NANOSEC             # <<<<<<<<<<<<<<
 *             fmt = b'%Y-%m-%d %H:%M:%S.%n'
 *         else:
 */
      break;
      default:

      /* "pandas/src/period.pyx":334
 *             fmt = b'%Y-%m-%d %H:%M:%S.%n'
 *         else:
 *             raise ValueError('Unknown freq: %d' % freq)             # <<<<<<<<<<<<<<
 * 
 *     return _period_strftime(value, freq, fmt)
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_freq_d, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 334, __pyx_L1_error)
      break;
    }

    /* "pandas/src/period.pyx":305
 *         return repr(NaT)
 * 
 *     if fmt is None:             # <<<<<<<<<<<<<<
 *         freq_group = (freq // 1000) * 1000
 *         if freq_group == 1000: # FR_ANN
 */
  }

  /* "pandas/src/period.pyx":336
 *             raise ValueError('Unknown freq: %d' % freq)
 * 
 *     return _period_strftime(value, freq, fmt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = __pyx_f_6pandas_7_period__period_strftime(__pyx_v_value, __pyx_v_freq, __pyx_v_fmt); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":298
 * 
 * 
 * def period_format(int64_t value, int freq, object fmt=None):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int freq_group
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pandas._period.period_format", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fmt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":349
 *                             "^`GH`^", "^`IJ`^", "^`KL`^"]
 * 
 * cdef object _period_strftime(int64_t value, int freq, object fmt):             # <<<<<<<<<<<<<<
 *     import sys
 * 
 */

static PyObject *__pyx_f_6pandas_7_period__period_strftime(__pyx_t_5numpy_int64_t __pyx_v_value, int __pyx_v_freq, PyObject *__pyx_v_fmt) {
  CYTHON_UNUSED PyObject *__pyx_v_sys = NULL;
  Py_ssize_t __pyx_v_i;
  date_info __pyx_v_dinfo;
  char *__pyx_v_formatted;
  PyObject *__pyx_v_pat = 0;
  PyObject *__pyx_v_repl = 0;
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_v_found_pat = 0;
  int __pyx_v_year;
  int __pyx_v_quarter;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  char *__pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannySetupContext("_period_strftime", 0);
  __Pyx_INCREF(__pyx_v_fmt);

  /* "pandas/src/period.pyx":350
 * 
 * cdef object _period_strftime(int64_t value, int freq, object fmt):
 *     import sys             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_sys = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":357
 *         char *formatted
 *         object pat, repl, result
 *         list found_pat = [False] * len(extra_fmts)             # <<<<<<<<<<<<<<
 *         int year, quarter
 * 
 */
  __pyx_t_1 = __pyx_v_6pandas_7_period_extra_fmts;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 357, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(1 * ((__pyx_t_2<0) ? 0:__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < __pyx_t_2; __pyx_temp++) {
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      PyList_SET_ITEM(__pyx_t_1, __pyx_temp, Py_False);
    }
  }
  __pyx_v_found_pat = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":360
 *         int year, quarter
 * 
 *     if PyUnicode_Check(fmt):             # <<<<<<<<<<<<<<
 *         fmt = fmt.encode('utf-8')
 * 
 */
  __pyx_t_3 = (PyUnicode_Check(__pyx_v_fmt) != 0);
  if (__pyx_t_3) {

    /* "pandas/src/period.pyx":361
 * 
 *     if PyUnicode_Check(fmt):
 *         fmt = fmt.encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *     get_date_info(value, freq, &dinfo)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_fmt, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":360
 *         int year, quarter
 * 
 *     if PyUnicode_Check(fmt):             # <<<<<<<<<<<<<<
 *         fmt = fmt.encode('utf-8')
 * 
 */
  }

  /* "pandas/src/period.pyx":363
 *         fmt = fmt.encode('utf-8')
 * 
 *     get_date_info(value, freq, &dinfo)             # <<<<<<<<<<<<<<
 *     for i in range(len(extra_fmts)):
 *         pat = extra_fmts[i][0]
 */
  __pyx_t_5 = get_date_info(__pyx_v_value, __pyx_v_freq, (&__pyx_v_dinfo)); if (unlikely(__pyx_t_5 == INT32_MIN)) __PYX_ERR(0, 363, __pyx_L1_error)

  /* "pandas/src/period.pyx":364
 * 
 *     get_date_info(value, freq, &dinfo)
 *     for i in range(len(extra_fmts)):             # <<<<<<<<<<<<<<
 *         pat = extra_fmts[i][0]
 *         repl = extra_fmts[i][1]
 */
  __pyx_t_4 = __pyx_v_6pandas_7_period_extra_fmts;
  __Pyx_INCREF(__pyx_t_4);
  if (unlikely(__pyx_t_4 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 364, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_4); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 364, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_2; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "pandas/src/period.pyx":365
 *     get_date_info(value, freq, &dinfo)
 *     for i in range(len(extra_fmts)):
 *         pat = extra_fmts[i][0]             # <<<<<<<<<<<<<<
 *         repl = extra_fmts[i][1]
 *         if pat in fmt:
 */
    if (unlikely(__pyx_v_6pandas_7_period_extra_fmts == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 365, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_6pandas_7_period_extra_fmts, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_pat, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":366
 *     for i in range(len(extra_fmts)):
 *         pat = extra_fmts[i][0]
 *         repl = extra_fmts[i][1]             # <<<<<<<<<<<<<<
 *         if pat in fmt:
 *             fmt = fmt.replace(pat, repl)
 */
    if (unlikely(__pyx_v_6pandas_7_period_extra_fmts == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 366, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_6pandas_7_period_extra_fmts, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":367
 *         pat = extra_fmts[i][0]
 *         repl = extra_fmts[i][1]
 *         if pat in fmt:             # <<<<<<<<<<<<<<
 *             fmt = fmt.replace(pat, repl)
 *             found_pat[i] = True
 */
    __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_pat, __pyx_v_fmt, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 367, __pyx_L1_error)
    __pyx_t_7 = (__pyx_t_3 != 0);
    if (__pyx_t_7) {

      /* "pandas/src/period.pyx":368
 *         repl = extra_fmts[i][1]
 *         if pat in fmt:
 *             fmt = fmt.replace(pat, repl)             # <<<<<<<<<<<<<<
 *             found_pat[i] = True
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_fmt, __pyx_n_s_replace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_9 = 1;
        }
      }
      __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_v_pat);
      __Pyx_GIVEREF(__pyx_v_pat);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_pat);
      __Pyx_INCREF(__pyx_v_repl);
      __Pyx_GIVEREF(__pyx_v_repl);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_repl);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_fmt, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "pandas/src/period.pyx":369
 *         if pat in fmt:
 *             fmt = fmt.replace(pat, repl)
 *             found_pat[i] = True             # <<<<<<<<<<<<<<
 * 
 *     formatted = c_strftime(&dinfo, <char*> fmt)
 */
      if (unlikely(__Pyx_SetItemInt(__pyx_v_found_pat, __pyx_v_i, Py_True, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0)) __PYX_ERR(0, 369, __pyx_L1_error)

      /* "pandas/src/period.pyx":367
 *         pat = extra_fmts[i][0]
 *         repl = extra_fmts[i][1]
 *         if pat in fmt:             # <<<<<<<<<<<<<<
 *             fmt = fmt.replace(pat, repl)
 *             found_pat[i] = True
 */
    }
  }

  /* "pandas/src/period.pyx":371
 *             found_pat[i] = True
 * 
 *     formatted = c_strftime(&dinfo, <char*> fmt)             # <<<<<<<<<<<<<<
 * 
 *     result = util.char_to_string(formatted)
 */
  __pyx_t_11 = __Pyx_PyObject_AsString(__pyx_v_fmt); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 371, __pyx_L1_error)
  __pyx_v_formatted = c_strftime((&__pyx_v_dinfo), ((char *)__pyx_t_11));

  /* "pandas/src/period.pyx":373
 *     formatted = c_strftime(&dinfo, <char*> fmt)
 * 
 *     result = util.char_to_string(formatted)             # <<<<<<<<<<<<<<
 *     free(formatted)
 * 
 */
  __pyx_t_4 = char_to_string(__pyx_v_formatted); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":374
 * 
 *     result = util.char_to_string(formatted)
 *     free(formatted)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(len(extra_fmts)):
 */
  free(__pyx_v_formatted);

  /* "pandas/src/period.pyx":376
 *     free(formatted)
 * 
 *     for i in range(len(extra_fmts)):             # <<<<<<<<<<<<<<
 *         if found_pat[i]:
 *             if get_yq(value, freq, &quarter, &year) < 0:
 */
  __pyx_t_4 = __pyx_v_6pandas_7_period_extra_fmts;
  __Pyx_INCREF(__pyx_t_4);
  if (unlikely(__pyx_t_4 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 376, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_4); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_2; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "pandas/src/period.pyx":377
 * 
 *     for i in range(len(extra_fmts)):
 *         if found_pat[i]:             # <<<<<<<<<<<<<<
 *             if get_yq(value, freq, &quarter, &year) < 0:
 *                 raise ValueError('Unable to get quarter and year')
 */
    __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_found_pat, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 377, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 377, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_7) {

      /* "pandas/src/period.pyx":378
 *     for i in range(len(extra_fmts)):
 *         if found_pat[i]:
 *             if get_yq(value, freq, &quarter, &year) < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Unable to get quarter and year')
 * 
 */
      __pyx_t_7 = ((get_yq(__pyx_v_value, __pyx_v_freq, (&__pyx_v_quarter), (&__pyx_v_year)) < 0) != 0);
      if (__pyx_t_7) {

        /* "pandas/src/period.pyx":379
 *         if found_pat[i]:
 *             if get_yq(value, freq, &quarter, &year) < 0:
 *                 raise ValueError('Unable to get quarter and year')             # <<<<<<<<<<<<<<
 * 
 *             if i == 0:
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 379, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 379, __pyx_L1_error)

        /* "pandas/src/period.pyx":378
 *     for i in range(len(extra_fmts)):
 *         if found_pat[i]:
 *             if get_yq(value, freq, &quarter, &year) < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Unable to get quarter and year')
 * 
 */
      }

      /* "pandas/src/period.pyx":381
 *                 raise ValueError('Unable to get quarter and year')
 * 
 *             if i == 0:             # <<<<<<<<<<<<<<
 *                 repl = '%d' % quarter
 *             elif i == 1:  # %f, 2-digit year
 */
      switch (__pyx_v_i) {
        case 0:

        /* "pandas/src/period.pyx":382
 * 
 *             if i == 0:
 *                 repl = '%d' % quarter             # <<<<<<<<<<<<<<
 *             elif i == 1:  # %f, 2-digit year
 *                 repl = '%.2d' % (year % 100)
 */
        __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_quarter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 382, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_d_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 382, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pandas/src/period.pyx":381
 *                 raise ValueError('Unable to get quarter and year')
 * 
 *             if i == 0:             # <<<<<<<<<<<<<<
 *                 repl = '%d' % quarter
 *             elif i == 1:  # %f, 2-digit year
 */
        break;

        /* "pandas/src/period.pyx":383
 *             if i == 0:
 *                 repl = '%d' % quarter
 *             elif i == 1:  # %f, 2-digit year             # <<<<<<<<<<<<<<
 *                 repl = '%.2d' % (year % 100)
 *             elif i == 2:
 */
        case 1:

        /* "pandas/src/period.pyx":384
 *                 repl = '%d' % quarter
 *             elif i == 1:  # %f, 2-digit year
 *                 repl = '%.2d' % (year % 100)             # <<<<<<<<<<<<<<
 *             elif i == 2:
 *                 repl = '%d' % year
 */
        __pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_mod_long(__pyx_v_year, 0x64)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_2d, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 384, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "pandas/src/period.pyx":383
 *             if i == 0:
 *                 repl = '%d' % quarter
 *             elif i == 1:  # %f, 2-digit year             # <<<<<<<<<<<<<<
 *                 repl = '%.2d' % (year % 100)
 *             elif i == 2:
 */
        break;

        /* "pandas/src/period.pyx":385
 *             elif i == 1:  # %f, 2-digit year
 *                 repl = '%.2d' % (year % 100)
 *             elif i == 2:             # <<<<<<<<<<<<<<
 *                 repl = '%d' % year
 *             elif i == 3:
 */
        case 2:

        /* "pandas/src/period.pyx":386
 *                 repl = '%.2d' % (year % 100)
 *             elif i == 2:
 *                 repl = '%d' % year             # <<<<<<<<<<<<<<
 *             elif i == 3:
 *                 repl = '%03d' % (value % 1000)
 */
        __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_year); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 386, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_d_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pandas/src/period.pyx":385
 *             elif i == 1:  # %f, 2-digit year
 *                 repl = '%.2d' % (year % 100)
 *             elif i == 2:             # <<<<<<<<<<<<<<
 *                 repl = '%d' % year
 *             elif i == 3:
 */
        break;

        /* "pandas/src/period.pyx":387
 *             elif i == 2:
 *                 repl = '%d' % year
 *             elif i == 3:             # <<<<<<<<<<<<<<
 *                 repl = '%03d' % (value % 1000)
 *             elif i == 4:
 */
        case 3:

        /* "pandas/src/period.pyx":388
 *                 repl = '%d' % year
 *             elif i == 3:
 *                 repl = '%03d' % (value % 1000)             # <<<<<<<<<<<<<<
 *             elif i == 4:
 *                 repl = '%06d' % (value % 1000000)
 */
        __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__Pyx_mod___pyx_t_5numpy_int64_t(__pyx_v_value, 0x3E8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_03d, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 388, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "pandas/src/period.pyx":387
 *             elif i == 2:
 *                 repl = '%d' % year
 *             elif i == 3:             # <<<<<<<<<<<<<<
 *                 repl = '%03d' % (value % 1000)
 *             elif i == 4:
 */
        break;

        /* "pandas/src/period.pyx":389
 *             elif i == 3:
 *                 repl = '%03d' % (value % 1000)
 *             elif i == 4:             # <<<<<<<<<<<<<<
 *                 repl = '%06d' % (value % 1000000)
 *             elif i == 5:
 */
        case 4:

        /* "pandas/src/period.pyx":390
 *                 repl = '%03d' % (value % 1000)
 *             elif i == 4:
 *                 repl = '%06d' % (value % 1000000)             # <<<<<<<<<<<<<<
 *             elif i == 5:
 *                 repl = '%09d' % (value % 1000000000)
 */
        __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__Pyx_mod___pyx_t_5numpy_int64_t(__pyx_v_value, 0xF4240)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_06d, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pandas/src/period.pyx":389
 *             elif i == 3:
 *                 repl = '%03d' % (value % 1000)
 *             elif i == 4:             # <<<<<<<<<<<<<<
 *                 repl = '%06d' % (value % 1000000)
 *             elif i == 5:
 */
        break;

        /* "pandas/src/period.pyx":391
 *             elif i == 4:
 *                 repl = '%06d' % (value % 1000000)
 *             elif i == 5:             # <<<<<<<<<<<<<<
 *                 repl = '%09d' % (value % 1000000000)
 * 
 */
        case 5:

        /* "pandas/src/period.pyx":392
 *                 repl = '%06d' % (value % 1000000)
 *             elif i == 5:
 *                 repl = '%09d' % (value % 1000000000)             # <<<<<<<<<<<<<<
 * 
 *             result = result.replace(str_extra_fmts[i], repl)
 */
        __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__Pyx_mod___pyx_t_5numpy_int64_t(__pyx_v_value, 0x3B9ACA00)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 392, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_09d, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "pandas/src/period.pyx":391
 *             elif i == 4:
 *                 repl = '%06d' % (value % 1000000)
 *             elif i == 5:             # <<<<<<<<<<<<<<
 *                 repl = '%09d' % (value % 1000000000)
 * 
 */
        break;
        default: break;
      }

      /* "pandas/src/period.pyx":394
 *                 repl = '%09d' % (value % 1000000000)
 * 
 *             result = result.replace(str_extra_fmts[i], repl)             # <<<<<<<<<<<<<<
 * 
 *     if PY2:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_replace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__pyx_v_6pandas_7_period_str_extra_fmts == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 394, __pyx_L1_error)
      }
      __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_6pandas_7_period_str_extra_fmts, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (unlikely(!__pyx_v_repl)) { __Pyx_RaiseUnboundLocalError("repl"); __PYX_ERR(0, 394, __pyx_L1_error) }
      __pyx_t_8 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_9 = 1;
        }
      }
      __pyx_t_12 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_9, __pyx_t_10);
      __Pyx_INCREF(__pyx_v_repl);
      __Pyx_GIVEREF(__pyx_v_repl);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_9, __pyx_v_repl);
      __pyx_t_10 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "pandas/src/period.pyx":377
 * 
 *     for i in range(len(extra_fmts)):
 *         if found_pat[i]:             # <<<<<<<<<<<<<<
 *             if get_yq(value, freq, &quarter, &year) < 0:
 *                 raise ValueError('Unable to get quarter and year')
 */
    }
  }

  /* "pandas/src/period.pyx":396
 *             result = result.replace(str_extra_fmts[i], repl)
 * 
 *     if PY2:             # <<<<<<<<<<<<<<
 *         result = result.decode('utf-8', 'ignore')
 * 
 */
  __pyx_t_7 = (__pyx_v_6pandas_7_period_PY2 != 0);
  if (__pyx_t_7) {

    /* "pandas/src/period.pyx":397
 * 
 *     if PY2:
 *         result = result.decode('utf-8', 'ignore')             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":396
 *             result = result.replace(str_extra_fmts[i], repl)
 * 
 *     if PY2:             # <<<<<<<<<<<<<<
 *         result = result.decode('utf-8', 'ignore')
 * 
 */
  }

  /* "pandas/src/period.pyx":399
 *         result = result.decode('utf-8', 'ignore')
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # period accessors
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":349
 *                             "^`GH`^", "^`IJ`^", "^`KL`^"]
 * 
 * cdef object _period_strftime(int64_t value, int freq, object fmt):             # <<<<<<<<<<<<<<
 *     import sys
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pandas._period._period_strftime", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sys);
  __Pyx_XDECREF(__pyx_v_pat);
  __Pyx_XDECREF(__pyx_v_repl);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_found_pat);
  __Pyx_XDECREF(__pyx_v_fmt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":406
 * 
 * 
 * def get_period_field(int code, int64_t value, int freq):             # <<<<<<<<<<<<<<
 *     cdef accessor f = _get_accessor_func(code)
 *     if f is NULL:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_15get_period_field(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_15get_period_field = {"get_period_field", (PyCFunction)__pyx_pw_6pandas_7_period_15get_period_field, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_15get_period_field(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_code;
  __pyx_t_5numpy_int64_t __pyx_v_value;
  int __pyx_v_freq;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_period_field (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_code,&__pyx_n_s_value,&__pyx_n_s_freq,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_code)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_period_field", 1, 3, 3, 1); __PYX_ERR(0, 406, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_period_field", 1, 3, 3, 2); __PYX_ERR(0, 406, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_period_field") < 0)) __PYX_ERR(0, 406, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_code = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L3_error)
    __pyx_v_value = __Pyx_PyInt_As_npy_int64(values[1]); if (unlikely((__pyx_v_value == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L3_error)
    __pyx_v_freq = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_freq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_period_field", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 406, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.get_period_field", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_14get_period_field(__pyx_self, __pyx_v_code, __pyx_v_value, __pyx_v_freq);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_14get_period_field(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_code, __pyx_t_5numpy_int64_t __pyx_v_value, int __pyx_v_freq) {
  __pyx_t_6pandas_7_period_accessor __pyx_v_f;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("get_period_field", 0);

  /* "pandas/src/period.pyx":407
 * 
 * def get_period_field(int code, int64_t value, int freq):
 *     cdef accessor f = _get_accessor_func(code)             # <<<<<<<<<<<<<<
 *     if f is NULL:
 *         raise ValueError('Unrecognized period code: %d' % code)
 */
  __pyx_v_f = __pyx_f_6pandas_7_period__get_accessor_func(__pyx_v_code);

  /* "pandas/src/period.pyx":408
 * def get_period_field(int code, int64_t value, int freq):
 *     cdef accessor f = _get_accessor_func(code)
 *     if f is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unrecognized period code: %d' % code)
 *     if value == iNaT:
 */
  __pyx_t_1 = ((__pyx_v_f == NULL) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":409
 *     cdef accessor f = _get_accessor_func(code)
 *     if f is NULL:
 *         raise ValueError('Unrecognized period code: %d' % code)             # <<<<<<<<<<<<<<
 *     if value == iNaT:
 *         return np.nan
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unrecognized_period_code_d, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 409, __pyx_L1_error)

    /* "pandas/src/period.pyx":408
 * def get_period_field(int code, int64_t value, int freq):
 *     cdef accessor f = _get_accessor_func(code)
 *     if f is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unrecognized period code: %d' % code)
 *     if value == iNaT:
 */
  }

  /* "pandas/src/period.pyx":410
 *     if f is NULL:
 *         raise ValueError('Unrecognized period code: %d' % code)
 *     if value == iNaT:             # <<<<<<<<<<<<<<
 *         return np.nan
 *     return f(value, freq)
 */
  __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_iNaT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":411
 *         raise ValueError('Unrecognized period code: %d' % code)
 *     if value == iNaT:
 *         return np.nan             # <<<<<<<<<<<<<<
 *     return f(value, freq)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":410
 *     if f is NULL:
 *         raise ValueError('Unrecognized period code: %d' % code)
 *     if value == iNaT:             # <<<<<<<<<<<<<<
 *         return np.nan
 *     return f(value, freq)
 */
  }

  /* "pandas/src/period.pyx":412
 *     if value == iNaT:
 *         return np.nan
 *     return f(value, freq)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_v_f(__pyx_v_value, __pyx_v_freq); if (unlikely(__pyx_t_5 == INT32_MIN)) __PYX_ERR(0, 412, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":406
 * 
 * 
 * def get_period_field(int code, int64_t value, int freq):             # <<<<<<<<<<<<<<
 *     cdef accessor f = _get_accessor_func(code)
 *     if f is NULL:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pandas._period.get_period_field", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":415
 * 
 * 
 * def get_period_field_arr(int code, ndarray[int64_t] arr, int freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, sz
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_17get_period_field_arr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_17get_period_field_arr = {"get_period_field_arr", (PyCFunction)__pyx_pw_6pandas_7_period_17get_period_field_arr, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_17get_period_field_arr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_code;
  PyArrayObject *__pyx_v_arr = 0;
  int __pyx_v_freq;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_period_field_arr (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_code,&__pyx_n_s_arr,&__pyx_n_s_freq,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_code)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_period_field_arr", 1, 3, 3, 1); __PYX_ERR(0, 415, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_period_field_arr", 1, 3, 3, 2); __PYX_ERR(0, 415, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_period_field_arr") < 0)) __PYX_ERR(0, 415, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_code = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_code == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L3_error)
    __pyx_v_arr = ((PyArrayObject *)values[1]);
    __pyx_v_freq = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_freq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_period_field_arr", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 415, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.get_period_field_arr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_5numpy_ndarray, 1, "arr", 0))) __PYX_ERR(0, 415, __pyx_L1_error)
  __pyx_r = __pyx_pf_6pandas_7_period_16get_period_field_arr(__pyx_self, __pyx_v_code, __pyx_v_arr, __pyx_v_freq);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_16get_period_field_arr(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_code, PyArrayObject *__pyx_v_arr, int __pyx_v_freq) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_sz;
  PyArrayObject *__pyx_v_out = 0;
  __pyx_t_6pandas_7_period_accessor __pyx_v_f;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_arr;
  __Pyx_Buffer __pyx_pybuffer_arr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
  __Pyx_Buffer __pyx_pybuffer_out;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  int __pyx_t_18;
  __Pyx_RefNannySetupContext("get_period_field_arr", 0);
  __pyx_pybuffer_out.pybuffer.buf = NULL;
  __pyx_pybuffer_out.refcount = 0;
  __pyx_pybuffernd_out.data = NULL;
  __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
  __pyx_pybuffer_arr.pybuffer.buf = NULL;
  __pyx_pybuffer_arr.refcount = 0;
  __pyx_pybuffernd_arr.data = NULL;
  __pyx_pybuffernd_arr.rcbuffer = &__pyx_pybuffer_arr;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_arr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 415, __pyx_L1_error)
  }
  __pyx_pybuffernd_arr.diminfo[0].strides = __pyx_pybuffernd_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_arr.diminfo[0].shape = __pyx_pybuffernd_arr.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":421
 *         accessor f
 * 
 *     f = _get_accessor_func(code)             # <<<<<<<<<<<<<<
 *     if f is NULL:
 *         raise ValueError('Unrecognized period code: %d' % code)
 */
  __pyx_v_f = __pyx_f_6pandas_7_period__get_accessor_func(__pyx_v_code);

  /* "pandas/src/period.pyx":422
 * 
 *     f = _get_accessor_func(code)
 *     if f is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unrecognized period code: %d' % code)
 * 
 */
  __pyx_t_1 = ((__pyx_v_f == NULL) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":423
 *     f = _get_accessor_func(code)
 *     if f is NULL:
 *         raise ValueError('Unrecognized period code: %d' % code)             # <<<<<<<<<<<<<<
 * 
 *     sz = len(arr)
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unrecognized_period_code_d, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 423, __pyx_L1_error)

    /* "pandas/src/period.pyx":422
 * 
 *     f = _get_accessor_func(code)
 *     if f is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unrecognized period code: %d' % code)
 * 
 */
  }

  /* "pandas/src/period.pyx":425
 *         raise ValueError('Unrecognized period code: %d' % code)
 * 
 *     sz = len(arr)             # <<<<<<<<<<<<<<
 *     out = np.empty(sz, dtype=np.int64)
 * 
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_arr)); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 425, __pyx_L1_error)
  __pyx_v_sz = __pyx_t_4;

  /* "pandas/src/period.pyx":426
 * 
 *     sz = len(arr)
 *     out = np.empty(sz, dtype=np.int64)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(sz):
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_sz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 426, __pyx_L1_error)
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 426, __pyx_L1_error)
  }
  __pyx_t_8 = 0;
  __pyx_v_out = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "pandas/src/period.pyx":428
 *     out = np.empty(sz, dtype=np.int64)
 * 
 *     for i in range(sz):             # <<<<<<<<<<<<<<
 *         if arr[i] == iNaT:
 *             out[i] = -1
 */
  __pyx_t_4 = __pyx_v_sz;
  for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_4; __pyx_t_13+=1) {
    __pyx_v_i = __pyx_t_13;

    /* "pandas/src/period.pyx":429
 * 
 *     for i in range(sz):
 *         if arr[i] == iNaT:             # <<<<<<<<<<<<<<
 *             out[i] = -1
 *             continue
 */
    __pyx_t_14 = __pyx_v_i;
    __pyx_t_9 = -1;
    if (__pyx_t_14 < 0) {
      __pyx_t_14 += __pyx_pybuffernd_arr.diminfo[0].shape;
      if (unlikely(__pyx_t_14 < 0)) __pyx_t_9 = 0;
    } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      __PYX_ERR(0, 429, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_PyInt_From_npy_int64((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_arr.diminfo[0].strides))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_iNaT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_1) {

      /* "pandas/src/period.pyx":430
 *     for i in range(sz):
 *         if arr[i] == iNaT:
 *             out[i] = -1             # <<<<<<<<<<<<<<
 *             continue
 *         out[i] = f(arr[i], freq)
 */
      __pyx_t_15 = __pyx_v_i;
      __pyx_t_9 = -1;
      if (__pyx_t_15 < 0) {
        __pyx_t_15 += __pyx_pybuffernd_out.diminfo[0].shape;
        if (unlikely(__pyx_t_15 < 0)) __pyx_t_9 = 0;
      } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_out.diminfo[0].shape)) __pyx_t_9 = 0;
      if (unlikely(__pyx_t_9 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_9);
        __PYX_ERR(0, 430, __pyx_L1_error)
      }
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_out.diminfo[0].strides) = -1LL;

      /* "pandas/src/period.pyx":431
 *         if arr[i] == iNaT:
 *             out[i] = -1
 *             continue             # <<<<<<<<<<<<<<
 *         out[i] = f(arr[i], freq)
 * 
 */
      goto __pyx_L4_continue;

      /* "pandas/src/period.pyx":429
 * 
 *     for i in range(sz):
 *         if arr[i] == iNaT:             # <<<<<<<<<<<<<<
 *             out[i] = -1
 *             continue
 */
    }

    /* "pandas/src/period.pyx":432
 *             out[i] = -1
 *             continue
 *         out[i] = f(arr[i], freq)             # <<<<<<<<<<<<<<
 * 
 *     return out
 */
    __pyx_t_16 = __pyx_v_i;
    __pyx_t_9 = -1;
    if (__pyx_t_16 < 0) {
      __pyx_t_16 += __pyx_pybuffernd_arr.diminfo[0].shape;
      if (unlikely(__pyx_t_16 < 0)) __pyx_t_9 = 0;
    } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_9 = 0;
    if (unlikely(__pyx_t_9 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_9);
      __PYX_ERR(0, 432, __pyx_L1_error)
    }
    __pyx_t_9 = __pyx_v_f((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_arr.diminfo[0].strides)), __pyx_v_freq); if (unlikely(__pyx_t_9 == INT32_MIN)) __PYX_ERR(0, 432, __pyx_L1_error)
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_out.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_out.diminfo[0].shape)) __pyx_t_18 = 0;
    if (unlikely(__pyx_t_18 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_18);
      __PYX_ERR(0, 432, __pyx_L1_error)
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_t_9;
    __pyx_L4_continue:;
  }

  /* "pandas/src/period.pyx":434
 *         out[i] = f(arr[i], freq)
 * 
 *     return out             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_r = ((PyObject *)__pyx_v_out);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":415
 * 
 * 
 * def get_period_field_arr(int code, ndarray[int64_t] arr, int freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, sz
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.get_period_field_arr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":437
 * 
 * 
 * cdef accessor _get_accessor_func(int code):             # <<<<<<<<<<<<<<
 *     if code == 0:
 *         return &pyear
 */

static __pyx_t_6pandas_7_period_accessor __pyx_f_6pandas_7_period__get_accessor_func(int __pyx_v_code) {
  __pyx_t_6pandas_7_period_accessor __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_accessor_func", 0);

  /* "pandas/src/period.pyx":438
 * 
 * cdef accessor _get_accessor_func(int code):
 *     if code == 0:             # <<<<<<<<<<<<<<
 *         return &pyear
 *     elif code == 1:
 */
  switch (__pyx_v_code) {
    case 0:

    /* "pandas/src/period.pyx":439
 * cdef accessor _get_accessor_func(int code):
 *     if code == 0:
 *         return &pyear             # <<<<<<<<<<<<<<
 *     elif code == 1:
 *         return &pqyear
 */
    __pyx_r = (&pyear);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":438
 * 
 * cdef accessor _get_accessor_func(int code):
 *     if code == 0:             # <<<<<<<<<<<<<<
 *         return &pyear
 *     elif code == 1:
 */
    break;

    /* "pandas/src/period.pyx":440
 *     if code == 0:
 *         return &pyear
 *     elif code == 1:             # <<<<<<<<<<<<<<
 *         return &pqyear
 *     elif code == 2:
 */
    case 1:

    /* "pandas/src/period.pyx":441
 *         return &pyear
 *     elif code == 1:
 *         return &pqyear             # <<<<<<<<<<<<<<
 *     elif code == 2:
 *         return &pquarter
 */
    __pyx_r = (&pqyear);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":440
 *     if code == 0:
 *         return &pyear
 *     elif code == 1:             # <<<<<<<<<<<<<<
 *         return &pqyear
 *     elif code == 2:
 */
    break;

    /* "pandas/src/period.pyx":442
 *     elif code == 1:
 *         return &pqyear
 *     elif code == 2:             # <<<<<<<<<<<<<<
 *         return &pquarter
 *     elif code == 3:
 */
    case 2:

    /* "pandas/src/period.pyx":443
 *         return &pqyear
 *     elif code == 2:
 *         return &pquarter             # <<<<<<<<<<<<<<
 *     elif code == 3:
 *         return &pmonth
 */
    __pyx_r = (&pquarter);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":442
 *     elif code == 1:
 *         return &pqyear
 *     elif code == 2:             # <<<<<<<<<<<<<<
 *         return &pquarter
 *     elif code == 3:
 */
    break;

    /* "pandas/src/period.pyx":444
 *     elif code == 2:
 *         return &pquarter
 *     elif code == 3:             # <<<<<<<<<<<<<<
 *         return &pmonth
 *     elif code == 4:
 */
    case 3:

    /* "pandas/src/period.pyx":445
 *         return &pquarter
 *     elif code == 3:
 *         return &pmonth             # <<<<<<<<<<<<<<
 *     elif code == 4:
 *         return &pday
 */
    __pyx_r = (&pmonth);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":444
 *     elif code == 2:
 *         return &pquarter
 *     elif code == 3:             # <<<<<<<<<<<<<<
 *         return &pmonth
 *     elif code == 4:
 */
    break;

    /* "pandas/src/period.pyx":446
 *     elif code == 3:
 *         return &pmonth
 *     elif code == 4:             # <<<<<<<<<<<<<<
 *         return &pday
 *     elif code == 5:
 */
    case 4:

    /* "pandas/src/period.pyx":447
 *         return &pmonth
 *     elif code == 4:
 *         return &pday             # <<<<<<<<<<<<<<
 *     elif code == 5:
 *         return &phour
 */
    __pyx_r = (&pday);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":446
 *     elif code == 3:
 *         return &pmonth
 *     elif code == 4:             # <<<<<<<<<<<<<<
 *         return &pday
 *     elif code == 5:
 */
    break;

    /* "pandas/src/period.pyx":448
 *     elif code == 4:
 *         return &pday
 *     elif code == 5:             # <<<<<<<<<<<<<<
 *         return &phour
 *     elif code == 6:
 */
    case 5:

    /* "pandas/src/period.pyx":449
 *         return &pday
 *     elif code == 5:
 *         return &phour             # <<<<<<<<<<<<<<
 *     elif code == 6:
 *         return &pminute
 */
    __pyx_r = (&phour);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":448
 *     elif code == 4:
 *         return &pday
 *     elif code == 5:             # <<<<<<<<<<<<<<
 *         return &phour
 *     elif code == 6:
 */
    break;

    /* "pandas/src/period.pyx":450
 *     elif code == 5:
 *         return &phour
 *     elif code == 6:             # <<<<<<<<<<<<<<
 *         return &pminute
 *     elif code == 7:
 */
    case 6:

    /* "pandas/src/period.pyx":451
 *         return &phour
 *     elif code == 6:
 *         return &pminute             # <<<<<<<<<<<<<<
 *     elif code == 7:
 *         return &psecond
 */
    __pyx_r = (&pminute);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":450
 *     elif code == 5:
 *         return &phour
 *     elif code == 6:             # <<<<<<<<<<<<<<
 *         return &pminute
 *     elif code == 7:
 */
    break;

    /* "pandas/src/period.pyx":452
 *     elif code == 6:
 *         return &pminute
 *     elif code == 7:             # <<<<<<<<<<<<<<
 *         return &psecond
 *     elif code == 8:
 */
    case 7:

    /* "pandas/src/period.pyx":453
 *         return &pminute
 *     elif code == 7:
 *         return &psecond             # <<<<<<<<<<<<<<
 *     elif code == 8:
 *         return &pweek
 */
    __pyx_r = (&psecond);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":452
 *     elif code == 6:
 *         return &pminute
 *     elif code == 7:             # <<<<<<<<<<<<<<
 *         return &psecond
 *     elif code == 8:
 */
    break;

    /* "pandas/src/period.pyx":454
 *     elif code == 7:
 *         return &psecond
 *     elif code == 8:             # <<<<<<<<<<<<<<
 *         return &pweek
 *     elif code == 9:
 */
    case 8:

    /* "pandas/src/period.pyx":455
 *         return &psecond
 *     elif code == 8:
 *         return &pweek             # <<<<<<<<<<<<<<
 *     elif code == 9:
 *         return &pday_of_year
 */
    __pyx_r = (&pweek);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":454
 *     elif code == 7:
 *         return &psecond
 *     elif code == 8:             # <<<<<<<<<<<<<<
 *         return &pweek
 *     elif code == 9:
 */
    break;

    /* "pandas/src/period.pyx":456
 *     elif code == 8:
 *         return &pweek
 *     elif code == 9:             # <<<<<<<<<<<<<<
 *         return &pday_of_year
 *     elif code == 10:
 */
    case 9:

    /* "pandas/src/period.pyx":457
 *         return &pweek
 *     elif code == 9:
 *         return &pday_of_year             # <<<<<<<<<<<<<<
 *     elif code == 10:
 *         return &pweekday
 */
    __pyx_r = (&pday_of_year);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":456
 *     elif code == 8:
 *         return &pweek
 *     elif code == 9:             # <<<<<<<<<<<<<<
 *         return &pday_of_year
 *     elif code == 10:
 */
    break;

    /* "pandas/src/period.pyx":458
 *     elif code == 9:
 *         return &pday_of_year
 *     elif code == 10:             # <<<<<<<<<<<<<<
 *         return &pweekday
 *     elif code == 11:
 */
    case 10:

    /* "pandas/src/period.pyx":459
 *         return &pday_of_year
 *     elif code == 10:
 *         return &pweekday             # <<<<<<<<<<<<<<
 *     elif code == 11:
 *         return &pdays_in_month
 */
    __pyx_r = (&pweekday);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":458
 *     elif code == 9:
 *         return &pday_of_year
 *     elif code == 10:             # <<<<<<<<<<<<<<
 *         return &pweekday
 *     elif code == 11:
 */
    break;

    /* "pandas/src/period.pyx":460
 *     elif code == 10:
 *         return &pweekday
 *     elif code == 11:             # <<<<<<<<<<<<<<
 *         return &pdays_in_month
 *     return NULL
 */
    case 11:

    /* "pandas/src/period.pyx":461
 *         return &pweekday
 *     elif code == 11:
 *         return &pdays_in_month             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    __pyx_r = (&pdays_in_month);
    goto __pyx_L0;

    /* "pandas/src/period.pyx":460
 *     elif code == 10:
 *         return &pweekday
 *     elif code == 11:             # <<<<<<<<<<<<<<
 *         return &pdays_in_month
 *     return NULL
 */
    break;
    default: break;
  }

  /* "pandas/src/period.pyx":462
 *     elif code == 11:
 *         return &pdays_in_month
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":437
 * 
 * 
 * cdef accessor _get_accessor_func(int code):             # <<<<<<<<<<<<<<
 *     if code == 0:
 *         return &pyear
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":465
 * 
 * 
 * def extract_ordinals(ndarray[object] values, freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_19extract_ordinals(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_19extract_ordinals = {"extract_ordinals", (PyCFunction)__pyx_pw_6pandas_7_period_19extract_ordinals, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_19extract_ordinals(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_values = 0;
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_ordinals (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_values,&__pyx_n_s_freq,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("extract_ordinals", 1, 2, 2, 1); __PYX_ERR(0, 465, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "extract_ordinals") < 0)) __PYX_ERR(0, 465, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_values = ((PyArrayObject *)values[0]);
    __pyx_v_freq = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_ordinals", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 465, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.extract_ordinals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) __PYX_ERR(0, 465, __pyx_L1_error)
  __pyx_r = __pyx_pf_6pandas_7_period_18extract_ordinals(__pyx_self, __pyx_v_values, __pyx_v_freq);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_18extract_ordinals(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_values, PyObject *__pyx_v_freq) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  PyArrayObject *__pyx_v_ordinals = 0;
  PyObject *__pyx_v_p = 0;
  PyObject *__pyx_v_freqstr = NULL;
  PyObject *__pyx_v_msg = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ordinals;
  __Pyx_Buffer __pyx_pybuffer_ordinals;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
  __Pyx_Buffer __pyx_pybuffer_values;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  __pyx_t_5numpy_int64_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  Py_ssize_t __pyx_t_17;
  Py_ssize_t __pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_t_21;
  Py_ssize_t __pyx_t_22;
  Py_ssize_t __pyx_t_23;
  __Pyx_RefNannySetupContext("extract_ordinals", 0);
  __pyx_pybuffer_ordinals.pybuffer.buf = NULL;
  __pyx_pybuffer_ordinals.refcount = 0;
  __pyx_pybuffernd_ordinals.data = NULL;
  __pyx_pybuffernd_ordinals.rcbuffer = &__pyx_pybuffer_ordinals;
  __pyx_pybuffer_values.pybuffer.buf = NULL;
  __pyx_pybuffer_values.refcount = 0;
  __pyx_pybuffernd_values.data = NULL;
  __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 465, __pyx_L1_error)
  }
  __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":467
 * def extract_ordinals(ndarray[object] values, freq):
 *     cdef:
 *         Py_ssize_t i, n = len(values)             # <<<<<<<<<<<<<<
 *         ndarray[int64_t] ordinals = np.empty(n, dtype=np.int64)
 *         object p
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 467, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "pandas/src/period.pyx":468
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 *         ndarray[int64_t] ordinals = np.empty(n, dtype=np.int64)             # <<<<<<<<<<<<<<
 *         object p
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 468, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ordinals.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_ordinals = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ordinals.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 468, __pyx_L1_error)
    } else {__pyx_pybuffernd_ordinals.diminfo[0].strides = __pyx_pybuffernd_ordinals.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ordinals.diminfo[0].shape = __pyx_pybuffernd_ordinals.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_ordinals = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pandas/src/period.pyx":471
 *         object p
 * 
 *     freqstr = Period._maybe_convert_freq(freq).freqstr             # <<<<<<<<<<<<<<
 * 
 *     for i in range(n):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_maybe_convert_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_freq); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_freq);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_freqstr = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":473
 *     freqstr = Period._maybe_convert_freq(freq).freqstr
 * 
 *     for i in range(n):             # <<<<<<<<<<<<<<
 *         p = values[i]
 * 
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "pandas/src/period.pyx":474
 * 
 *     for i in range(n):
 *         p = values[i]             # <<<<<<<<<<<<<<
 * 
 *         if is_null_datetimelike(p):
 */
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_10 = -1;
    if (__pyx_t_9 < 0) {
      __pyx_t_9 += __pyx_pybuffernd_values.diminfo[0].shape;
      if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0;
    } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_10 = 0;
    if (unlikely(__pyx_t_10 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_10);
      __PYX_ERR(0, 474, __pyx_L1_error)
    }
    __pyx_t_4 = (PyObject *) *__Pyx_BufPtrStrided1d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_values.diminfo[0].strides);
    __Pyx_INCREF((PyObject*)__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":476
 *         p = values[i]
 * 
 *         if is_null_datetimelike(p):             # <<<<<<<<<<<<<<
 *             ordinals[i] = tslib.iNaT
 *         else:
 */
    __pyx_t_11 = (__pyx_f_6pandas_3lib_is_null_datetimelike(__pyx_v_p) != 0);
    if (__pyx_t_11) {

      /* "pandas/src/period.pyx":477
 * 
 *         if is_null_datetimelike(p):
 *             ordinals[i] = tslib.iNaT             # <<<<<<<<<<<<<<
 *         else:
 *             try:
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 477, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_iNaT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 477, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_npy_int64(__pyx_t_6); if (unlikely((__pyx_t_12 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 477, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_13 = __pyx_v_i;
      __pyx_t_10 = -1;
      if (__pyx_t_13 < 0) {
        __pyx_t_13 += __pyx_pybuffernd_ordinals.diminfo[0].shape;
        if (unlikely(__pyx_t_13 < 0)) __pyx_t_10 = 0;
      } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_ordinals.diminfo[0].shape)) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        __PYX_ERR(0, 477, __pyx_L1_error)
      }
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_ordinals.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ordinals.diminfo[0].strides) = __pyx_t_12;

      /* "pandas/src/period.pyx":476
 *         p = values[i]
 * 
 *         if is_null_datetimelike(p):             # <<<<<<<<<<<<<<
 *             ordinals[i] = tslib.iNaT
 *         else:
 */
      goto __pyx_L5;
    }

    /* "pandas/src/period.pyx":479
 *             ordinals[i] = tslib.iNaT
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 ordinals[i] = p.ordinal
 * 
 */
    /*else*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_16);
        /*try:*/ {

          /* "pandas/src/period.pyx":480
 *         else:
 *             try:
 *                 ordinals[i] = p.ordinal             # <<<<<<<<<<<<<<
 * 
 *                 if p.freqstr != freqstr:
 */
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 480, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_12 = __Pyx_PyInt_As_npy_int64(__pyx_t_6); if (unlikely((__pyx_t_12 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_17 = __pyx_v_i;
          __pyx_t_10 = -1;
          if (__pyx_t_17 < 0) {
            __pyx_t_17 += __pyx_pybuffernd_ordinals.diminfo[0].shape;
            if (unlikely(__pyx_t_17 < 0)) __pyx_t_10 = 0;
          } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_ordinals.diminfo[0].shape)) __pyx_t_10 = 0;
          if (unlikely(__pyx_t_10 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_10);
            __PYX_ERR(0, 480, __pyx_L6_error)
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_ordinals.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_ordinals.diminfo[0].strides) = __pyx_t_12;

          /* "pandas/src/period.pyx":482
 *                 ordinals[i] = p.ordinal
 * 
 *                 if p.freqstr != freqstr:             # <<<<<<<<<<<<<<
 *                     msg = _DIFFERENT_FREQ_INDEX.format(freqstr, p.freqstr)
 *                     raise IncompatibleFrequency(msg)
 */
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 482, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_4 = PyObject_RichCompare(__pyx_t_6, __pyx_v_freqstr, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 482, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 482, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__pyx_t_11) {

            /* "pandas/src/period.pyx":483
 * 
 *                 if p.freqstr != freqstr:
 *                     msg = _DIFFERENT_FREQ_INDEX.format(freqstr, p.freqstr)             # <<<<<<<<<<<<<<
 *                     raise IncompatibleFrequency(msg)
 * 
 */
            __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DIFFERENT_FREQ_INDEX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 483, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 483, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 483, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_2 = NULL;
            __pyx_t_18 = 0;
            if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_2)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
                __pyx_t_18 = 1;
              }
            }
            __pyx_t_5 = PyTuple_New(2+__pyx_t_18); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 483, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_5);
            if (__pyx_t_2) {
              __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
            }
            __Pyx_INCREF(__pyx_v_freqstr);
            __Pyx_GIVEREF(__pyx_v_freqstr);
            PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_18, __pyx_v_freqstr);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_18, __pyx_t_6);
            __pyx_t_6 = 0;
            __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 483, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF_SET(__pyx_v_msg, __pyx_t_4);
            __pyx_t_4 = 0;

            /* "pandas/src/period.pyx":484
 *                 if p.freqstr != freqstr:
 *                     msg = _DIFFERENT_FREQ_INDEX.format(freqstr, p.freqstr)
 *                     raise IncompatibleFrequency(msg)             # <<<<<<<<<<<<<<
 * 
 *             except AttributeError:
 */
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_IncompatibleFrequency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 484, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_5 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_5)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            if (!__pyx_t_5) {
              __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_msg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 484, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_4);
            } else {
              __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 484, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
              __Pyx_INCREF(__pyx_v_msg);
              __Pyx_GIVEREF(__pyx_v_msg);
              PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_msg);
              __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 484, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_4, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __PYX_ERR(0, 484, __pyx_L6_error)

            /* "pandas/src/period.pyx":482
 *                 ordinals[i] = p.ordinal
 * 
 *                 if p.freqstr != freqstr:             # <<<<<<<<<<<<<<
 *                     msg = _DIFFERENT_FREQ_INDEX.format(freqstr, p.freqstr)
 *                     raise IncompatibleFrequency(msg)
 */
          }

          /* "pandas/src/period.pyx":479
 *             ordinals[i] = tslib.iNaT
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 ordinals[i] = p.ordinal
 * 
 */
        }
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        goto __pyx_L13_try_end;
        __pyx_L6_error:;
        __Pyx_PyThreadState_assign
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pandas/src/period.pyx":486
 *                     raise IncompatibleFrequency(msg)
 * 
 *             except AttributeError:             # <<<<<<<<<<<<<<
 *                 p = Period(p, freq=freq)
 *                 if p is tslib.NaT:
 */
        __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
        if (__pyx_t_10) {
          __Pyx_AddTraceback("pandas._period.extract_ordinals", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_6) < 0) __PYX_ERR(0, 486, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_6);

          /* "pandas/src/period.pyx":487
 * 
 *             except AttributeError:
 *                 p = Period(p, freq=freq)             # <<<<<<<<<<<<<<
 *                 if p is tslib.NaT:
 *                     # input may contain NaT-like string
 */
          __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 487, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_v_p);
          __Pyx_GIVEREF(__pyx_v_p);
          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_p);
          __pyx_t_19 = PyDict_New(); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 487, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_19);
          if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_freq, __pyx_v_freq) < 0) __PYX_ERR(0, 487, __pyx_L8_except_error)
          __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_19); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 487, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_20);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF_SET(__pyx_v_p, __pyx_t_20);
          __pyx_t_20 = 0;

          /* "pandas/src/period.pyx":488
 *             except AttributeError:
 *                 p = Period(p, freq=freq)
 *                 if p is tslib.NaT:             # <<<<<<<<<<<<<<
 *                     # input may contain NaT-like string
 *                     ordinals[i] = tslib.iNaT
 */
          __pyx_t_20 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 488, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_20);
          __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_NaT); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 488, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __pyx_t_11 = (__pyx_v_p == __pyx_t_19);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __pyx_t_21 = (__pyx_t_11 != 0);
          if (__pyx_t_21) {

            /* "pandas/src/period.pyx":490
 *                 if p is tslib.NaT:
 *                     # input may contain NaT-like string
 *                     ordinals[i] = tslib.iNaT             # <<<<<<<<<<<<<<
 *                 else:
 *                     ordinals[i] = p.ordinal
 */
            __pyx_t_19 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 490, __pyx_L8_except_error)
            __Pyx_GOTREF(__pyx_t_19);
            __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_iNaT); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 490, __pyx_L8_except_error)
            __Pyx_GOTREF(__pyx_t_20);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __pyx_t_12 = __Pyx_PyInt_As_npy_int64(__pyx_t_20); if (unlikely((__pyx_t_12 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 490, __pyx_L8_except_error)
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
            __pyx_t_22 = __pyx_v_i;
            __pyx_t_10 = -1;
            if (__pyx_t_22 < 0) {
              __pyx_t_22 += __pyx_pybuffernd_ordinals.diminfo[0].shape;
              if (unlikely(__pyx_t_22 < 0)) __pyx_t_10 = 0;
            } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_ordinals.diminfo[0].shape)) __pyx_t_10 = 0;
            if (unlikely(__pyx_t_10 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_10);
              __PYX_ERR(0, 490, __pyx_L8_except_error)
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_ordinals.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_ordinals.diminfo[0].strides) = __pyx_t_12;

            /* "pandas/src/period.pyx":488
 *             except AttributeError:
 *                 p = Period(p, freq=freq)
 *                 if p is tslib.NaT:             # <<<<<<<<<<<<<<
 *                     # input may contain NaT-like string
 *                     ordinals[i] = tslib.iNaT
 */
            goto __pyx_L17;
          }

          /* "pandas/src/period.pyx":492
 *                     ordinals[i] = tslib.iNaT
 *                 else:
 *                     ordinals[i] = p.ordinal             # <<<<<<<<<<<<<<
 * 
 *     return ordinals
 */
          /*else*/ {
            __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 492, __pyx_L8_except_error)
            __Pyx_GOTREF(__pyx_t_20);
            __pyx_t_12 = __Pyx_PyInt_As_npy_int64(__pyx_t_20); if (unlikely((__pyx_t_12 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 492, __pyx_L8_except_error)
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
            __pyx_t_23 = __pyx_v_i;
            __pyx_t_10 = -1;
            if (__pyx_t_23 < 0) {
              __pyx_t_23 += __pyx_pybuffernd_ordinals.diminfo[0].shape;
              if (unlikely(__pyx_t_23 < 0)) __pyx_t_10 = 0;
            } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_ordinals.diminfo[0].shape)) __pyx_t_10 = 0;
            if (unlikely(__pyx_t_10 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_10);
              __PYX_ERR(0, 492, __pyx_L8_except_error)
            }
            *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_ordinals.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_ordinals.diminfo[0].strides) = __pyx_t_12;
          }
          __pyx_L17:;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L7_exception_handled;
        }
        goto __pyx_L8_except_error;
        __pyx_L8_except_error:;

        /* "pandas/src/period.pyx":479
 *             ordinals[i] = tslib.iNaT
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 ordinals[i] = p.ordinal
 * 
 */
        __Pyx_PyThreadState_assign
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        goto __pyx_L1_error;
        __pyx_L7_exception_handled:;
        __Pyx_PyThreadState_assign
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        __pyx_L13_try_end:;
      }
    }
    __pyx_L5:;
  }

  /* "pandas/src/period.pyx":494
 *                     ordinals[i] = p.ordinal
 * 
 *     return ordinals             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_ordinals));
  __pyx_r = ((PyObject *)__pyx_v_ordinals);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":465
 * 
 * 
 * def extract_ordinals(ndarray[object] values, freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ordinals.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.extract_ordinals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ordinals.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ordinals);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_freqstr);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":497
 * 
 * 
 * def extract_freq(ndarray[object] values):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_21extract_freq(PyObject *__pyx_self, PyObject *__pyx_v_values); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_21extract_freq = {"extract_freq", (PyCFunction)__pyx_pw_6pandas_7_period_21extract_freq, METH_O, 0};
static PyObject *__pyx_pw_6pandas_7_period_21extract_freq(PyObject *__pyx_self, PyObject *__pyx_v_values) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_freq (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) __PYX_ERR(0, 497, __pyx_L1_error)
  __pyx_r = __pyx_pf_6pandas_7_period_20extract_freq(__pyx_self, ((PyArrayObject *)__pyx_v_values));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_20extract_freq(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_values) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  PyObject *__pyx_v_p = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_values;
  __Pyx_Buffer __pyx_pybuffer_values;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("extract_freq", 0);
  __pyx_pybuffer_values.pybuffer.buf = NULL;
  __pyx_pybuffer_values.refcount = 0;
  __pyx_pybuffernd_values.data = NULL;
  __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_object, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 497, __pyx_L1_error)
  }
  __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":499
 * def extract_freq(ndarray[object] values):
 *     cdef:
 *         Py_ssize_t i, n = len(values)             # <<<<<<<<<<<<<<
 *         object p
 * 
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_values)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 499, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "pandas/src/period.pyx":502
 *         object p
 * 
 *     for i in range(n):             # <<<<<<<<<<<<<<
 *         p = values[i]
 * 
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "pandas/src/period.pyx":503
 * 
 *     for i in range(n):
 *         p = values[i]             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    __pyx_t_4 = __pyx_v_i;
    __pyx_t_5 = -1;
    if (__pyx_t_4 < 0) {
      __pyx_t_4 += __pyx_pybuffernd_values.diminfo[0].shape;
      if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 0;
    } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_values.diminfo[0].shape)) __pyx_t_5 = 0;
    if (unlikely(__pyx_t_5 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_5);
      __PYX_ERR(0, 503, __pyx_L1_error)
    }
    __pyx_t_3 = (PyObject *) *__Pyx_BufPtrStrided1d(PyObject **, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_values.diminfo[0].strides);
    __Pyx_INCREF((PyObject*)__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":505
 *         p = values[i]
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # now Timestamp / NaT has freq attr
 *             if is_period(p):
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      /*try:*/ {

        /* "pandas/src/period.pyx":507
 *         try:
 *             # now Timestamp / NaT has freq attr
 *             if is_period(p):             # <<<<<<<<<<<<<<
 *                 return p.freq
 *         except AttributeError:
 */
        __pyx_t_9 = (__pyx_f_6pandas_3lib_is_period(__pyx_v_p, 0) != 0);
        if (__pyx_t_9) {

          /* "pandas/src/period.pyx":508
 *             # now Timestamp / NaT has freq attr
 *             if is_period(p):
 *                 return p.freq             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             pass
 */
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 508, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_r = __pyx_t_3;
          __pyx_t_3 = 0;
          goto __pyx_L9_try_return;

          /* "pandas/src/period.pyx":507
 *         try:
 *             # now Timestamp / NaT has freq attr
 *             if is_period(p):             # <<<<<<<<<<<<<<
 *                 return p.freq
 *         except AttributeError:
 */
        }

        /* "pandas/src/period.pyx":505
 *         p = values[i]
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # now Timestamp / NaT has freq attr
 *             if is_period(p):
 */
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L12_try_end;
      __pyx_L5_error:;
      __Pyx_PyThreadState_assign
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pandas/src/period.pyx":509
 *             if is_period(p):
 *                 return p.freq
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             pass
 * 
 */
      __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
      if (__pyx_t_5) {
        __Pyx_ErrRestore(0,0,0);
        goto __pyx_L6_exception_handled;
      }
      goto __pyx_L7_except_error;
      __pyx_L7_except_error:;

      /* "pandas/src/period.pyx":505
 *         p = values[i]
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # now Timestamp / NaT has freq attr
 *             if is_period(p):
 */
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L1_error;
      __pyx_L9_try_return:;
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L0;
      __pyx_L6_exception_handled:;
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_L12_try_end:;
    }
  }

  /* "pandas/src/period.pyx":512
 *             pass
 * 
 *     raise ValueError('freq not specified and cannot be inferred')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __PYX_ERR(0, 512, __pyx_L1_error)

  /* "pandas/src/period.pyx":497
 * 
 * 
 * def extract_freq(ndarray[object] values):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.extract_freq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":515
 * 
 * 
 * cpdef resolution(ndarray[int64_t] stamps, tz=None):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(stamps)
 */

static PyObject *__pyx_pw_6pandas_7_period_23resolution(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6pandas_7_period_resolution(PyArrayObject *__pyx_v_stamps, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6pandas_7_period_resolution *__pyx_optional_args) {
  PyObject *__pyx_v_tz = ((PyObject *)Py_None);
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  pandas_datetimestruct __pyx_v_dts;
  int __pyx_v_reso;
  int __pyx_v_curr_reso;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_stamps;
  __Pyx_Buffer __pyx_pybuffer_stamps;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("resolution", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_tz = __pyx_optional_args->tz;
    }
  }
  __Pyx_INCREF(__pyx_v_tz);
  __pyx_pybuffer_stamps.pybuffer.buf = NULL;
  __pyx_pybuffer_stamps.refcount = 0;
  __pyx_pybuffernd_stamps.data = NULL;
  __pyx_pybuffernd_stamps.rcbuffer = &__pyx_pybuffer_stamps;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer, (PyObject*)__pyx_v_stamps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 515, __pyx_L1_error)
  }
  __pyx_pybuffernd_stamps.diminfo[0].strides = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_stamps.diminfo[0].shape = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":517
 * cpdef resolution(ndarray[int64_t] stamps, tz=None):
 *     cdef:
 *         Py_ssize_t i, n = len(stamps)             # <<<<<<<<<<<<<<
 *         pandas_datetimestruct dts
 *         int reso = D_RESO, curr_reso
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_stamps)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 517, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "pandas/src/period.pyx":519
 *         Py_ssize_t i, n = len(stamps)
 *         pandas_datetimestruct dts
 *         int reso = D_RESO, curr_reso             # <<<<<<<<<<<<<<
 * 
 *     if tz is not None:
 */
  __pyx_v_reso = __pyx_v_6pandas_7_period_D_RESO;

  /* "pandas/src/period.pyx":521
 *         int reso = D_RESO, curr_reso
 * 
 *     if tz is not None:             # <<<<<<<<<<<<<<
 *         tz = maybe_get_tz(tz)
 *         return _reso_local(stamps, tz)
 */
  __pyx_t_2 = (__pyx_v_tz != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pandas/src/period.pyx":522
 * 
 *     if tz is not None:
 *         tz = maybe_get_tz(tz)             # <<<<<<<<<<<<<<
 *         return _reso_local(stamps, tz)
 *     else:
 */
    __pyx_t_4 = __pyx_f_6pandas_5tslib_maybe_get_tz(__pyx_v_tz, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_tz, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":523
 *     if tz is not None:
 *         tz = maybe_get_tz(tz)
 *         return _reso_local(stamps, tz)             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(n):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __pyx_f_6pandas_7_period__reso_local(((PyArrayObject *)__pyx_v_stamps), __pyx_v_tz); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":521
 *         int reso = D_RESO, curr_reso
 * 
 *     if tz is not None:             # <<<<<<<<<<<<<<
 *         tz = maybe_get_tz(tz)
 *         return _reso_local(stamps, tz)
 */
  }

  /* "pandas/src/period.pyx":525
 *         return _reso_local(stamps, tz)
 *     else:
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             if stamps[i] == NPY_NAT:
 *                 continue
 */
  /*else*/ {
    __pyx_t_1 = __pyx_v_n;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "pandas/src/period.pyx":526
 *     else:
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 */
      __pyx_t_6 = __pyx_v_i;
      __pyx_t_7 = -1;
      if (__pyx_t_6 < 0) {
        __pyx_t_6 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0;
      } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_7 = 0;
      if (unlikely(__pyx_t_7 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_7);
        __PYX_ERR(0, 526, __pyx_L1_error)
      }
      __pyx_t_3 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
      if (__pyx_t_3) {

        /* "pandas/src/period.pyx":527
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 *                 continue             # <<<<<<<<<<<<<<
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 */
        goto __pyx_L4_continue;

        /* "pandas/src/period.pyx":526
 *     else:
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 */
      }

      /* "pandas/src/period.pyx":528
 *             if stamps[i] == NPY_NAT:
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:
 */
      __pyx_t_8 = __pyx_v_i;
      __pyx_t_7 = -1;
      if (__pyx_t_8 < 0) {
        __pyx_t_8 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_8 < 0)) __pyx_t_7 = 0;
      } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_7 = 0;
      if (unlikely(__pyx_t_7 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_7);
        __PYX_ERR(0, 528, __pyx_L1_error)
      }
      pandas_datetime_to_datetimestruct((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_stamps.diminfo[0].strides)), PANDAS_FR_ns, (&__pyx_v_dts));

      /* "pandas/src/period.pyx":529
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)             # <<<<<<<<<<<<<<
 *             if curr_reso < reso:
 *                 reso = curr_reso
 */
      __pyx_v_curr_reso = __pyx_f_6pandas_7_period__reso_stamp((&__pyx_v_dts));

      /* "pandas/src/period.pyx":530
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                 reso = curr_reso
 *         return reso
 */
      __pyx_t_3 = ((__pyx_v_curr_reso < __pyx_v_reso) != 0);
      if (__pyx_t_3) {

        /* "pandas/src/period.pyx":531
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:
 *                 reso = curr_reso             # <<<<<<<<<<<<<<
 *         return reso
 * 
 */
        __pyx_v_reso = __pyx_v_curr_reso;

        /* "pandas/src/period.pyx":530
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                 reso = curr_reso
 *         return reso
 */
      }
      __pyx_L4_continue:;
    }

    /* "pandas/src/period.pyx":532
 *             if curr_reso < reso:
 *                 reso = curr_reso
 *         return reso             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_reso); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "pandas/src/period.pyx":515
 * 
 * 
 * cpdef resolution(ndarray[int64_t] stamps, tz=None):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(stamps)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.resolution", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_tz);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_23resolution(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_23resolution(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_stamps = 0;
  PyObject *__pyx_v_tz = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("resolution (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stamps,&__pyx_n_s_tz,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stamps)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tz);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "resolution") < 0)) __PYX_ERR(0, 515, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_stamps = ((PyArrayObject *)values[0]);
    __pyx_v_tz = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("resolution", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 515, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.resolution", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stamps), __pyx_ptype_5numpy_ndarray, 1, "stamps", 0))) __PYX_ERR(0, 515, __pyx_L1_error)
  __pyx_r = __pyx_pf_6pandas_7_period_22resolution(__pyx_self, __pyx_v_stamps, __pyx_v_tz);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_22resolution(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_stamps, PyObject *__pyx_v_tz) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_stamps;
  __Pyx_Buffer __pyx_pybuffer_stamps;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_6pandas_7_period_resolution __pyx_t_2;
  __Pyx_RefNannySetupContext("resolution", 0);
  __pyx_pybuffer_stamps.pybuffer.buf = NULL;
  __pyx_pybuffer_stamps.refcount = 0;
  __pyx_pybuffernd_stamps.data = NULL;
  __pyx_pybuffernd_stamps.rcbuffer = &__pyx_pybuffer_stamps;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer, (PyObject*)__pyx_v_stamps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 515, __pyx_L1_error)
  }
  __pyx_pybuffernd_stamps.diminfo[0].strides = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_stamps.diminfo[0].shape = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.shape[0];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.tz = __pyx_v_tz;
  __pyx_t_1 = __pyx_f_6pandas_7_period_resolution(__pyx_v_stamps, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.resolution", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":535
 * 
 * 
 * cdef inline int _reso_stamp(pandas_datetimestruct *dts):             # <<<<<<<<<<<<<<
 *     if dts.us != 0:
 *         if dts.us % 1000 == 0:
 */

static CYTHON_INLINE int __pyx_f_6pandas_7_period__reso_stamp(pandas_datetimestruct *__pyx_v_dts) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_reso_stamp", 0);

  /* "pandas/src/period.pyx":536
 * 
 * cdef inline int _reso_stamp(pandas_datetimestruct *dts):
 *     if dts.us != 0:             # <<<<<<<<<<<<<<
 *         if dts.us % 1000 == 0:
 *             return MS_RESO
 */
  __pyx_t_1 = ((__pyx_v_dts->us != 0) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":537
 * cdef inline int _reso_stamp(pandas_datetimestruct *dts):
 *     if dts.us != 0:
 *         if dts.us % 1000 == 0:             # <<<<<<<<<<<<<<
 *             return MS_RESO
 *         return US_RESO
 */
    __pyx_t_1 = ((__Pyx_mod_long(__pyx_v_dts->us, 0x3E8) == 0) != 0);
    if (__pyx_t_1) {

      /* "pandas/src/period.pyx":538
 *     if dts.us != 0:
 *         if dts.us % 1000 == 0:
 *             return MS_RESO             # <<<<<<<<<<<<<<
 *         return US_RESO
 *     elif dts.sec != 0:
 */
      __pyx_r = __pyx_v_6pandas_7_period_MS_RESO;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":537
 * cdef inline int _reso_stamp(pandas_datetimestruct *dts):
 *     if dts.us != 0:
 *         if dts.us % 1000 == 0:             # <<<<<<<<<<<<<<
 *             return MS_RESO
 *         return US_RESO
 */
    }

    /* "pandas/src/period.pyx":539
 *         if dts.us % 1000 == 0:
 *             return MS_RESO
 *         return US_RESO             # <<<<<<<<<<<<<<
 *     elif dts.sec != 0:
 *         return S_RESO
 */
    __pyx_r = __pyx_v_6pandas_7_period_US_RESO;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":536
 * 
 * cdef inline int _reso_stamp(pandas_datetimestruct *dts):
 *     if dts.us != 0:             # <<<<<<<<<<<<<<
 *         if dts.us % 1000 == 0:
 *             return MS_RESO
 */
  }

  /* "pandas/src/period.pyx":540
 *             return MS_RESO
 *         return US_RESO
 *     elif dts.sec != 0:             # <<<<<<<<<<<<<<
 *         return S_RESO
 *     elif dts.min != 0:
 */
  __pyx_t_1 = ((__pyx_v_dts->sec != 0) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":541
 *         return US_RESO
 *     elif dts.sec != 0:
 *         return S_RESO             # <<<<<<<<<<<<<<
 *     elif dts.min != 0:
 *         return T_RESO
 */
    __pyx_r = __pyx_v_6pandas_7_period_S_RESO;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":540
 *             return MS_RESO
 *         return US_RESO
 *     elif dts.sec != 0:             # <<<<<<<<<<<<<<
 *         return S_RESO
 *     elif dts.min != 0:
 */
  }

  /* "pandas/src/period.pyx":542
 *     elif dts.sec != 0:
 *         return S_RESO
 *     elif dts.min != 0:             # <<<<<<<<<<<<<<
 *         return T_RESO
 *     elif dts.hour != 0:
 */
  __pyx_t_1 = ((__pyx_v_dts->min != 0) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":543
 *         return S_RESO
 *     elif dts.min != 0:
 *         return T_RESO             # <<<<<<<<<<<<<<
 *     elif dts.hour != 0:
 *         return H_RESO
 */
    __pyx_r = __pyx_v_6pandas_7_period_T_RESO;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":542
 *     elif dts.sec != 0:
 *         return S_RESO
 *     elif dts.min != 0:             # <<<<<<<<<<<<<<
 *         return T_RESO
 *     elif dts.hour != 0:
 */
  }

  /* "pandas/src/period.pyx":544
 *     elif dts.min != 0:
 *         return T_RESO
 *     elif dts.hour != 0:             # <<<<<<<<<<<<<<
 *         return H_RESO
 *     return D_RESO
 */
  __pyx_t_1 = ((__pyx_v_dts->hour != 0) != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":545
 *         return T_RESO
 *     elif dts.hour != 0:
 *         return H_RESO             # <<<<<<<<<<<<<<
 *     return D_RESO
 * 
 */
    __pyx_r = __pyx_v_6pandas_7_period_H_RESO;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":544
 *     elif dts.min != 0:
 *         return T_RESO
 *     elif dts.hour != 0:             # <<<<<<<<<<<<<<
 *         return H_RESO
 *     return D_RESO
 */
  }

  /* "pandas/src/period.pyx":546
 *     elif dts.hour != 0:
 *         return H_RESO
 *     return D_RESO             # <<<<<<<<<<<<<<
 * 
 * cdef _reso_local(ndarray[int64_t] stamps, object tz):
 */
  __pyx_r = __pyx_v_6pandas_7_period_D_RESO;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":535
 * 
 * 
 * cdef inline int _reso_stamp(pandas_datetimestruct *dts):             # <<<<<<<<<<<<<<
 *     if dts.us != 0:
 *         if dts.us % 1000 == 0:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":548
 *     return D_RESO
 * 
 * cdef _reso_local(ndarray[int64_t] stamps, object tz):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t n = len(stamps)
 */

static PyObject *__pyx_f_6pandas_7_period__reso_local(PyArrayObject *__pyx_v_stamps, PyObject *__pyx_v_tz) {
  Py_ssize_t __pyx_v_n;
  int __pyx_v_reso;
  int __pyx_v_curr_reso;
  PyArrayObject *__pyx_v_trans = 0;
  PyArrayObject *__pyx_v_deltas = 0;
  PyArrayObject *__pyx_v_pos = 0;
  pandas_datetimestruct __pyx_v_dts;
  Py_ssize_t __pyx_v_i;
  PyDateTime_DateTime *__pyx_v_dt = NULL;
  PyObject *__pyx_v_delta = NULL;
  PyObject *__pyx_v_typ = NULL;
  PyObject *__pyx_v__pos = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_deltas;
  __Pyx_Buffer __pyx_pybuffer_deltas;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_pos;
  __Pyx_Buffer __pyx_pybuffer_pos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_stamps;
  __Pyx_Buffer __pyx_pybuffer_stamps;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_trans;
  __Pyx_Buffer __pyx_pybuffer_trans;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  Py_ssize_t __pyx_t_17;
  Py_ssize_t __pyx_t_18;
  npy_datetime __pyx_t_19;
  PyObject *(*__pyx_t_20)(PyObject *);
  PyArrayObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_t_25;
  Py_ssize_t __pyx_t_26;
  Py_ssize_t __pyx_t_27;
  Py_ssize_t __pyx_t_28;
  Py_ssize_t __pyx_t_29;
  Py_ssize_t __pyx_t_30;
  Py_ssize_t __pyx_t_31;
  __pyx_t_5numpy_int64_t __pyx_t_32;
  __Pyx_RefNannySetupContext("_reso_local", 0);
  __pyx_pybuffer_trans.pybuffer.buf = NULL;
  __pyx_pybuffer_trans.refcount = 0;
  __pyx_pybuffernd_trans.data = NULL;
  __pyx_pybuffernd_trans.rcbuffer = &__pyx_pybuffer_trans;
  __pyx_pybuffer_deltas.pybuffer.buf = NULL;
  __pyx_pybuffer_deltas.refcount = 0;
  __pyx_pybuffernd_deltas.data = NULL;
  __pyx_pybuffernd_deltas.rcbuffer = &__pyx_pybuffer_deltas;
  __pyx_pybuffer_pos.pybuffer.buf = NULL;
  __pyx_pybuffer_pos.refcount = 0;
  __pyx_pybuffernd_pos.data = NULL;
  __pyx_pybuffernd_pos.rcbuffer = &__pyx_pybuffer_pos;
  __pyx_pybuffer_stamps.pybuffer.buf = NULL;
  __pyx_pybuffer_stamps.refcount = 0;
  __pyx_pybuffernd_stamps.data = NULL;
  __pyx_pybuffernd_stamps.rcbuffer = &__pyx_pybuffer_stamps;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer, (PyObject*)__pyx_v_stamps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 548, __pyx_L1_error)
  }
  __pyx_pybuffernd_stamps.diminfo[0].strides = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_stamps.diminfo[0].shape = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":550
 * cdef _reso_local(ndarray[int64_t] stamps, object tz):
 *     cdef:
 *         Py_ssize_t n = len(stamps)             # <<<<<<<<<<<<<<
 *         int reso = D_RESO, curr_reso
 *         ndarray[int64_t] trans, deltas, pos
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_stamps)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 550, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "pandas/src/period.pyx":551
 *     cdef:
 *         Py_ssize_t n = len(stamps)
 *         int reso = D_RESO, curr_reso             # <<<<<<<<<<<<<<
 *         ndarray[int64_t] trans, deltas, pos
 *         pandas_datetimestruct dts
 */
  __pyx_v_reso = __pyx_v_6pandas_7_period_D_RESO;

  /* "pandas/src/period.pyx":555
 *         pandas_datetimestruct dts
 * 
 *     if _is_utc(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
  __pyx_t_2 = (__pyx_f_6pandas_5tslib__is_utc(__pyx_v_tz) != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":556
 * 
 *     if _is_utc(tz):
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             if stamps[i] == NPY_NAT:
 *                 continue
 */
    __pyx_t_1 = __pyx_v_n;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "pandas/src/period.pyx":557
 *     if _is_utc(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 */
      __pyx_t_4 = __pyx_v_i;
      __pyx_t_5 = -1;
      if (__pyx_t_4 < 0) {
        __pyx_t_4 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 0;
      } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
      if (unlikely(__pyx_t_5 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_5);
        __PYX_ERR(0, 557, __pyx_L1_error)
      }
      __pyx_t_2 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
      if (__pyx_t_2) {

        /* "pandas/src/period.pyx":558
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 *                 continue             # <<<<<<<<<<<<<<
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 */
        goto __pyx_L4_continue;

        /* "pandas/src/period.pyx":557
 *     if _is_utc(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 */
      }

      /* "pandas/src/period.pyx":559
 *             if stamps[i] == NPY_NAT:
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:
 */
      __pyx_t_6 = __pyx_v_i;
      __pyx_t_5 = -1;
      if (__pyx_t_6 < 0) {
        __pyx_t_6 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_6 < 0)) __pyx_t_5 = 0;
      } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
      if (unlikely(__pyx_t_5 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_5);
        __PYX_ERR(0, 559, __pyx_L1_error)
      }
      pandas_datetime_to_datetimestruct((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_stamps.diminfo[0].strides)), PANDAS_FR_ns, (&__pyx_v_dts));

      /* "pandas/src/period.pyx":560
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)             # <<<<<<<<<<<<<<
 *             if curr_reso < reso:
 *                 reso = curr_reso
 */
      __pyx_v_curr_reso = __pyx_f_6pandas_7_period__reso_stamp((&__pyx_v_dts));

      /* "pandas/src/period.pyx":561
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                 reso = curr_reso
 *     elif _is_tzlocal(tz):
 */
      __pyx_t_2 = ((__pyx_v_curr_reso < __pyx_v_reso) != 0);
      if (__pyx_t_2) {

        /* "pandas/src/period.pyx":562
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:
 *                 reso = curr_reso             # <<<<<<<<<<<<<<
 *     elif _is_tzlocal(tz):
 *         for i in range(n):
 */
        __pyx_v_reso = __pyx_v_curr_reso;

        /* "pandas/src/period.pyx":561
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                 reso = curr_reso
 *     elif _is_tzlocal(tz):
 */
      }
      __pyx_L4_continue:;
    }

    /* "pandas/src/period.pyx":555
 *         pandas_datetimestruct dts
 * 
 *     if _is_utc(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
    goto __pyx_L3;
  }

  /* "pandas/src/period.pyx":563
 *             if curr_reso < reso:
 *                 reso = curr_reso
 *     elif _is_tzlocal(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
  __pyx_t_2 = (__pyx_f_6pandas_5tslib__is_tzlocal(__pyx_v_tz) != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":564
 *                 reso = curr_reso
 *     elif _is_tzlocal(tz):
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             if stamps[i] == NPY_NAT:
 *                 continue
 */
    __pyx_t_1 = __pyx_v_n;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "pandas/src/period.pyx":565
 *     elif _is_tzlocal(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 */
      __pyx_t_7 = __pyx_v_i;
      __pyx_t_5 = -1;
      if (__pyx_t_7 < 0) {
        __pyx_t_7 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_7 < 0)) __pyx_t_5 = 0;
      } else if (unlikely(__pyx_t_7 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
      if (unlikely(__pyx_t_5 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_5);
        __PYX_ERR(0, 565, __pyx_L1_error)
      }
      __pyx_t_2 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
      if (__pyx_t_2) {

        /* "pandas/src/period.pyx":566
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 *                 continue             # <<<<<<<<<<<<<<
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)
 */
        goto __pyx_L8_continue;

        /* "pandas/src/period.pyx":565
 *     elif _is_tzlocal(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 */
      }

      /* "pandas/src/period.pyx":567
 *             if stamps[i] == NPY_NAT:
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,             # <<<<<<<<<<<<<<
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 */
      __pyx_t_8 = __pyx_v_i;
      __pyx_t_5 = -1;
      if (__pyx_t_8 < 0) {
        __pyx_t_8 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_8 < 0)) __pyx_t_5 = 0;
      } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
      if (unlikely(__pyx_t_5 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_5);
        __PYX_ERR(0, 567, __pyx_L1_error)
      }

      /* "pandas/src/period.pyx":568
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)             # <<<<<<<<<<<<<<
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 *                           dts.min, dts.sec, dts.us, tz)
 */
      pandas_datetime_to_datetimestruct((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_stamps.diminfo[0].strides)), PANDAS_FR_ns, (&__pyx_v_dts));

      /* "pandas/src/period.pyx":569
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,             # <<<<<<<<<<<<<<
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 */
      __pyx_t_9 = __Pyx_PyInt_From_npy_int64(__pyx_v_dts.year); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.month); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.day); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.hour); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "pandas/src/period.pyx":570
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 *                           dts.min, dts.sec, dts.us, tz)             # <<<<<<<<<<<<<<
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 */
      __pyx_t_13 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.min); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.sec); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_15 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.us); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);

      /* "pandas/src/period.pyx":569
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,             # <<<<<<<<<<<<<<
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 */
      __pyx_t_16 = PyTuple_New(8); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_16, 2, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_16, 3, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_16, 4, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_16, 5, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_16, 6, __pyx_t_15);
      __Pyx_INCREF(__pyx_v_tz);
      __Pyx_GIVEREF(__pyx_v_tz);
      PyTuple_SET_ITEM(__pyx_t_16, 7, __pyx_v_tz);
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;
      __pyx_t_11 = 0;
      __pyx_t_12 = 0;
      __pyx_t_13 = 0;
      __pyx_t_14 = 0;
      __pyx_t_15 = 0;
      __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8datetime_datetime), __pyx_t_16, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dt, ((PyDateTime_DateTime *)__pyx_t_15));
      __pyx_t_15 = 0;

      /* "pandas/src/period.pyx":571
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000             # <<<<<<<<<<<<<<
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 *                                               PANDAS_FR_ns, &dts)
 */
      __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_utcoffset); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 571, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_14 = NULL;
      __pyx_t_17 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_16))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_16);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_16, function);
          __pyx_t_17 = 1;
        }
      }
      __pyx_t_13 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 571, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_14) {
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL;
      }
      __Pyx_INCREF(__pyx_v_tz);
      __Pyx_GIVEREF(__pyx_v_tz);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_17, __pyx_v_tz);
      __Pyx_INCREF(((PyObject *)__pyx_v_dt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_dt));
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_17, ((PyObject *)__pyx_v_dt));
      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_13, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 571, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = __Pyx_PyInt_FromDouble(total_seconds(__pyx_t_15)); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 571, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = PyNumber_Multiply(__pyx_t_16, __pyx_int_1000000000); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 571, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF_SET(__pyx_v_delta, __pyx_t_15);
      __pyx_t_15 = 0;

      /* "pandas/src/period.pyx":572
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,             # <<<<<<<<<<<<<<
 *                                               PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 */
      __pyx_t_18 = __pyx_v_i;
      __pyx_t_5 = -1;
      if (__pyx_t_18 < 0) {
        __pyx_t_18 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_18 < 0)) __pyx_t_5 = 0;
      } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
      if (unlikely(__pyx_t_5 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_5);
        __PYX_ERR(0, 572, __pyx_L1_error)
      }
      __pyx_t_15 = __Pyx_PyInt_From_npy_int64((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_stamps.diminfo[0].strides))); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = PyNumber_Add(__pyx_t_15, __pyx_v_delta); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_19 = __Pyx_PyInt_As_npy_int64(__pyx_t_16); if (unlikely((__pyx_t_19 == (npy_datetime)-1) && PyErr_Occurred())) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

      /* "pandas/src/period.pyx":573
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 *                                               PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:
 */
      pandas_datetime_to_datetimestruct(__pyx_t_19, PANDAS_FR_ns, (&__pyx_v_dts));

      /* "pandas/src/period.pyx":574
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 *                                               PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)             # <<<<<<<<<<<<<<
 *             if curr_reso < reso:
 *                 reso = curr_reso
 */
      __pyx_v_curr_reso = __pyx_f_6pandas_7_period__reso_stamp((&__pyx_v_dts));

      /* "pandas/src/period.pyx":575
 *                                               PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                 reso = curr_reso
 *     else:
 */
      __pyx_t_2 = ((__pyx_v_curr_reso < __pyx_v_reso) != 0);
      if (__pyx_t_2) {

        /* "pandas/src/period.pyx":576
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:
 *                 reso = curr_reso             # <<<<<<<<<<<<<<
 *     else:
 *         # Adjust datetime64 timestamp, recompute datetimestruct
 */
        __pyx_v_reso = __pyx_v_curr_reso;

        /* "pandas/src/period.pyx":575
 *                                               PANDAS_FR_ns, &dts)
 *             curr_reso = _reso_stamp(&dts)
 *             if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                 reso = curr_reso
 *     else:
 */
      }
      __pyx_L8_continue:;
    }

    /* "pandas/src/period.pyx":563
 *             if curr_reso < reso:
 *                 reso = curr_reso
 *     elif _is_tzlocal(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
    goto __pyx_L3;
  }

  /* "pandas/src/period.pyx":579
 *     else:
 *         # Adjust datetime64 timestamp, recompute datetimestruct
 *         trans, deltas, typ = _get_dst_info(tz)             # <<<<<<<<<<<<<<
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 */
  /*else*/ {
    __pyx_t_16 = __pyx_f_6pandas_5tslib__get_dst_info(__pyx_v_tz); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    if ((likely(PyTuple_CheckExact(__pyx_t_16))) || (PyList_CheckExact(__pyx_t_16))) {
      PyObject* sequence = __pyx_t_16;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 579, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_15 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_14 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_15 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_13 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_14 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_14);
      #else
      __pyx_t_15 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      #endif
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_12 = PyObject_GetIter(__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 579, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_20 = Py_TYPE(__pyx_t_12)->tp_iternext;
      index = 0; __pyx_t_15 = __pyx_t_20(__pyx_t_12); if (unlikely(!__pyx_t_15)) goto __pyx_L12_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_15);
      index = 1; __pyx_t_13 = __pyx_t_20(__pyx_t_12); if (unlikely(!__pyx_t_13)) goto __pyx_L12_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_13);
      index = 2; __pyx_t_14 = __pyx_t_20(__pyx_t_12); if (unlikely(!__pyx_t_14)) goto __pyx_L12_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_14);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_12), 3) < 0) __PYX_ERR(0, 579, __pyx_L1_error)
      __pyx_t_20 = NULL;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L13_unpacking_done;
      __pyx_L12_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_20 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 579, __pyx_L1_error)
      __pyx_L13_unpacking_done:;
    }
    if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 579, __pyx_L1_error)
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 579, __pyx_L1_error)
    __pyx_t_21 = ((PyArrayObject *)__pyx_t_15);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_trans.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_trans.rcbuffer->pybuffer, (PyObject*)__pyx_v_trans, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_trans.diminfo[0].strides = __pyx_pybuffernd_trans.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_trans.diminfo[0].shape = __pyx_pybuffernd_trans.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 579, __pyx_L1_error)
    }
    __pyx_t_21 = 0;
    __pyx_v_trans = ((PyArrayObject *)__pyx_t_15);
    __pyx_t_15 = 0;
    __pyx_t_21 = ((PyArrayObject *)__pyx_t_13);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_v_deltas, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_deltas.diminfo[0].strides = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_deltas.diminfo[0].shape = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 579, __pyx_L1_error)
    }
    __pyx_t_21 = 0;
    __pyx_v_deltas = ((PyArrayObject *)__pyx_t_13);
    __pyx_t_13 = 0;
    __pyx_v_typ = __pyx_t_14;
    __pyx_t_14 = 0;

    /* "pandas/src/period.pyx":581
 *         trans, deltas, typ = _get_dst_info(tz)
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1             # <<<<<<<<<<<<<<
 *         if _pos.dtype != np.int64:
 *             _pos = _pos.astype(np.int64)
 */
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_trans), __pyx_n_s_searchsorted); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_INCREF(((PyObject *)__pyx_v_stamps));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_stamps));
    PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_stamps));
    __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_side, __pyx_n_s_right) < 0) __PYX_ERR(0, 581, __pyx_L1_error)
    __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_14, __pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = __Pyx_PyInt_SubtractObjC(__pyx_t_15, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_v__pos = __pyx_t_13;
    __pyx_t_13 = 0;

    /* "pandas/src/period.pyx":582
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 *         if _pos.dtype != np.int64:             # <<<<<<<<<<<<<<
 *             _pos = _pos.astype(np.int64)
 *         pos = _pos
 */
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v__pos, __pyx_n_s_dtype); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_int64); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = PyObject_RichCompare(__pyx_t_13, __pyx_t_14, Py_NE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (__pyx_t_2) {

      /* "pandas/src/period.pyx":583
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 *         if _pos.dtype != np.int64:
 *             _pos = _pos.astype(np.int64)             # <<<<<<<<<<<<<<
 *         pos = _pos
 * 
 */
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v__pos, __pyx_n_s_astype); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 583, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 583, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_int64); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 583, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      if (!__pyx_t_13) {
        __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_16); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 583, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_15);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 583, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_16);
        __pyx_t_16 = 0;
        __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_12, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 583, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF_SET(__pyx_v__pos, __pyx_t_15);
      __pyx_t_15 = 0;

      /* "pandas/src/period.pyx":582
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 *         if _pos.dtype != np.int64:             # <<<<<<<<<<<<<<
 *             _pos = _pos.astype(np.int64)
 *         pos = _pos
 */
    }

    /* "pandas/src/period.pyx":584
 *         if _pos.dtype != np.int64:
 *             _pos = _pos.astype(np.int64)
 *         pos = _pos             # <<<<<<<<<<<<<<
 * 
 *         # statictzinfo
 */
    if (!(likely(((__pyx_v__pos) == Py_None) || likely(__Pyx_TypeTest(__pyx_v__pos, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 584, __pyx_L1_error)
    __pyx_t_15 = __pyx_v__pos;
    __Pyx_INCREF(__pyx_t_15);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pos.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pos.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_15), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pos.rcbuffer->pybuffer, (PyObject*)__pyx_v_pos, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_pos.diminfo[0].strides = __pyx_pybuffernd_pos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pos.diminfo[0].shape = __pyx_pybuffernd_pos.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 584, __pyx_L1_error)
    }
    __pyx_v_pos = ((PyArrayObject *)__pyx_t_15);
    __pyx_t_15 = 0;

    /* "pandas/src/period.pyx":587
 * 
 *         # statictzinfo
 *         if typ not in ['pytz', 'dateutil']:             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 */
    __Pyx_INCREF(__pyx_v_typ);
    __pyx_t_15 = __pyx_v_typ;
    __pyx_t_25 = (__Pyx_PyString_Equals(__pyx_t_15, __pyx_n_s_pytz, Py_NE)); if (unlikely(__pyx_t_25 < 0)) __PYX_ERR(0, 587, __pyx_L1_error)
    if (__pyx_t_25) {
    } else {
      __pyx_t_2 = __pyx_t_25;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_25 = (__Pyx_PyString_Equals(__pyx_t_15, __pyx_n_s_dateutil, Py_NE)); if (unlikely(__pyx_t_25 < 0)) __PYX_ERR(0, 587, __pyx_L1_error)
    __pyx_t_2 = __pyx_t_25;
    __pyx_L16_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_25 = (__pyx_t_2 != 0);
    if (__pyx_t_25) {

      /* "pandas/src/period.pyx":588
 *         # statictzinfo
 *         if typ not in ['pytz', 'dateutil']:
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if stamps[i] == NPY_NAT:
 *                     continue
 */
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
        __pyx_v_i = __pyx_t_3;

        /* "pandas/src/period.pyx":589
 *         if typ not in ['pytz', 'dateutil']:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 */
        __pyx_t_26 = __pyx_v_i;
        __pyx_t_5 = -1;
        if (__pyx_t_26 < 0) {
          __pyx_t_26 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_26 < 0)) __pyx_t_5 = 0;
        } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
        if (unlikely(__pyx_t_5 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_5);
          __PYX_ERR(0, 589, __pyx_L1_error)
        }
        __pyx_t_25 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
        if (__pyx_t_25) {

          /* "pandas/src/period.pyx":590
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 *                     continue             # <<<<<<<<<<<<<<
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 *                                                   PANDAS_FR_ns, &dts)
 */
          goto __pyx_L18_continue;

          /* "pandas/src/period.pyx":589
 *         if typ not in ['pytz', 'dateutil']:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 */
        }

        /* "pandas/src/period.pyx":591
 *                 if stamps[i] == NPY_NAT:
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],             # <<<<<<<<<<<<<<
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)
 */
        __pyx_t_27 = __pyx_v_i;
        __pyx_t_5 = -1;
        if (__pyx_t_27 < 0) {
          __pyx_t_27 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_27 < 0)) __pyx_t_5 = 0;
        } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
        if (unlikely(__pyx_t_5 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_5);
          __PYX_ERR(0, 591, __pyx_L1_error)
        }
        __pyx_t_28 = 0;
        __pyx_t_5 = -1;
        if (__pyx_t_28 < 0) {
          __pyx_t_28 += __pyx_pybuffernd_deltas.diminfo[0].shape;
          if (unlikely(__pyx_t_28 < 0)) __pyx_t_5 = 0;
        } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_deltas.diminfo[0].shape)) __pyx_t_5 = 0;
        if (unlikely(__pyx_t_5 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_5);
          __PYX_ERR(0, 591, __pyx_L1_error)
        }

        /* "pandas/src/period.pyx":592
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 *                                                   PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:
 */
        pandas_datetime_to_datetimestruct(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_stamps.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_deltas.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_deltas.diminfo[0].strides))), PANDAS_FR_ns, (&__pyx_v_dts));

        /* "pandas/src/period.pyx":593
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)             # <<<<<<<<<<<<<<
 *                 if curr_reso < reso:
 *                     reso = curr_reso
 */
        __pyx_v_curr_reso = __pyx_f_6pandas_7_period__reso_stamp((&__pyx_v_dts));

        /* "pandas/src/period.pyx":594
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                     reso = curr_reso
 *         else:
 */
        __pyx_t_25 = ((__pyx_v_curr_reso < __pyx_v_reso) != 0);
        if (__pyx_t_25) {

          /* "pandas/src/period.pyx":595
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:
 *                     reso = curr_reso             # <<<<<<<<<<<<<<
 *         else:
 *             for i in range(n):
 */
          __pyx_v_reso = __pyx_v_curr_reso;

          /* "pandas/src/period.pyx":594
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                     reso = curr_reso
 *         else:
 */
        }
        __pyx_L18_continue:;
      }

      /* "pandas/src/period.pyx":587
 * 
 *         # statictzinfo
 *         if typ not in ['pytz', 'dateutil']:             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 */
      goto __pyx_L15;
    }

    /* "pandas/src/period.pyx":597
 *                     reso = curr_reso
 *         else:
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if stamps[i] == NPY_NAT:
 *                     continue
 */
    /*else*/ {
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
        __pyx_v_i = __pyx_t_3;

        /* "pandas/src/period.pyx":598
 *         else:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 */
        __pyx_t_29 = __pyx_v_i;
        __pyx_t_5 = -1;
        if (__pyx_t_29 < 0) {
          __pyx_t_29 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_29 < 0)) __pyx_t_5 = 0;
        } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
        if (unlikely(__pyx_t_5 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_5);
          __PYX_ERR(0, 598, __pyx_L1_error)
        }
        __pyx_t_25 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
        if (__pyx_t_25) {

          /* "pandas/src/period.pyx":599
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 *                     continue             # <<<<<<<<<<<<<<
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 *                                                   PANDAS_FR_ns, &dts)
 */
          goto __pyx_L22_continue;

          /* "pandas/src/period.pyx":598
 *         else:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 */
        }

        /* "pandas/src/period.pyx":600
 *                 if stamps[i] == NPY_NAT:
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],             # <<<<<<<<<<<<<<
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)
 */
        __pyx_t_30 = __pyx_v_i;
        __pyx_t_5 = -1;
        if (__pyx_t_30 < 0) {
          __pyx_t_30 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_30 < 0)) __pyx_t_5 = 0;
        } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_5 = 0;
        if (unlikely(__pyx_t_5 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_5);
          __PYX_ERR(0, 600, __pyx_L1_error)
        }
        __pyx_t_31 = __pyx_v_i;
        __pyx_t_5 = -1;
        if (__pyx_t_31 < 0) {
          __pyx_t_31 += __pyx_pybuffernd_pos.diminfo[0].shape;
          if (unlikely(__pyx_t_31 < 0)) __pyx_t_5 = 0;
        } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_pos.diminfo[0].shape)) __pyx_t_5 = 0;
        if (unlikely(__pyx_t_5 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_5);
          __PYX_ERR(0, 600, __pyx_L1_error)
        }
        __pyx_t_32 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_pos.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_pos.diminfo[0].strides));
        __pyx_t_5 = -1;
        if (__pyx_t_32 < 0) {
          __pyx_t_32 += __pyx_pybuffernd_deltas.diminfo[0].shape;
          if (unlikely(__pyx_t_32 < 0)) __pyx_t_5 = 0;
        } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_deltas.diminfo[0].shape)) __pyx_t_5 = 0;
        if (unlikely(__pyx_t_5 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_5);
          __PYX_ERR(0, 600, __pyx_L1_error)
        }

        /* "pandas/src/period.pyx":601
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 *                                                   PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:
 */
        pandas_datetime_to_datetimestruct(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_stamps.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_deltas.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_deltas.diminfo[0].strides))), PANDAS_FR_ns, (&__pyx_v_dts));

        /* "pandas/src/period.pyx":602
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)             # <<<<<<<<<<<<<<
 *                 if curr_reso < reso:
 *                     reso = curr_reso
 */
        __pyx_v_curr_reso = __pyx_f_6pandas_7_period__reso_stamp((&__pyx_v_dts));

        /* "pandas/src/period.pyx":603
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                     reso = curr_reso
 * 
 */
        __pyx_t_25 = ((__pyx_v_curr_reso < __pyx_v_reso) != 0);
        if (__pyx_t_25) {

          /* "pandas/src/period.pyx":604
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:
 *                     reso = curr_reso             # <<<<<<<<<<<<<<
 * 
 *     return reso
 */
          __pyx_v_reso = __pyx_v_curr_reso;

          /* "pandas/src/period.pyx":603
 *                                                   PANDAS_FR_ns, &dts)
 *                 curr_reso = _reso_stamp(&dts)
 *                 if curr_reso < reso:             # <<<<<<<<<<<<<<
 *                     reso = curr_reso
 * 
 */
        }
        __pyx_L22_continue:;
      }
    }
    __pyx_L15:;
  }
  __pyx_L3:;

  /* "pandas/src/period.pyx":606
 *                     reso = curr_reso
 * 
 *     return reso             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_reso); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_r = __pyx_t_15;
  __pyx_t_15 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":548
 *     return D_RESO
 * 
 * cdef _reso_local(ndarray[int64_t] stamps, object tz):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t n = len(stamps)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period._reso_local", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pos.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_trans);
  __Pyx_XDECREF((PyObject *)__pyx_v_deltas);
  __Pyx_XDECREF((PyObject *)__pyx_v_pos);
  __Pyx_XDECREF((PyObject *)__pyx_v_dt);
  __Pyx_XDECREF(__pyx_v_delta);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v__pos);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":611
 * # period helpers
 * 
 * cdef ndarray[int64_t] localize_dt64arr_to_period(ndarray[int64_t] stamps,             # <<<<<<<<<<<<<<
 *                                                  int freq, object tz):
 *     cdef:
 */

static PyArrayObject *__pyx_f_6pandas_7_period_localize_dt64arr_to_period(PyArrayObject *__pyx_v_stamps, int __pyx_v_freq, PyObject *__pyx_v_tz) {
  Py_ssize_t __pyx_v_n;
  PyArrayObject *__pyx_v_result = 0;
  PyArrayObject *__pyx_v_trans = 0;
  PyArrayObject *__pyx_v_deltas = 0;
  PyArrayObject *__pyx_v_pos = 0;
  pandas_datetimestruct __pyx_v_dts;
  Py_ssize_t __pyx_v_i;
  PyDateTime_DateTime *__pyx_v_dt = NULL;
  PyObject *__pyx_v_delta = NULL;
  PyObject *__pyx_v_typ = NULL;
  PyObject *__pyx_v__pos = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_deltas;
  __Pyx_Buffer __pyx_pybuffer_deltas;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_pos;
  __Pyx_Buffer __pyx_pybuffer_pos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_stamps;
  __Pyx_Buffer __pyx_pybuffer_stamps;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_trans;
  __Pyx_Buffer __pyx_pybuffer_trans;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  __pyx_t_5numpy_int64_t __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  Py_ssize_t __pyx_t_18;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  Py_ssize_t __pyx_t_23;
  Py_ssize_t __pyx_t_24;
  npy_datetime __pyx_t_25;
  Py_ssize_t __pyx_t_26;
  PyObject *(*__pyx_t_27)(PyObject *);
  PyArrayObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  Py_ssize_t __pyx_t_32;
  Py_ssize_t __pyx_t_33;
  Py_ssize_t __pyx_t_34;
  Py_ssize_t __pyx_t_35;
  Py_ssize_t __pyx_t_36;
  Py_ssize_t __pyx_t_37;
  Py_ssize_t __pyx_t_38;
  Py_ssize_t __pyx_t_39;
  Py_ssize_t __pyx_t_40;
  __pyx_t_5numpy_int64_t __pyx_t_41;
  Py_ssize_t __pyx_t_42;
  __Pyx_RefNannySetupContext("localize_dt64arr_to_period", 0);
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  __pyx_pybuffer_trans.pybuffer.buf = NULL;
  __pyx_pybuffer_trans.refcount = 0;
  __pyx_pybuffernd_trans.data = NULL;
  __pyx_pybuffernd_trans.rcbuffer = &__pyx_pybuffer_trans;
  __pyx_pybuffer_deltas.pybuffer.buf = NULL;
  __pyx_pybuffer_deltas.refcount = 0;
  __pyx_pybuffernd_deltas.data = NULL;
  __pyx_pybuffernd_deltas.rcbuffer = &__pyx_pybuffer_deltas;
  __pyx_pybuffer_pos.pybuffer.buf = NULL;
  __pyx_pybuffer_pos.refcount = 0;
  __pyx_pybuffernd_pos.data = NULL;
  __pyx_pybuffernd_pos.rcbuffer = &__pyx_pybuffer_pos;
  __pyx_pybuffer_stamps.pybuffer.buf = NULL;
  __pyx_pybuffer_stamps.refcount = 0;
  __pyx_pybuffernd_stamps.data = NULL;
  __pyx_pybuffernd_stamps.rcbuffer = &__pyx_pybuffer_stamps;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer, (PyObject*)__pyx_v_stamps, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 611, __pyx_L1_error)
  }
  __pyx_pybuffernd_stamps.diminfo[0].strides = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_stamps.diminfo[0].shape = __pyx_pybuffernd_stamps.rcbuffer->pybuffer.shape[0];

  /* "pandas/src/period.pyx":614
 *                                                  int freq, object tz):
 *     cdef:
 *         Py_ssize_t n = len(stamps)             # <<<<<<<<<<<<<<
 *         ndarray[int64_t] result = np.empty(n, dtype=np.int64)
 *         ndarray[int64_t] trans, deltas, pos
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_stamps)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 614, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "pandas/src/period.pyx":615
 *     cdef:
 *         Py_ssize_t n = len(stamps)
 *         ndarray[int64_t] result = np.empty(n, dtype=np.int64)             # <<<<<<<<<<<<<<
 *         ndarray[int64_t] trans, deltas, pos
 *         pandas_datetimestruct dts
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 615, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_result = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_result.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 615, __pyx_L1_error)
    } else {__pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pandas/src/period.pyx":619
 *         pandas_datetimestruct dts
 * 
 *     if not have_pytz:             # <<<<<<<<<<<<<<
 *         raise Exception('Could not find pytz module')
 * 
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_have_pytz); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_9 = ((!__pyx_t_8) != 0);
  if (__pyx_t_9) {

    /* "pandas/src/period.pyx":620
 * 
 *     if not have_pytz:
 *         raise Exception('Could not find pytz module')             # <<<<<<<<<<<<<<
 * 
 *     if _is_utc(tz):
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 620, __pyx_L1_error)

    /* "pandas/src/period.pyx":619
 *         pandas_datetimestruct dts
 * 
 *     if not have_pytz:             # <<<<<<<<<<<<<<
 *         raise Exception('Could not find pytz module')
 * 
 */
  }

  /* "pandas/src/period.pyx":622
 *         raise Exception('Could not find pytz module')
 * 
 *     if _is_utc(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
  __pyx_t_9 = (__pyx_f_6pandas_5tslib__is_utc(__pyx_v_tz) != 0);
  if (__pyx_t_9) {

    /* "pandas/src/period.pyx":623
 * 
 *     if _is_utc(tz):
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             if stamps[i] == NPY_NAT:
 *                 result[i] = NPY_NAT
 */
    __pyx_t_1 = __pyx_v_n;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_1; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pandas/src/period.pyx":624
 *     if _is_utc(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 result[i] = NPY_NAT
 *                 continue
 */
      __pyx_t_11 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_11 < 0) {
        __pyx_t_11 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        __PYX_ERR(0, 624, __pyx_L1_error)
      }
      __pyx_t_9 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
      if (__pyx_t_9) {

        /* "pandas/src/period.pyx":625
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 *                 result[i] = NPY_NAT             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 */
        __pyx_t_13 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_pybuffernd_result.diminfo[0].shape;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 625, __pyx_L1_error)
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_6pandas_7_period_NPY_NAT;

        /* "pandas/src/period.pyx":626
 *             if stamps[i] == NPY_NAT:
 *                 result[i] = NPY_NAT
 *                 continue             # <<<<<<<<<<<<<<
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 */
        goto __pyx_L5_continue;

        /* "pandas/src/period.pyx":624
 *     if _is_utc(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 result[i] = NPY_NAT
 *                 continue
 */
      }

      /* "pandas/src/period.pyx":627
 *                 result[i] = NPY_NAT
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *             result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 *                                            dts.hour, dts.min, dts.sec,
 */
      __pyx_t_14 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_14 < 0) {
        __pyx_t_14 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_14 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        __PYX_ERR(0, 627, __pyx_L1_error)
      }
      pandas_datetime_to_datetimestruct((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_stamps.diminfo[0].strides)), PANDAS_FR_ns, (&__pyx_v_dts));

      /* "pandas/src/period.pyx":628
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
 *             result[i] = get_period_ordinal(dts.year, dts.month, dts.day,             # <<<<<<<<<<<<<<
 *                                            dts.hour, dts.min, dts.sec,
 *                                            dts.us, dts.ps, freq)
 */
      __pyx_t_15 = get_period_ordinal(__pyx_v_dts.year, __pyx_v_dts.month, __pyx_v_dts.day, __pyx_v_dts.hour, __pyx_v_dts.min, __pyx_v_dts.sec, __pyx_v_dts.us, __pyx_v_dts.ps, __pyx_v_freq); if (unlikely(__pyx_t_15 == INT32_MIN)) __PYX_ERR(0, 628, __pyx_L1_error)
      __pyx_t_16 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_16 < 0) {
        __pyx_t_16 += __pyx_pybuffernd_result.diminfo[0].shape;
        if (unlikely(__pyx_t_16 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        __PYX_ERR(0, 628, __pyx_L1_error)
      }
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_t_15;
      __pyx_L5_continue:;
    }

    /* "pandas/src/period.pyx":622
 *         raise Exception('Could not find pytz module')
 * 
 *     if _is_utc(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":632
 *                                            dts.us, dts.ps, freq)
 * 
 *     elif _is_tzlocal(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
  __pyx_t_9 = (__pyx_f_6pandas_5tslib__is_tzlocal(__pyx_v_tz) != 0);
  if (__pyx_t_9) {

    /* "pandas/src/period.pyx":633
 * 
 *     elif _is_tzlocal(tz):
 *         for i in range(n):             # <<<<<<<<<<<<<<
 *             if stamps[i] == NPY_NAT:
 *                 result[i] = NPY_NAT
 */
    __pyx_t_1 = __pyx_v_n;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_1; __pyx_t_10+=1) {
      __pyx_v_i = __pyx_t_10;

      /* "pandas/src/period.pyx":634
 *     elif _is_tzlocal(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 result[i] = NPY_NAT
 *                 continue
 */
      __pyx_t_17 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_17 < 0) {
        __pyx_t_17 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_17 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        __PYX_ERR(0, 634, __pyx_L1_error)
      }
      __pyx_t_9 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
      if (__pyx_t_9) {

        /* "pandas/src/period.pyx":635
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 *                 result[i] = NPY_NAT             # <<<<<<<<<<<<<<
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 */
        __pyx_t_18 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_18 < 0) {
          __pyx_t_18 += __pyx_pybuffernd_result.diminfo[0].shape;
          if (unlikely(__pyx_t_18 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 635, __pyx_L1_error)
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_6pandas_7_period_NPY_NAT;

        /* "pandas/src/period.pyx":636
 *             if stamps[i] == NPY_NAT:
 *                 result[i] = NPY_NAT
 *                 continue             # <<<<<<<<<<<<<<
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)
 */
        goto __pyx_L8_continue;

        /* "pandas/src/period.pyx":634
 *     elif _is_tzlocal(tz):
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                 result[i] = NPY_NAT
 *                 continue
 */
      }

      /* "pandas/src/period.pyx":637
 *                 result[i] = NPY_NAT
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,             # <<<<<<<<<<<<<<
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 */
      __pyx_t_19 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_19 < 0) {
        __pyx_t_19 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_19 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        __PYX_ERR(0, 637, __pyx_L1_error)
      }

      /* "pandas/src/period.pyx":638
 *                 continue
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)             # <<<<<<<<<<<<<<
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 *                           dts.min, dts.sec, dts.us, tz)
 */
      pandas_datetime_to_datetimestruct((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_stamps.diminfo[0].strides)), PANDAS_FR_ns, (&__pyx_v_dts));

      /* "pandas/src/period.pyx":639
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,             # <<<<<<<<<<<<<<
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 */
      __pyx_t_6 = __Pyx_PyInt_From_npy_int64(__pyx_v_dts.year); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.month); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.day); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.hour); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "pandas/src/period.pyx":640
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 *                           dts.min, dts.sec, dts.us, tz)             # <<<<<<<<<<<<<<
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 */
      __pyx_t_5 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.min); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 640, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_20 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.sec); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 640, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_21 = __Pyx_PyInt_From_npy_int32(__pyx_v_dts.us); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 640, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);

      /* "pandas/src/period.pyx":639
 *             pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
 *                                               &dts)
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,             # <<<<<<<<<<<<<<
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 */
      __pyx_t_22 = PyTuple_New(8); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_22);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_22, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_22, 3, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_22, 4, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_20);
      PyTuple_SET_ITEM(__pyx_t_22, 5, __pyx_t_20);
      __Pyx_GIVEREF(__pyx_t_21);
      PyTuple_SET_ITEM(__pyx_t_22, 6, __pyx_t_21);
      __Pyx_INCREF(__pyx_v_tz);
      __Pyx_GIVEREF(__pyx_v_tz);
      PyTuple_SET_ITEM(__pyx_t_22, 7, __pyx_v_tz);
      __pyx_t_6 = 0;
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_3 = 0;
      __pyx_t_5 = 0;
      __pyx_t_20 = 0;
      __pyx_t_21 = 0;
      __pyx_t_21 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8datetime_datetime), __pyx_t_22, NULL); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dt, ((PyDateTime_DateTime *)__pyx_t_21));
      __pyx_t_21 = 0;

      /* "pandas/src/period.pyx":641
 *             dt = datetime(dts.year, dts.month, dts.day, dts.hour,
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000             # <<<<<<<<<<<<<<
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 *                                               PANDAS_FR_ns, &dts)
 */
      __pyx_t_22 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_utcoffset); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_22);
      __pyx_t_20 = NULL;
      __pyx_t_23 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_22))) {
        __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_22);
        if (likely(__pyx_t_20)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
          __Pyx_INCREF(__pyx_t_20);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_22, function);
          __pyx_t_23 = 1;
        }
      }
      __pyx_t_5 = PyTuple_New(2+__pyx_t_23); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_20) {
        __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_20); __pyx_t_20 = NULL;
      }
      __Pyx_INCREF(__pyx_v_tz);
      __Pyx_GIVEREF(__pyx_v_tz);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_23, __pyx_v_tz);
      __Pyx_INCREF(((PyObject *)__pyx_v_dt));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_dt));
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_23, ((PyObject *)__pyx_v_dt));
      __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_5, NULL); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __pyx_t_22 = __Pyx_PyInt_FromDouble(total_seconds(__pyx_t_21)); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_22);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_21 = PyNumber_Multiply(__pyx_t_22, __pyx_int_1000000000); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_XDECREF_SET(__pyx_v_delta, __pyx_t_21);
      __pyx_t_21 = 0;

      /* "pandas/src/period.pyx":642
 *                           dts.min, dts.sec, dts.us, tz)
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,             # <<<<<<<<<<<<<<
 *                                               PANDAS_FR_ns, &dts)
 *             result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 */
      __pyx_t_24 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_24 < 0) {
        __pyx_t_24 += __pyx_pybuffernd_stamps.diminfo[0].shape;
        if (unlikely(__pyx_t_24 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        __PYX_ERR(0, 642, __pyx_L1_error)
      }
      __pyx_t_21 = __Pyx_PyInt_From_npy_int64((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_stamps.diminfo[0].strides))); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 642, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_22 = PyNumber_Add(__pyx_t_21, __pyx_v_delta); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 642, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_22);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_25 = __Pyx_PyInt_As_npy_int64(__pyx_t_22); if (unlikely((__pyx_t_25 == (npy_datetime)-1) && PyErr_Occurred())) __PYX_ERR(0, 642, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

      /* "pandas/src/period.pyx":643
 *             delta = int(total_seconds(_get_utcoffset(tz, dt))) * 1000000000
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 *                                               PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *             result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 *                                            dts.hour, dts.min, dts.sec,
 */
      pandas_datetime_to_datetimestruct(__pyx_t_25, PANDAS_FR_ns, (&__pyx_v_dts));

      /* "pandas/src/period.pyx":644
 *             pandas_datetime_to_datetimestruct(stamps[i] + delta,
 *                                               PANDAS_FR_ns, &dts)
 *             result[i] = get_period_ordinal(dts.year, dts.month, dts.day,             # <<<<<<<<<<<<<<
 *                                            dts.hour, dts.min, dts.sec,
 *                                            dts.us, dts.ps, freq)
 */
      __pyx_t_15 = get_period_ordinal(__pyx_v_dts.year, __pyx_v_dts.month, __pyx_v_dts.day, __pyx_v_dts.hour, __pyx_v_dts.min, __pyx_v_dts.sec, __pyx_v_dts.us, __pyx_v_dts.ps, __pyx_v_freq); if (unlikely(__pyx_t_15 == INT32_MIN)) __PYX_ERR(0, 644, __pyx_L1_error)
      __pyx_t_26 = __pyx_v_i;
      __pyx_t_12 = -1;
      if (__pyx_t_26 < 0) {
        __pyx_t_26 += __pyx_pybuffernd_result.diminfo[0].shape;
        if (unlikely(__pyx_t_26 < 0)) __pyx_t_12 = 0;
      } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
      if (unlikely(__pyx_t_12 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_12);
        __PYX_ERR(0, 644, __pyx_L1_error)
      }
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_t_15;
      __pyx_L8_continue:;
    }

    /* "pandas/src/period.pyx":632
 *                                            dts.us, dts.ps, freq)
 * 
 *     elif _is_tzlocal(tz):             # <<<<<<<<<<<<<<
 *         for i in range(n):
 *             if stamps[i] == NPY_NAT:
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":649
 *     else:
 *         # Adjust datetime64 timestamp, recompute datetimestruct
 *         trans, deltas, typ = _get_dst_info(tz)             # <<<<<<<<<<<<<<
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 */
  /*else*/ {
    __pyx_t_22 = __pyx_f_6pandas_5tslib__get_dst_info(__pyx_v_tz); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if ((likely(PyTuple_CheckExact(__pyx_t_22))) || (PyList_CheckExact(__pyx_t_22))) {
      PyObject* sequence = __pyx_t_22;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 649, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_21 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_20 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_21 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_20 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_21);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_20);
      #else
      __pyx_t_21 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 649, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 649, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_20 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 649, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      #endif
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_3 = PyObject_GetIter(__pyx_t_22); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 649, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __pyx_t_27 = Py_TYPE(__pyx_t_3)->tp_iternext;
      index = 0; __pyx_t_21 = __pyx_t_27(__pyx_t_3); if (unlikely(!__pyx_t_21)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_21);
      index = 1; __pyx_t_5 = __pyx_t_27(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 2; __pyx_t_20 = __pyx_t_27(__pyx_t_3); if (unlikely(!__pyx_t_20)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_20);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_27(__pyx_t_3), 3) < 0) __PYX_ERR(0, 649, __pyx_L1_error)
      __pyx_t_27 = NULL;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L12_unpacking_done;
      __pyx_L11_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_27 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 649, __pyx_L1_error)
      __pyx_L12_unpacking_done:;
    }
    if (!(likely(((__pyx_t_21) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_21, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 649, __pyx_L1_error)
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 649, __pyx_L1_error)
    __pyx_t_28 = ((PyArrayObject *)__pyx_t_21);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans.rcbuffer->pybuffer);
      __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_trans.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_12 < 0)) {
        PyErr_Fetch(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_trans.rcbuffer->pybuffer, (PyObject*)__pyx_v_trans, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_29); Py_XDECREF(__pyx_t_30); Py_XDECREF(__pyx_t_31);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_29, __pyx_t_30, __pyx_t_31);
        }
      }
      __pyx_pybuffernd_trans.diminfo[0].strides = __pyx_pybuffernd_trans.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_trans.diminfo[0].shape = __pyx_pybuffernd_trans.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
    }
    __pyx_t_28 = 0;
    __pyx_v_trans = ((PyArrayObject *)__pyx_t_21);
    __pyx_t_21 = 0;
    __pyx_t_28 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
      __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_12 < 0)) {
        PyErr_Fetch(&__pyx_t_31, &__pyx_t_30, &__pyx_t_29);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_v_deltas, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_31); Py_XDECREF(__pyx_t_30); Py_XDECREF(__pyx_t_29);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_31, __pyx_t_30, __pyx_t_29);
        }
      }
      __pyx_pybuffernd_deltas.diminfo[0].strides = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_deltas.diminfo[0].shape = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
    }
    __pyx_t_28 = 0;
    __pyx_v_deltas = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_v_typ = __pyx_t_20;
    __pyx_t_20 = 0;

    /* "pandas/src/period.pyx":651
 *         trans, deltas, typ = _get_dst_info(tz)
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1             # <<<<<<<<<<<<<<
 *         if _pos.dtype != np.int64:
 *             _pos = _pos.astype(np.int64)
 */
    __pyx_t_22 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_trans), __pyx_n_s_searchsorted); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_INCREF(((PyObject *)__pyx_v_stamps));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_stamps));
    PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)__pyx_v_stamps));
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_side, __pyx_n_s_right) < 0) __PYX_ERR(0, 651, __pyx_L1_error)
    __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_20, __pyx_t_5); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_SubtractObjC(__pyx_t_21, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __pyx_v__pos = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "pandas/src/period.pyx":652
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 *         if _pos.dtype != np.int64:             # <<<<<<<<<<<<<<
 *             _pos = _pos.astype(np.int64)
 *         pos = _pos
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v__pos, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_n_s_int64); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __pyx_t_21 = PyObject_RichCompare(__pyx_t_5, __pyx_t_20, Py_NE); __Pyx_XGOTREF(__pyx_t_21); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_21); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    if (__pyx_t_9) {

      /* "pandas/src/period.pyx":653
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 *         if _pos.dtype != np.int64:
 *             _pos = _pos.astype(np.int64)             # <<<<<<<<<<<<<<
 *         pos = _pos
 * 
 */
      __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_v__pos, __pyx_n_s_astype); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 653, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 653, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 653, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_22);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_20))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_20);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_20, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_21 = __Pyx_PyObject_CallOneArg(__pyx_t_20, __pyx_t_22); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 653, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
        __Pyx_GOTREF(__pyx_t_21);
      } else {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 653, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_22);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_22);
        __pyx_t_22 = 0;
        __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_3, NULL); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 653, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_21);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF_SET(__pyx_v__pos, __pyx_t_21);
      __pyx_t_21 = 0;

      /* "pandas/src/period.pyx":652
 * 
 *         _pos = trans.searchsorted(stamps, side='right') - 1
 *         if _pos.dtype != np.int64:             # <<<<<<<<<<<<<<
 *             _pos = _pos.astype(np.int64)
 *         pos = _pos
 */
    }

    /* "pandas/src/period.pyx":654
 *         if _pos.dtype != np.int64:
 *             _pos = _pos.astype(np.int64)
 *         pos = _pos             # <<<<<<<<<<<<<<
 * 
 *         # statictzinfo
 */
    if (!(likely(((__pyx_v__pos) == Py_None) || likely(__Pyx_TypeTest(__pyx_v__pos, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 654, __pyx_L1_error)
    __pyx_t_21 = __pyx_v__pos;
    __Pyx_INCREF(__pyx_t_21);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pos.rcbuffer->pybuffer);
      __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pos.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_21), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_12 < 0)) {
        PyErr_Fetch(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pos.rcbuffer->pybuffer, (PyObject*)__pyx_v_pos, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_29); Py_XDECREF(__pyx_t_30); Py_XDECREF(__pyx_t_31);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_29, __pyx_t_30, __pyx_t_31);
        }
      }
      __pyx_pybuffernd_pos.diminfo[0].strides = __pyx_pybuffernd_pos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pos.diminfo[0].shape = __pyx_pybuffernd_pos.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 654, __pyx_L1_error)
    }
    __pyx_v_pos = ((PyArrayObject *)__pyx_t_21);
    __pyx_t_21 = 0;

    /* "pandas/src/period.pyx":657
 * 
 *         # statictzinfo
 *         if typ not in ['pytz', 'dateutil']:             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 */
    __Pyx_INCREF(__pyx_v_typ);
    __pyx_t_21 = __pyx_v_typ;
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_t_21, __pyx_n_s_pytz, Py_NE)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 657, __pyx_L1_error)
    if (__pyx_t_8) {
    } else {
      __pyx_t_9 = __pyx_t_8;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_t_21, __pyx_n_s_dateutil, Py_NE)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 657, __pyx_L1_error)
    __pyx_t_9 = __pyx_t_8;
    __pyx_L15_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __pyx_t_8 = (__pyx_t_9 != 0);
    if (__pyx_t_8) {

      /* "pandas/src/period.pyx":658
 *         # statictzinfo
 *         if typ not in ['pytz', 'dateutil']:
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if stamps[i] == NPY_NAT:
 *                     result[i] = NPY_NAT
 */
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_1; __pyx_t_10+=1) {
        __pyx_v_i = __pyx_t_10;

        /* "pandas/src/period.pyx":659
 *         if typ not in ['pytz', 'dateutil']:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     result[i] = NPY_NAT
 *                     continue
 */
        __pyx_t_32 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_32 < 0) {
          __pyx_t_32 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_32 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 659, __pyx_L1_error)
        }
        __pyx_t_8 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
        if (__pyx_t_8) {

          /* "pandas/src/period.pyx":660
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 *                     result[i] = NPY_NAT             # <<<<<<<<<<<<<<
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 */
          __pyx_t_33 = __pyx_v_i;
          __pyx_t_12 = -1;
          if (__pyx_t_33 < 0) {
            __pyx_t_33 += __pyx_pybuffernd_result.diminfo[0].shape;
            if (unlikely(__pyx_t_33 < 0)) __pyx_t_12 = 0;
          } else if (unlikely(__pyx_t_33 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
          if (unlikely(__pyx_t_12 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_12);
            __PYX_ERR(0, 660, __pyx_L1_error)
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_6pandas_7_period_NPY_NAT;

          /* "pandas/src/period.pyx":661
 *                 if stamps[i] == NPY_NAT:
 *                     result[i] = NPY_NAT
 *                     continue             # <<<<<<<<<<<<<<
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 *                                                   PANDAS_FR_ns, &dts)
 */
          goto __pyx_L17_continue;

          /* "pandas/src/period.pyx":659
 *         if typ not in ['pytz', 'dateutil']:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     result[i] = NPY_NAT
 *                     continue
 */
        }

        /* "pandas/src/period.pyx":662
 *                     result[i] = NPY_NAT
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],             # <<<<<<<<<<<<<<
 *                                                   PANDAS_FR_ns, &dts)
 *                 result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 */
        __pyx_t_34 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_34 < 0) {
          __pyx_t_34 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_34 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_34 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 662, __pyx_L1_error)
        }
        __pyx_t_35 = 0;
        __pyx_t_12 = -1;
        if (__pyx_t_35 < 0) {
          __pyx_t_35 += __pyx_pybuffernd_deltas.diminfo[0].shape;
          if (unlikely(__pyx_t_35 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_35 >= __pyx_pybuffernd_deltas.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 662, __pyx_L1_error)
        }

        /* "pandas/src/period.pyx":663
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 *                                                   PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *                 result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 *                                                dts.hour, dts.min, dts.sec,
 */
        pandas_datetime_to_datetimestruct(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_stamps.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_deltas.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_deltas.diminfo[0].strides))), PANDAS_FR_ns, (&__pyx_v_dts));

        /* "pandas/src/period.pyx":664
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[0],
 *                                                   PANDAS_FR_ns, &dts)
 *                 result[i] = get_period_ordinal(dts.year, dts.month, dts.day,             # <<<<<<<<<<<<<<
 *                                                dts.hour, dts.min, dts.sec,
 *                                                dts.us, dts.ps, freq)
 */
        __pyx_t_15 = get_period_ordinal(__pyx_v_dts.year, __pyx_v_dts.month, __pyx_v_dts.day, __pyx_v_dts.hour, __pyx_v_dts.min, __pyx_v_dts.sec, __pyx_v_dts.us, __pyx_v_dts.ps, __pyx_v_freq); if (unlikely(__pyx_t_15 == INT32_MIN)) __PYX_ERR(0, 664, __pyx_L1_error)
        __pyx_t_36 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_36 < 0) {
          __pyx_t_36 += __pyx_pybuffernd_result.diminfo[0].shape;
          if (unlikely(__pyx_t_36 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_36 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 664, __pyx_L1_error)
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_t_15;
        __pyx_L17_continue:;
      }

      /* "pandas/src/period.pyx":657
 * 
 *         # statictzinfo
 *         if typ not in ['pytz', 'dateutil']:             # <<<<<<<<<<<<<<
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 */
      goto __pyx_L14;
    }

    /* "pandas/src/period.pyx":668
 *                                                dts.us, dts.ps, freq)
 *         else:
 *             for i in range(n):             # <<<<<<<<<<<<<<
 *                 if stamps[i] == NPY_NAT:
 *                     result[i] = NPY_NAT
 */
    /*else*/ {
      __pyx_t_1 = __pyx_v_n;
      for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_1; __pyx_t_10+=1) {
        __pyx_v_i = __pyx_t_10;

        /* "pandas/src/period.pyx":669
 *         else:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     result[i] = NPY_NAT
 *                     continue
 */
        __pyx_t_37 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_37 < 0) {
          __pyx_t_37 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_37 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_37 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 669, __pyx_L1_error)
        }
        __pyx_t_8 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_stamps.diminfo[0].strides)) == __pyx_v_6pandas_7_period_NPY_NAT) != 0);
        if (__pyx_t_8) {

          /* "pandas/src/period.pyx":670
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:
 *                     result[i] = NPY_NAT             # <<<<<<<<<<<<<<
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 */
          __pyx_t_38 = __pyx_v_i;
          __pyx_t_12 = -1;
          if (__pyx_t_38 < 0) {
            __pyx_t_38 += __pyx_pybuffernd_result.diminfo[0].shape;
            if (unlikely(__pyx_t_38 < 0)) __pyx_t_12 = 0;
          } else if (unlikely(__pyx_t_38 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
          if (unlikely(__pyx_t_12 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_12);
            __PYX_ERR(0, 670, __pyx_L1_error)
          }
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_6pandas_7_period_NPY_NAT;

          /* "pandas/src/period.pyx":671
 *                 if stamps[i] == NPY_NAT:
 *                     result[i] = NPY_NAT
 *                     continue             # <<<<<<<<<<<<<<
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 *                                                   PANDAS_FR_ns, &dts)
 */
          goto __pyx_L20_continue;

          /* "pandas/src/period.pyx":669
 *         else:
 *             for i in range(n):
 *                 if stamps[i] == NPY_NAT:             # <<<<<<<<<<<<<<
 *                     result[i] = NPY_NAT
 *                     continue
 */
        }

        /* "pandas/src/period.pyx":672
 *                     result[i] = NPY_NAT
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],             # <<<<<<<<<<<<<<
 *                                                   PANDAS_FR_ns, &dts)
 *                 result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 */
        __pyx_t_39 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_39 < 0) {
          __pyx_t_39 += __pyx_pybuffernd_stamps.diminfo[0].shape;
          if (unlikely(__pyx_t_39 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_39 >= __pyx_pybuffernd_stamps.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 672, __pyx_L1_error)
        }
        __pyx_t_40 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_40 < 0) {
          __pyx_t_40 += __pyx_pybuffernd_pos.diminfo[0].shape;
          if (unlikely(__pyx_t_40 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_40 >= __pyx_pybuffernd_pos.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 672, __pyx_L1_error)
        }
        __pyx_t_15 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_pos.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_pos.diminfo[0].strides));
        __pyx_t_12 = -1;
        if (__pyx_t_15 < 0) {
          __pyx_t_15 += __pyx_pybuffernd_deltas.diminfo[0].shape;
          if (unlikely(__pyx_t_15 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_deltas.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 672, __pyx_L1_error)
        }

        /* "pandas/src/period.pyx":673
 *                     continue
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 *                                                   PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *                 result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
 *                                                dts.hour, dts.min, dts.sec,
 */
        pandas_datetime_to_datetimestruct(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_stamps.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_stamps.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_deltas.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_deltas.diminfo[0].strides))), PANDAS_FR_ns, (&__pyx_v_dts));

        /* "pandas/src/period.pyx":674
 *                 pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos[i]],
 *                                                   PANDAS_FR_ns, &dts)
 *                 result[i] = get_period_ordinal(dts.year, dts.month, dts.day,             # <<<<<<<<<<<<<<
 *                                                dts.hour, dts.min, dts.sec,
 *                                                dts.us, dts.ps, freq)
 */
        __pyx_t_41 = get_period_ordinal(__pyx_v_dts.year, __pyx_v_dts.month, __pyx_v_dts.day, __pyx_v_dts.hour, __pyx_v_dts.min, __pyx_v_dts.sec, __pyx_v_dts.us, __pyx_v_dts.ps, __pyx_v_freq); if (unlikely(__pyx_t_41 == INT32_MIN)) __PYX_ERR(0, 674, __pyx_L1_error)
        __pyx_t_42 = __pyx_v_i;
        __pyx_t_12 = -1;
        if (__pyx_t_42 < 0) {
          __pyx_t_42 += __pyx_pybuffernd_result.diminfo[0].shape;
          if (unlikely(__pyx_t_42 < 0)) __pyx_t_12 = 0;
        } else if (unlikely(__pyx_t_42 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_12 = 0;
        if (unlikely(__pyx_t_12 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_12);
          __PYX_ERR(0, 674, __pyx_L1_error)
        }
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_t_41;
        __pyx_L20_continue:;
      }
    }
    __pyx_L14:;
  }
  __pyx_L4:;

  /* "pandas/src/period.pyx":678
 *                                                dts.us, dts.ps, freq)
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "pandas/src/period.pyx":611
 * # period helpers
 * 
 * cdef ndarray[int64_t] localize_dt64arr_to_period(ndarray[int64_t] stamps,             # <<<<<<<<<<<<<<
 *                                                  int freq, object tz):
 *     cdef:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pandas._period.localize_dt64arr_to_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pos.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_stamps.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trans.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF((PyObject *)__pyx_v_trans);
  __Pyx_XDECREF((PyObject *)__pyx_v_deltas);
  __Pyx_XDECREF((PyObject *)__pyx_v_pos);
  __Pyx_XDECREF((PyObject *)__pyx_v_dt);
  __Pyx_XDECREF(__pyx_v_delta);
  __Pyx_XDECREF(__pyx_v_typ);
  __Pyx_XDECREF(__pyx_v__pos);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":700
 * 
 *     @classmethod
 *     def _maybe_convert_freq(cls, object freq):             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(freq, (int, tuple)):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_1_maybe_convert_freq(PyObject *__pyx_v_cls, PyObject *__pyx_v_freq); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_1_maybe_convert_freq(PyObject *__pyx_v_cls, PyObject *__pyx_v_freq) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_maybe_convert_freq (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period__maybe_convert_freq(((PyTypeObject*)__pyx_v_cls), ((PyObject *)__pyx_v_freq));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period__maybe_convert_freq(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_freq) {
  PyObject *__pyx_v_code = NULL;
  PyObject *__pyx_v_stride = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_maybe_convert_freq", 0);
  __Pyx_INCREF(__pyx_v_freq);

  /* "pandas/src/period.pyx":702
 *     def _maybe_convert_freq(cls, object freq):
 * 
 *         if isinstance(freq, (int, tuple)):             # <<<<<<<<<<<<<<
 *             code, stride = frequencies.get_freq_code(freq)
 *             freq = frequencies._get_freq_str(code, stride)
 */
  __pyx_t_2 = PyInt_Check(__pyx_v_freq); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = PyTuple_Check(__pyx_v_freq); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":703
 * 
 *         if isinstance(freq, (int, tuple)):
 *             code, stride = frequencies.get_freq_code(freq)             # <<<<<<<<<<<<<<
 *             freq = frequencies._get_freq_str(code, stride)
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 703, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_freq);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 703, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_8(__pyx_t_5); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_7 = __pyx_t_8(__pyx_t_5); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_5), 2) < 0) __PYX_ERR(0, 703, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 703, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __pyx_v_code = __pyx_t_6;
    __pyx_t_6 = 0;
    __pyx_v_stride = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "pandas/src/period.pyx":704
 *         if isinstance(freq, (int, tuple)):
 *             code, stride = frequencies.get_freq_code(freq)
 *             freq = frequencies._get_freq_str(code, stride)             # <<<<<<<<<<<<<<
 * 
 *         freq = frequencies.to_offset(freq)
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_get_freq_str); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_v_code);
    __Pyx_GIVEREF(__pyx_v_code);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_v_code);
    __Pyx_INCREF(__pyx_v_stride);
    __Pyx_GIVEREF(__pyx_v_stride);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_v_stride);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":702
 *     def _maybe_convert_freq(cls, object freq):
 * 
 *         if isinstance(freq, (int, tuple)):             # <<<<<<<<<<<<<<
 *             code, stride = frequencies.get_freq_code(freq)
 *             freq = frequencies._get_freq_str(code, stride)
 */
  }

  /* "pandas/src/period.pyx":706
 *             freq = frequencies._get_freq_str(code, stride)
 * 
 *         freq = frequencies.to_offset(freq)             # <<<<<<<<<<<<<<
 * 
 *         if freq.n <= 0:
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_to_offset); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_freq);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":708
 *         freq = frequencies.to_offset(freq)
 * 
 *         if freq.n <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Frequency must be positive, because it'
 *                              ' represents span: {0}'.format(freq.freqstr))
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_freq, __pyx_n_s_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 708, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 708, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 708, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":710
 *         if freq.n <= 0:
 *             raise ValueError('Frequency must be positive, because it'
 *                              ' represents span: {0}'.format(freq.freqstr))             # <<<<<<<<<<<<<<
 * 
 *         return freq
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Frequency_must_be_positive_becau, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_freq, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 710, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 710, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 710, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":709
 * 
 *         if freq.n <= 0:
 *             raise ValueError('Frequency must be positive, because it'             # <<<<<<<<<<<<<<
 *                              ' represents span: {0}'.format(freq.freqstr))
 * 
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 709, __pyx_L1_error)

    /* "pandas/src/period.pyx":708
 *         freq = frequencies.to_offset(freq)
 * 
 *         if freq.n <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Frequency must be positive, because it'
 *                              ' represents span: {0}'.format(freq.freqstr))
 */
  }

  /* "pandas/src/period.pyx":712
 *                              ' represents span: {0}'.format(freq.freqstr))
 * 
 *         return freq             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_freq);
  __pyx_r = __pyx_v_freq;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":700
 * 
 *     @classmethod
 *     def _maybe_convert_freq(cls, object freq):             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(freq, (int, tuple)):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pandas._period._Period._maybe_convert_freq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_code);
  __Pyx_XDECREF(__pyx_v_stride);
  __Pyx_XDECREF(__pyx_v_freq);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":715
 * 
 *     @classmethod
 *     def _from_ordinal(cls, ordinal, freq):             # <<<<<<<<<<<<<<
 *         """
 *         Fast creation from an ordinal and freq that are already validated!
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_3_from_ordinal(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6pandas_7_period_7_Period_2_from_ordinal[] = "\n        Fast creation from an ordinal and freq that are already validated!\n        ";
static PyObject *__pyx_pw_6pandas_7_period_7_Period_3_from_ordinal(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ordinal = 0;
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_from_ordinal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ordinal,&__pyx_n_s_freq,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ordinal)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_from_ordinal", 1, 2, 2, 1); __PYX_ERR(0, 715, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_from_ordinal") < 0)) __PYX_ERR(0, 715, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_ordinal = values[0];
    __pyx_v_freq = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_from_ordinal", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 715, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period._Period._from_ordinal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_2_from_ordinal(((PyTypeObject*)__pyx_v_cls), __pyx_v_ordinal, __pyx_v_freq);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_2_from_ordinal(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_ordinal, PyObject *__pyx_v_freq) {
  PyObject *__pyx_v_self = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_from_ordinal", 0);

  /* "pandas/src/period.pyx":719
 *         Fast creation from an ordinal and freq that are already validated!
 *         """
 *         if ordinal == tslib.iNaT:             # <<<<<<<<<<<<<<
 *             return tslib.NaT
 *         else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_iNaT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 719, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_ordinal, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 719, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 719, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "pandas/src/period.pyx":720
 *         """
 *         if ordinal == tslib.iNaT:
 *             return tslib.NaT             # <<<<<<<<<<<<<<
 *         else:
 *             self = _Period.__new__(cls)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_NaT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":719
 *         Fast creation from an ordinal and freq that are already validated!
 *         """
 *         if ordinal == tslib.iNaT:             # <<<<<<<<<<<<<<
 *             return tslib.NaT
 *         else:
 */
  }

  /* "pandas/src/period.pyx":722
 *             return tslib.NaT
 *         else:
 *             self = _Period.__new__(cls)             # <<<<<<<<<<<<<<
 *             self.ordinal = ordinal
 *             self.freq = cls._maybe_convert_freq(freq)
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6pandas_7_period__Period), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cls)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 722, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_cls));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_cls));
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_cls));
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_self = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pandas/src/period.pyx":723
 *         else:
 *             self = _Period.__new__(cls)
 *             self.ordinal = ordinal             # <<<<<<<<<<<<<<
 *             self.freq = cls._maybe_convert_freq(freq)
 *             return self
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_ordinal, __pyx_v_ordinal) < 0) __PYX_ERR(0, 723, __pyx_L1_error)

    /* "pandas/src/period.pyx":724
 *             self = _Period.__new__(cls)
 *             self.ordinal = ordinal
 *             self.freq = cls._maybe_convert_freq(freq)             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s_maybe_convert_freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_freq); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_freq);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_freq, __pyx_t_2) < 0) __PYX_ERR(0, 724, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pandas/src/period.pyx":725
 *             self.ordinal = ordinal
 *             self.freq = cls._maybe_convert_freq(freq)
 *             return self             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(self, other, op):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_self);
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
  }

  /* "pandas/src/period.pyx":715
 * 
 *     @classmethod
 *     def _from_ordinal(cls, ordinal, freq):             # <<<<<<<<<<<<<<
 *         """
 *         Fast creation from an ordinal and freq that are already validated!
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pandas._period._Period._from_ordinal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":727
 *             return self
 * 
 *     def __richcmp__(self, other, op):             # <<<<<<<<<<<<<<
 *         if isinstance(other, Period):
 *             if other.freq != self.freq:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_5__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_op); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_5__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_op) {
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_v_op = __Pyx_PyInt_From_int(__pyx_arg_op); if (unlikely(!__pyx_v_op)) __PYX_ERR(0, 727, __pyx_L3_error)
  __Pyx_GOTREF(__pyx_v_op);
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period._Period.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_4__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((PyObject *)__pyx_v_op));

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_4__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_op) {
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "pandas/src/period.pyx":728
 * 
 *     def __richcmp__(self, other, op):
 *         if isinstance(other, Period):             # <<<<<<<<<<<<<<
 *             if other.freq != self.freq:
 *                 msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_other, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 728, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pandas/src/period.pyx":729
 *     def __richcmp__(self, other, op):
 *         if isinstance(other, Period):
 *             if other.freq != self.freq:             # <<<<<<<<<<<<<<
 *                 msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                 raise IncompatibleFrequency(msg)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 729, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 729, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":730
 *         if isinstance(other, Period):
 *             if other.freq != self.freq:
 *                 msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)             # <<<<<<<<<<<<<<
 *                 raise IncompatibleFrequency(msg)
 *             return PyObject_RichCompareBool(self.ordinal, other.ordinal, op)
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DIFFERENT_FREQ); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_4 = 0;
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_msg = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "pandas/src/period.pyx":731
 *             if other.freq != self.freq:
 *                 msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                 raise IncompatibleFrequency(msg)             # <<<<<<<<<<<<<<
 *             return PyObject_RichCompareBool(self.ordinal, other.ordinal, op)
 *         elif other is tslib.NaT:
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_IncompatibleFrequency); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 731, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_msg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 731, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 731, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(__pyx_v_msg);
        __Pyx_GIVEREF(__pyx_v_msg);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_msg);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 731, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 731, __pyx_L1_error)

      /* "pandas/src/period.pyx":729
 *     def __richcmp__(self, other, op):
 *         if isinstance(other, Period):
 *             if other.freq != self.freq:             # <<<<<<<<<<<<<<
 *                 msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                 raise IncompatibleFrequency(msg)
 */
    }

    /* "pandas/src/period.pyx":732
 *                 msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                 raise IncompatibleFrequency(msg)
 *             return PyObject_RichCompareBool(self.ordinal, other.ordinal, op)             # <<<<<<<<<<<<<<
 *         elif other is tslib.NaT:
 *             return _nat_scalar_rules[op]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_op); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 732, __pyx_L1_error)
    __pyx_t_3 = PyObject_RichCompareBool(__pyx_t_5, __pyx_t_1, __pyx_t_10); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":728
 * 
 *     def __richcmp__(self, other, op):
 *         if isinstance(other, Period):             # <<<<<<<<<<<<<<
 *             if other.freq != self.freq:
 *                 msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 */
  }

  /* "pandas/src/period.pyx":733
 *                 raise IncompatibleFrequency(msg)
 *             return PyObject_RichCompareBool(self.ordinal, other.ordinal, op)
 *         elif other is tslib.NaT:             # <<<<<<<<<<<<<<
 *             return _nat_scalar_rules[op]
 *         # index/series like
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 733, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_NaT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 733, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_v_other == __pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":734
 *             return PyObject_RichCompareBool(self.ordinal, other.ordinal, op)
 *         elif other is tslib.NaT:
 *             return _nat_scalar_rules[op]             # <<<<<<<<<<<<<<
 *         # index/series like
 *         elif hasattr(other, '_typ'):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_op); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 734, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_v_6pandas_5tslib__nat_scalar_rules[__pyx_t_8])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":733
 *                 raise IncompatibleFrequency(msg)
 *             return PyObject_RichCompareBool(self.ordinal, other.ordinal, op)
 *         elif other is tslib.NaT:             # <<<<<<<<<<<<<<
 *             return _nat_scalar_rules[op]
 *         # index/series like
 */
  }

  /* "pandas/src/period.pyx":736
 *             return _nat_scalar_rules[op]
 *         # index/series like
 *         elif hasattr(other, '_typ'):             # <<<<<<<<<<<<<<
 *             return NotImplemented
 *         else:
 */
  __pyx_t_2 = PyObject_HasAttr(__pyx_v_other, __pyx_n_s_typ); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 736, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pandas/src/period.pyx":737
 *         # index/series like
 *         elif hasattr(other, '_typ'):
 *             return NotImplemented             # <<<<<<<<<<<<<<
 *         else:
 *             if op == Py_EQ:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":736
 *             return _nat_scalar_rules[op]
 *         # index/series like
 *         elif hasattr(other, '_typ'):             # <<<<<<<<<<<<<<
 *             return NotImplemented
 *         else:
 */
  }

  /* "pandas/src/period.pyx":739
 *             return NotImplemented
 *         else:
 *             if op == Py_EQ:             # <<<<<<<<<<<<<<
 *                 return NotImplemented
 *             elif op == Py_NE:
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyInt_From_int(Py_EQ); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_op, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":740
 *         else:
 *             if op == Py_EQ:
 *                 return NotImplemented             # <<<<<<<<<<<<<<
 *             elif op == Py_NE:
 *                 return NotImplemented
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_builtin_NotImplemented);
      __pyx_r = __pyx_builtin_NotImplemented;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":739
 *             return NotImplemented
 *         else:
 *             if op == Py_EQ:             # <<<<<<<<<<<<<<
 *                 return NotImplemented
 *             elif op == Py_NE:
 */
    }

    /* "pandas/src/period.pyx":741
 *             if op == Py_EQ:
 *                 return NotImplemented
 *             elif op == Py_NE:             # <<<<<<<<<<<<<<
 *                 return NotImplemented
 *             raise TypeError('Cannot compare type %r with type %r' %
 */
    __pyx_t_1 = __Pyx_PyInt_From_int(Py_NE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_op, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":742
 *                 return NotImplemented
 *             elif op == Py_NE:
 *                 return NotImplemented             # <<<<<<<<<<<<<<
 *             raise TypeError('Cannot compare type %r with type %r' %
 *                             (type(self).__name__, type(other).__name__))
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_builtin_NotImplemented);
      __pyx_r = __pyx_builtin_NotImplemented;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":741
 *             if op == Py_EQ:
 *                 return NotImplemented
 *             elif op == Py_NE:             # <<<<<<<<<<<<<<
 *                 return NotImplemented
 *             raise TypeError('Cannot compare type %r with type %r' %
 */
    }

    /* "pandas/src/period.pyx":744
 *                 return NotImplemented
 *             raise TypeError('Cannot compare type %r with type %r' %
 *                             (type(self).__name__, type(other).__name__))             # <<<<<<<<<<<<<<
 * 
 *     def __hash__(self):
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_self)), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_other)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 744, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":743
 *             elif op == Py_NE:
 *                 return NotImplemented
 *             raise TypeError('Cannot compare type %r with type %r' %             # <<<<<<<<<<<<<<
 *                             (type(self).__name__, type(other).__name__))
 * 
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_compare_type_r_with_type, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 743, __pyx_L1_error)
  }

  /* "pandas/src/period.pyx":727
 *             return self
 * 
 *     def __richcmp__(self, other, op):             # <<<<<<<<<<<<<<
 *         if isinstance(other, Period):
 *             if other.freq != self.freq:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pandas._period._Period.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":746
 *                             (type(self).__name__, type(other).__name__))
 * 
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         return hash((self.ordinal, self.freqstr))
 * 
 */

/* Python wrapper */
static Py_hash_t __pyx_pw_6pandas_7_period_7_Period_7__hash__(PyObject *__pyx_v_self); /*proto*/
static Py_hash_t __pyx_pw_6pandas_7_period_7_Period_7__hash__(PyObject *__pyx_v_self) {
  Py_hash_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hash__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_6__hash__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_hash_t __pyx_pf_6pandas_7_period_7_Period_6__hash__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  Py_hash_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_hash_t __pyx_t_4;
  __Pyx_RefNannySetupContext("__hash__", 0);

  /* "pandas/src/period.pyx":747
 * 
 *     def __hash__(self):
 *         return hash((self.ordinal, self.freqstr))             # <<<<<<<<<<<<<<
 * 
 *     def _add_delta(self, other):
 */
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_freqstr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_4 = PyObject_Hash(__pyx_t_3); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":746
 *                             (type(self).__name__, type(other).__name__))
 * 
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         return hash((self.ordinal, self.freqstr))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pandas._period._Period.__hash__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  if (unlikely(__pyx_r == -1) && !PyErr_Occurred()) __pyx_r = -2;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":749
 *         return hash((self.ordinal, self.freqstr))
 * 
 *     def _add_delta(self, other):             # <<<<<<<<<<<<<<
 *         if isinstance(other, (timedelta, np.timedelta64,
 *                               offsets.Tick, Timedelta)):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_9_add_delta(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_9_add_delta(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_add_delta (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_8_add_delta(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_8_add_delta(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_offset = NULL;
  PyObject *__pyx_v_nanos = NULL;
  PyObject *__pyx_v_offset_nanos = NULL;
  PyObject *__pyx_v_ordinal = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_v_freqstr = NULL;
  PyObject *__pyx_v_base = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  __Pyx_RefNannySetupContext("_add_delta", 0);

  /* "pandas/src/period.pyx":750
 * 
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timedelta64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":751
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,
 *                               offsets.Tick, Timedelta)):             # <<<<<<<<<<<<<<
 *             offset = frequencies.to_offset(self.freq.rule_code)
 *             if isinstance(offset, offsets.Tick):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_offsets); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Tick); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timedelta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "pandas/src/period.pyx":750
 * 
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)
 */
  __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_8datetime_timedelta); 
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = PyObject_IsInstance(__pyx_v_other, __pyx_t_2); 
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pandas/src/period.pyx":751
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,
 *                               offsets.Tick, Timedelta)):             # <<<<<<<<<<<<<<
 *             offset = frequencies.to_offset(self.freq.rule_code)
 *             if isinstance(offset, offsets.Tick):
 */
  __pyx_t_5 = PyObject_IsInstance(__pyx_v_other, __pyx_t_3); 
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pandas/src/period.pyx":750
 * 
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)
 */
  __pyx_t_6 = PyObject_IsInstance(__pyx_v_other, __pyx_t_1); 

  /* "pandas/src/period.pyx":751
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,
 *                               offsets.Tick, Timedelta)):             # <<<<<<<<<<<<<<
 *             offset = frequencies.to_offset(self.freq.rule_code)
 *             if isinstance(offset, offsets.Tick):
 */
  __pyx_t_5 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pandas/src/period.pyx":750
 * 
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)
 */
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pandas/src/period.pyx":752
 *         if isinstance(other, (timedelta, np.timedelta64,
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)             # <<<<<<<<<<<<<<
 *             if isinstance(offset, offsets.Tick):
 *                 nanos = tslib._delta_to_nanoseconds(other)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_to_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->freq, __pyx_n_s_rule_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 752, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_offset = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pandas/src/period.pyx":753
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)
 *             if isinstance(offset, offsets.Tick):             # <<<<<<<<<<<<<<
 *                 nanos = tslib._delta_to_nanoseconds(other)
 *                 offset_nanos = tslib._delta_to_nanoseconds(offset)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_offsets); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 753, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Tick); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 753, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = PyObject_IsInstance(__pyx_v_offset, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 753, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = (__pyx_t_5 != 0);
    if (__pyx_t_4) {

      /* "pandas/src/period.pyx":754
 *             offset = frequencies.to_offset(self.freq.rule_code)
 *             if isinstance(offset, offsets.Tick):
 *                 nanos = tslib._delta_to_nanoseconds(other)             # <<<<<<<<<<<<<<
 *                 offset_nanos = tslib._delta_to_nanoseconds(offset)
 * 
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_delta_to_nanoseconds); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_other); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 754, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_INCREF(__pyx_v_other);
        __Pyx_GIVEREF(__pyx_v_other);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_other);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_nanos = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "pandas/src/period.pyx":755
 *             if isinstance(offset, offsets.Tick):
 *                 nanos = tslib._delta_to_nanoseconds(other)
 *                 offset_nanos = tslib._delta_to_nanoseconds(offset)             # <<<<<<<<<<<<<<
 * 
 *                 if nanos % offset_nanos == 0:
 */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 755, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_delta_to_nanoseconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 755, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_INCREF(__pyx_v_offset);
        __Pyx_GIVEREF(__pyx_v_offset);
        PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_offset);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_offset_nanos = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "pandas/src/period.pyx":757
 *                 offset_nanos = tslib._delta_to_nanoseconds(offset)
 * 
 *                 if nanos % offset_nanos == 0:             # <<<<<<<<<<<<<<
 *                     ordinal = self.ordinal + (nanos // offset_nanos)
 *                     return Period(ordinal=ordinal, freq=self.freq)
 */
      __pyx_t_1 = PyNumber_Remainder(__pyx_v_nanos, __pyx_v_offset_nanos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 757, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_4) {

        /* "pandas/src/period.pyx":758
 * 
 *                 if nanos % offset_nanos == 0:
 *                     ordinal = self.ordinal + (nanos // offset_nanos)             # <<<<<<<<<<<<<<
 *                     return Period(ordinal=ordinal, freq=self.freq)
 *             msg = 'Input cannot be converted to Period(freq={0})'
 */
        __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PyNumber_FloorDivide(__pyx_v_nanos, __pyx_v_offset_nanos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 758, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 758, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_ordinal = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "pandas/src/period.pyx":759
 *                 if nanos % offset_nanos == 0:
 *                     ordinal = self.ordinal + (nanos // offset_nanos)
 *                     return Period(ordinal=ordinal, freq=self.freq)             # <<<<<<<<<<<<<<
 *             msg = 'Input cannot be converted to Period(freq={0})'
 *             raise IncompatibleFrequency(msg.format(self.freqstr))
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ordinal, __pyx_v_ordinal) < 0) __PYX_ERR(0, 759, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_freq, __pyx_v_self->freq) < 0) __PYX_ERR(0, 759, __pyx_L1_error)
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_r = __pyx_t_3;
        __pyx_t_3 = 0;
        goto __pyx_L0;

        /* "pandas/src/period.pyx":757
 *                 offset_nanos = tslib._delta_to_nanoseconds(offset)
 * 
 *                 if nanos % offset_nanos == 0:             # <<<<<<<<<<<<<<
 *                     ordinal = self.ordinal + (nanos // offset_nanos)
 *                     return Period(ordinal=ordinal, freq=self.freq)
 */
      }

      /* "pandas/src/period.pyx":753
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)
 *             if isinstance(offset, offsets.Tick):             # <<<<<<<<<<<<<<
 *                 nanos = tslib._delta_to_nanoseconds(other)
 *                 offset_nanos = tslib._delta_to_nanoseconds(offset)
 */
    }

    /* "pandas/src/period.pyx":760
 *                     ordinal = self.ordinal + (nanos // offset_nanos)
 *                     return Period(ordinal=ordinal, freq=self.freq)
 *             msg = 'Input cannot be converted to Period(freq={0})'             # <<<<<<<<<<<<<<
 *             raise IncompatibleFrequency(msg.format(self.freqstr))
 *         elif isinstance(other, offsets.DateOffset):
 */
    __Pyx_INCREF(__pyx_kp_s_Input_cannot_be_converted_to_Per);
    __pyx_v_msg = __pyx_kp_s_Input_cannot_be_converted_to_Per;

    /* "pandas/src/period.pyx":761
 *                     return Period(ordinal=ordinal, freq=self.freq)
 *             msg = 'Input cannot be converted to Period(freq={0})'
 *             raise IncompatibleFrequency(msg.format(self.freqstr))             # <<<<<<<<<<<<<<
 *         elif isinstance(other, offsets.DateOffset):
 *             freqstr = other.rule_code
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_IncompatibleFrequency); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_freqstr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 761, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 761, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 761, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 761, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 761, __pyx_L1_error)

    /* "pandas/src/period.pyx":750
 * 
 *     def _add_delta(self, other):
 *         if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                               offsets.Tick, Timedelta)):
 *             offset = frequencies.to_offset(self.freq.rule_code)
 */
  }

  /* "pandas/src/period.pyx":762
 *             msg = 'Input cannot be converted to Period(freq={0})'
 *             raise IncompatibleFrequency(msg.format(self.freqstr))
 *         elif isinstance(other, offsets.DateOffset):             # <<<<<<<<<<<<<<
 *             freqstr = other.rule_code
 *             base = frequencies.get_base_alias(freqstr)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_offsets); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DateOffset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = PyObject_IsInstance(__pyx_v_other, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pandas/src/period.pyx":763
 *             raise IncompatibleFrequency(msg.format(self.freqstr))
 *         elif isinstance(other, offsets.DateOffset):
 *             freqstr = other.rule_code             # <<<<<<<<<<<<<<
 *             base = frequencies.get_base_alias(freqstr)
 *             if base == self.freq.rule_code:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_rule_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_freqstr = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":764
 *         elif isinstance(other, offsets.DateOffset):
 *             freqstr = other.rule_code
 *             base = frequencies.get_base_alias(freqstr)             # <<<<<<<<<<<<<<
 *             if base == self.freq.rule_code:
 *                 ordinal = self.ordinal + other.n
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_base_alias); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_freqstr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_freqstr);
      __Pyx_GIVEREF(__pyx_v_freqstr);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_freqstr);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_v_base = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":765
 *             freqstr = other.rule_code
 *             base = frequencies.get_base_alias(freqstr)
 *             if base == self.freq.rule_code:             # <<<<<<<<<<<<<<
 *                 ordinal = self.ordinal + other.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->freq, __pyx_n_s_rule_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = PyObject_RichCompare(__pyx_v_base, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_5) {

      /* "pandas/src/period.pyx":766
 *             base = frequencies.get_base_alias(freqstr)
 *             if base == self.freq.rule_code:
 *                 ordinal = self.ordinal + other.n             # <<<<<<<<<<<<<<
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 */
      __pyx_t_10 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Add(__pyx_t_10, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_ordinal = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "pandas/src/period.pyx":767
 *             if base == self.freq.rule_code:
 *                 ordinal = self.ordinal + other.n
 *                 return Period(ordinal=ordinal, freq=self.freq)             # <<<<<<<<<<<<<<
 *             msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *             raise IncompatibleFrequency(msg)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ordinal, __pyx_v_ordinal) < 0) __PYX_ERR(0, 767, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_freq, __pyx_v_self->freq) < 0) __PYX_ERR(0, 767, __pyx_L1_error)
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_10;
      __pyx_t_10 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":765
 *             freqstr = other.rule_code
 *             base = frequencies.get_base_alias(freqstr)
 *             if base == self.freq.rule_code:             # <<<<<<<<<<<<<<
 *                 ordinal = self.ordinal + other.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 */
    }

    /* "pandas/src/period.pyx":768
 *                 ordinal = self.ordinal + other.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)             # <<<<<<<<<<<<<<
 *             raise IncompatibleFrequency(msg)
 *         else: # pragma no cover
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DIFFERENT_FREQ); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_freqstr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_11 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_msg = __pyx_t_10;
    __pyx_t_10 = 0;

    /* "pandas/src/period.pyx":769
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *             raise IncompatibleFrequency(msg)             # <<<<<<<<<<<<<<
 *         else: # pragma no cover
 *             return NotImplemented
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_IncompatibleFrequency); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 769, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_msg); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_msg);
      __Pyx_GIVEREF(__pyx_v_msg);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_msg);
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_10, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __PYX_ERR(0, 769, __pyx_L1_error)

    /* "pandas/src/period.pyx":762
 *             msg = 'Input cannot be converted to Period(freq={0})'
 *             raise IncompatibleFrequency(msg.format(self.freqstr))
 *         elif isinstance(other, offsets.DateOffset):             # <<<<<<<<<<<<<<
 *             freqstr = other.rule_code
 *             base = frequencies.get_base_alias(freqstr)
 */
  }

  /* "pandas/src/period.pyx":771
 *             raise IncompatibleFrequency(msg)
 *         else: # pragma no cover
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *     def __add__(self, other):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;
  }

  /* "pandas/src/period.pyx":749
 *         return hash((self.ordinal, self.freqstr))
 * 
 *     def _add_delta(self, other):             # <<<<<<<<<<<<<<
 *         if isinstance(other, (timedelta, np.timedelta64,
 *                               offsets.Tick, Timedelta)):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pandas._period._Period._add_delta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_offset);
  __Pyx_XDECREF(__pyx_v_nanos);
  __Pyx_XDECREF(__pyx_v_offset_nanos);
  __Pyx_XDECREF(__pyx_v_ordinal);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_freqstr);
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":773
 *             return NotImplemented
 * 
 *     def __add__(self, other):             # <<<<<<<<<<<<<<
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_11__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_11__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_10__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_10__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_ordinal = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "pandas/src/period.pyx":774
 * 
 *     def __add__(self, other):
 *         if isinstance(self, Period):             # <<<<<<<<<<<<<<
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_self, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pandas/src/period.pyx":775
 *     def __add__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 775, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timedelta64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 775, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":776
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,             # <<<<<<<<<<<<<<
 *                                   Timedelta)):
 *                 return self._add_delta(other)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_offsets); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Tick); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_offsets); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DateOffset); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":777
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):             # <<<<<<<<<<<<<<
 *                 return self._add_delta(other)
 *             elif other is tslib.NaT:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timedelta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "pandas/src/period.pyx":775
 *     def __add__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_8datetime_timedelta); 
    __pyx_t_7 = (__pyx_t_2 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_3 = __pyx_t_7;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_other, __pyx_t_4); 
    __pyx_t_2 = (__pyx_t_7 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }

    /* "pandas/src/period.pyx":776
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,             # <<<<<<<<<<<<<<
 *                                   Timedelta)):
 *                 return self._add_delta(other)
 */
    __pyx_t_2 = PyObject_IsInstance(__pyx_v_other, __pyx_t_5); 
    __pyx_t_7 = (__pyx_t_2 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_3 = __pyx_t_7;
      goto __pyx_L5_bool_binop_done;
    }

    /* "pandas/src/period.pyx":775
 *     def __add__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_other, __pyx_t_6); 

    /* "pandas/src/period.pyx":776
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,             # <<<<<<<<<<<<<<
 *                                   Timedelta)):
 *                 return self._add_delta(other)
 */
    __pyx_t_2 = (__pyx_t_7 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }

    /* "pandas/src/period.pyx":777
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):             # <<<<<<<<<<<<<<
 *                 return self._add_delta(other)
 *             elif other is tslib.NaT:
 */
    __pyx_t_2 = PyObject_IsInstance(__pyx_v_other, __pyx_t_1); 
    __pyx_t_7 = (__pyx_t_2 != 0);
    __pyx_t_3 = __pyx_t_7;
    __pyx_L5_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":775
 *     def __add__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_7 = (__pyx_t_3 != 0);
    if (__pyx_t_7) {

      /* "pandas/src/period.pyx":778
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 *                 return self._add_delta(other)             # <<<<<<<<<<<<<<
 *             elif other is tslib.NaT:
 *                 return tslib.NaT
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_add_delta); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 778, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_other); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 778, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 778, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_other);
        __Pyx_GIVEREF(__pyx_v_other);
        PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_other);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 778, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":775
 *     def __add__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    }

    /* "pandas/src/period.pyx":779
 *                                   Timedelta)):
 *                 return self._add_delta(other)
 *             elif other is tslib.NaT:             # <<<<<<<<<<<<<<
 *                 return tslib.NaT
 *             elif lib.is_integer(other):
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NaT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = (__pyx_v_other == __pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = (__pyx_t_7 != 0);
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":780
 *                 return self._add_delta(other)
 *             elif other is tslib.NaT:
 *                 return tslib.NaT             # <<<<<<<<<<<<<<
 *             elif lib.is_integer(other):
 *                 ordinal = self.ordinal + other * self.freq.n
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 780, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_NaT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 780, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":779
 *                                   Timedelta)):
 *                 return self._add_delta(other)
 *             elif other is tslib.NaT:             # <<<<<<<<<<<<<<
 *                 return tslib.NaT
 *             elif lib.is_integer(other):
 */
    }

    /* "pandas/src/period.pyx":781
 *             elif other is tslib.NaT:
 *                 return tslib.NaT
 *             elif lib.is_integer(other):             # <<<<<<<<<<<<<<
 *                 ordinal = self.ordinal + other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_lib); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_is_integer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_other); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_other);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 781, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":782
 *                 return tslib.NaT
 *             elif lib.is_integer(other):
 *                 ordinal = self.ordinal + other * self.freq.n             # <<<<<<<<<<<<<<
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             else:  # pragma: no cover
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_n); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Multiply(__pyx_v_other, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_ordinal = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":783
 *             elif lib.is_integer(other):
 *                 ordinal = self.ordinal + other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)             # <<<<<<<<<<<<<<
 *             else:  # pragma: no cover
 *                 return NotImplemented
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ordinal, __pyx_v_ordinal) < 0) __PYX_ERR(0, 783, __pyx_L1_error)
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_freq, __pyx_t_4) < 0) __PYX_ERR(0, 783, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 783, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":781
 *             elif other is tslib.NaT:
 *                 return tslib.NaT
 *             elif lib.is_integer(other):             # <<<<<<<<<<<<<<
 *                 ordinal = self.ordinal + other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 */
    }

    /* "pandas/src/period.pyx":785
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             else:  # pragma: no cover
 *                 return NotImplemented             # <<<<<<<<<<<<<<
 *         elif isinstance(other, Period):
 *             return other + self
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_builtin_NotImplemented);
      __pyx_r = __pyx_builtin_NotImplemented;
      goto __pyx_L0;
    }

    /* "pandas/src/period.pyx":774
 * 
 *     def __add__(self, other):
 *         if isinstance(self, Period):             # <<<<<<<<<<<<<<
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 */
  }

  /* "pandas/src/period.pyx":786
 *             else:  # pragma: no cover
 *                 return NotImplemented
 *         elif isinstance(other, Period):             # <<<<<<<<<<<<<<
 *             return other + self
 *         else:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_other, __pyx_t_4); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__pyx_t_3 != 0);
  if (__pyx_t_7) {

    /* "pandas/src/period.pyx":787
 *                 return NotImplemented
 *         elif isinstance(other, Period):
 *             return other + self             # <<<<<<<<<<<<<<
 *         else:
 *             return NotImplemented
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyNumber_Add(__pyx_v_other, __pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":786
 *             else:  # pragma: no cover
 *                 return NotImplemented
 *         elif isinstance(other, Period):             # <<<<<<<<<<<<<<
 *             return other + self
 *         else:
 */
  }

  /* "pandas/src/period.pyx":789
 *             return other + self
 *         else:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *     def __sub__(self, other):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;
  }

  /* "pandas/src/period.pyx":773
 *             return NotImplemented
 * 
 *     def __add__(self, other):             # <<<<<<<<<<<<<<
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pandas._period._Period.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ordinal);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":791
 *             return NotImplemented
 * 
 *     def __sub__(self, other):             # <<<<<<<<<<<<<<
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_13__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_13__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_12__sub__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_12__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_neg_other = NULL;
  PyObject *__pyx_v_ordinal = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "pandas/src/period.pyx":792
 * 
 *     def __sub__(self, other):
 *         if isinstance(self, Period):             # <<<<<<<<<<<<<<
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_self, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 792, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pandas/src/period.pyx":793
 *     def __sub__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 793, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timedelta64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 793, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":794
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,             # <<<<<<<<<<<<<<
 *                                   Timedelta)):
 *                 neg_other = -other
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_offsets); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Tick); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_offsets); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DateOffset); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":795
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):             # <<<<<<<<<<<<<<
 *                 neg_other = -other
 *                 return self + neg_other
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timedelta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "pandas/src/period.pyx":793
 *     def __sub__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_8datetime_timedelta); 
    __pyx_t_7 = (__pyx_t_2 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_3 = __pyx_t_7;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_other, __pyx_t_4); 
    __pyx_t_2 = (__pyx_t_7 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }

    /* "pandas/src/period.pyx":794
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,             # <<<<<<<<<<<<<<
 *                                   Timedelta)):
 *                 neg_other = -other
 */
    __pyx_t_2 = PyObject_IsInstance(__pyx_v_other, __pyx_t_5); 
    __pyx_t_7 = (__pyx_t_2 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_3 = __pyx_t_7;
      goto __pyx_L5_bool_binop_done;
    }

    /* "pandas/src/period.pyx":793
 *     def __sub__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_other, __pyx_t_6); 

    /* "pandas/src/period.pyx":794
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,             # <<<<<<<<<<<<<<
 *                                   Timedelta)):
 *                 neg_other = -other
 */
    __pyx_t_2 = (__pyx_t_7 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }

    /* "pandas/src/period.pyx":795
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):             # <<<<<<<<<<<<<<
 *                 neg_other = -other
 *                 return self + neg_other
 */
    __pyx_t_2 = PyObject_IsInstance(__pyx_v_other, __pyx_t_1); 
    __pyx_t_7 = (__pyx_t_2 != 0);
    __pyx_t_3 = __pyx_t_7;
    __pyx_L5_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":793
 *     def __sub__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    __pyx_t_7 = (__pyx_t_3 != 0);
    if (__pyx_t_7) {

      /* "pandas/src/period.pyx":796
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 *                 neg_other = -other             # <<<<<<<<<<<<<<
 *                 return self + neg_other
 *             elif lib.is_integer(other):
 */
      __pyx_t_4 = PyNumber_Negative(__pyx_v_other); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_neg_other = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "pandas/src/period.pyx":797
 *                                   Timedelta)):
 *                 neg_other = -other
 *                 return self + neg_other             # <<<<<<<<<<<<<<
 *             elif lib.is_integer(other):
 *                 ordinal = self.ordinal - other * self.freq.n
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = PyNumber_Add(__pyx_v_self, __pyx_v_neg_other); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 797, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":793
 *     def __sub__(self, other):
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,             # <<<<<<<<<<<<<<
 *                                   offsets.Tick, offsets.DateOffset,
 *                                   Timedelta)):
 */
    }

    /* "pandas/src/period.pyx":798
 *                 neg_other = -other
 *                 return self + neg_other
 *             elif lib.is_integer(other):             # <<<<<<<<<<<<<<
 *                 ordinal = self.ordinal - other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_lib); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_is_integer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_other); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 798, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 798, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_other);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 798, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_7) {

      /* "pandas/src/period.pyx":799
 *                 return self + neg_other
 *             elif lib.is_integer(other):
 *                 ordinal = self.ordinal - other * self.freq.n             # <<<<<<<<<<<<<<
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             elif isinstance(other, Period):
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freq); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Multiply(__pyx_v_other, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Subtract(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_ordinal = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "pandas/src/period.pyx":800
 *             elif lib.is_integer(other):
 *                 ordinal = self.ordinal - other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)             # <<<<<<<<<<<<<<
 *             elif isinstance(other, Period):
 *                 if other.freq != self.freq:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_ordinal, __pyx_v_ordinal) < 0) __PYX_ERR(0, 800, __pyx_L1_error)
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_freq, __pyx_t_4) < 0) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":798
 *                 neg_other = -other
 *                 return self + neg_other
 *             elif lib.is_integer(other):             # <<<<<<<<<<<<<<
 *                 ordinal = self.ordinal - other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 */
    }

    /* "pandas/src/period.pyx":801
 *                 ordinal = self.ordinal - other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             elif isinstance(other, Period):             # <<<<<<<<<<<<<<
 *                 if other.freq != self.freq:
 *                     msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_other, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 801, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = (__pyx_t_7 != 0);
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":802
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             elif isinstance(other, Period):
 *                 if other.freq != self.freq:             # <<<<<<<<<<<<<<
 *                     msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                     raise IncompatibleFrequency(msg)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freq); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_3) {

        /* "pandas/src/period.pyx":803
 *             elif isinstance(other, Period):
 *                 if other.freq != self.freq:
 *                     msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)             # <<<<<<<<<<<<<<
 *                     raise IncompatibleFrequency(msg)
 *                 return self.ordinal - other.ordinal
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DIFFERENT_FREQ); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 803, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 803, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 803, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 803, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = NULL;
        __pyx_t_9 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_9 = 1;
          }
        }
        __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 803, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
        __pyx_t_6 = 0;
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 803, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_msg = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "pandas/src/period.pyx":804
 *                 if other.freq != self.freq:
 *                     msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                     raise IncompatibleFrequency(msg)             # <<<<<<<<<<<<<<
 *                 return self.ordinal - other.ordinal
 *             elif getattr(other, '_typ', None) == 'periodindex':
 */
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_IncompatibleFrequency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 804, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        if (!__pyx_t_10) {
          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 804, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_msg);
          __Pyx_GIVEREF(__pyx_v_msg);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_msg);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 804, __pyx_L1_error)

        /* "pandas/src/period.pyx":802
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             elif isinstance(other, Period):
 *                 if other.freq != self.freq:             # <<<<<<<<<<<<<<
 *                     msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                     raise IncompatibleFrequency(msg)
 */
      }

      /* "pandas/src/period.pyx":805
 *                     msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 *                     raise IncompatibleFrequency(msg)
 *                 return self.ordinal - other.ordinal             # <<<<<<<<<<<<<<
 *             elif getattr(other, '_typ', None) == 'periodindex':
 *                 return -other.__sub__(self)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 805, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 805, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyNumber_Subtract(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 805, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":801
 *                 ordinal = self.ordinal - other * self.freq.n
 *                 return Period(ordinal=ordinal, freq=self.freq)
 *             elif isinstance(other, Period):             # <<<<<<<<<<<<<<
 *                 if other.freq != self.freq:
 *                     msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
 */
    }

    /* "pandas/src/period.pyx":806
 *                     raise IncompatibleFrequency(msg)
 *                 return self.ordinal - other.ordinal
 *             elif getattr(other, '_typ', None) == 'periodindex':             # <<<<<<<<<<<<<<
 *                 return -other.__sub__(self)
 *             else:  # pragma: no cover
 */
    __pyx_t_5 = __Pyx_GetAttr3(__pyx_v_other, __pyx_n_s_typ, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_periodindex, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 806, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":807
 *                 return self.ordinal - other.ordinal
 *             elif getattr(other, '_typ', None) == 'periodindex':
 *                 return -other.__sub__(self)             # <<<<<<<<<<<<<<
 *             else:  # pragma: no cover
 *                 return NotImplemented
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_sub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 807, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 807, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_INCREF(__pyx_v_self);
        __Pyx_GIVEREF(__pyx_v_self);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_self);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Negative(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 807, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":806
 *                     raise IncompatibleFrequency(msg)
 *                 return self.ordinal - other.ordinal
 *             elif getattr(other, '_typ', None) == 'periodindex':             # <<<<<<<<<<<<<<
 *                 return -other.__sub__(self)
 *             else:  # pragma: no cover
 */
    }

    /* "pandas/src/period.pyx":809
 *                 return -other.__sub__(self)
 *             else:  # pragma: no cover
 *                 return NotImplemented             # <<<<<<<<<<<<<<
 *         elif isinstance(other, Period):
 *             if self is tslib.NaT:
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_builtin_NotImplemented);
      __pyx_r = __pyx_builtin_NotImplemented;
      goto __pyx_L0;
    }

    /* "pandas/src/period.pyx":792
 * 
 *     def __sub__(self, other):
 *         if isinstance(self, Period):             # <<<<<<<<<<<<<<
 *             if isinstance(other, (timedelta, np.timedelta64,
 *                                   offsets.Tick, offsets.DateOffset,
 */
  }

  /* "pandas/src/period.pyx":810
 *             else:  # pragma: no cover
 *                 return NotImplemented
 *         elif isinstance(other, Period):             # <<<<<<<<<<<<<<
 *             if self is tslib.NaT:
 *                 return tslib.NaT
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_other, __pyx_t_4); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__pyx_t_3 != 0);
  if (__pyx_t_7) {

    /* "pandas/src/period.pyx":811
 *                 return NotImplemented
 *         elif isinstance(other, Period):
 *             if self is tslib.NaT:             # <<<<<<<<<<<<<<
 *                 return tslib.NaT
 *             return NotImplemented
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NaT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = (__pyx_v_self == __pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = (__pyx_t_7 != 0);
    if (__pyx_t_3) {

      /* "pandas/src/period.pyx":812
 *         elif isinstance(other, Period):
 *             if self is tslib.NaT:
 *                 return tslib.NaT             # <<<<<<<<<<<<<<
 *             return NotImplemented
 *         else:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 812, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_NaT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 812, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "pandas/src/period.pyx":811
 *                 return NotImplemented
 *         elif isinstance(other, Period):
 *             if self is tslib.NaT:             # <<<<<<<<<<<<<<
 *                 return tslib.NaT
 *             return NotImplemented
 */
    }

    /* "pandas/src/period.pyx":813
 *             if self is tslib.NaT:
 *                 return tslib.NaT
 *             return NotImplemented             # <<<<<<<<<<<<<<
 *         else:
 *             return NotImplemented
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "pandas/src/period.pyx":810
 *             else:  # pragma: no cover
 *                 return NotImplemented
 *         elif isinstance(other, Period):             # <<<<<<<<<<<<<<
 *             if self is tslib.NaT:
 *                 return tslib.NaT
 */
  }

  /* "pandas/src/period.pyx":815
 *             return NotImplemented
 *         else:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *     def asfreq(self, freq, how='E'):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;
  }

  /* "pandas/src/period.pyx":791
 *             return NotImplemented
 * 
 *     def __sub__(self, other):             # <<<<<<<<<<<<<<
 *         if isinstance(self, Period):
 *             if isinstance(other, (timedelta, np.timedelta64,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pandas._period._Period.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_neg_other);
  __Pyx_XDECREF(__pyx_v_ordinal);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":817
 *             return NotImplemented
 * 
 *     def asfreq(self, freq, how='E'):             # <<<<<<<<<<<<<<
 *         """
 *         Convert Period to desired frequency, either at the start or end of the
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_15asfreq(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6pandas_7_period_7_Period_14asfreq[] = "\n        Convert Period to desired frequency, either at the start or end of the\n        interval\n\n        Parameters\n        ----------\n        freq : string\n        how : {'E', 'S', 'end', 'start'}, default 'end'\n            Start or end of the timespan\n\n        Returns\n        -------\n        resampled : Period\n        ";
static PyObject *__pyx_pw_6pandas_7_period_7_Period_15asfreq(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_v_how = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("asfreq (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_freq,&__pyx_n_s_how,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_n_s_E);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_how);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "asfreq") < 0)) __PYX_ERR(0, 817, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_freq = values[0];
    __pyx_v_how = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("asfreq", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 817, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period._Period.asfreq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_14asfreq(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self), __pyx_v_freq, __pyx_v_how);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_14asfreq(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_freq, PyObject *__pyx_v_how) {
  PyObject *__pyx_v_base1 = NULL;
  PyObject *__pyx_v_mult1 = NULL;
  PyObject *__pyx_v_base2 = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult2 = NULL;
  PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_ordinal = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_t_6;
  __pyx_t_5numpy_int64_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("asfreq", 0);
  __Pyx_INCREF(__pyx_v_freq);
  __Pyx_INCREF(__pyx_v_how);

  /* "pandas/src/period.pyx":832
 *         resampled : Period
 *         """
 *         freq = self._maybe_convert_freq(freq)             # <<<<<<<<<<<<<<
 *         how = _validate_end_alias(how)
 *         base1, mult1 = frequencies.get_freq_code(self.freq)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_maybe_convert_freq); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":833
 *         """
 *         freq = self._maybe_convert_freq(freq)
 *         how = _validate_end_alias(how)             # <<<<<<<<<<<<<<
 *         base1, mult1 = frequencies.get_freq_code(self.freq)
 *         base2, mult2 = frequencies.get_freq_code(freq)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_validate_end_alias); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_how); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_how);
    __Pyx_GIVEREF(__pyx_v_how);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_how);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_how, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":834
 *         freq = self._maybe_convert_freq(freq)
 *         how = _validate_end_alias(how)
 *         base1, mult1 = frequencies.get_freq_code(self.freq)             # <<<<<<<<<<<<<<
 *         base2, mult2 = frequencies.get_freq_code(freq)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->freq);
    __Pyx_GIVEREF(__pyx_v_self->freq);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 834, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 834, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 834, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_base1 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mult1 = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":835
 *         how = _validate_end_alias(how)
 *         base1, mult1 = frequencies.get_freq_code(self.freq)
 *         base2, mult2 = frequencies.get_freq_code(freq)             # <<<<<<<<<<<<<<
 * 
 *         # mult1 can't be negative or 0
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 835, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 835, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 835, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_base2 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mult2 = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pandas/src/period.pyx":838
 * 
 *         # mult1 can't be negative or 0
 *         end = how == 'E'             # <<<<<<<<<<<<<<
 *         if end:
 *             ordinal = self.ordinal + mult1 - 1
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_how, __pyx_n_s_E, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 838, __pyx_L1_error)
  __pyx_v_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":839
 *         # mult1 can't be negative or 0
 *         end = how == 'E'
 *         if end:             # <<<<<<<<<<<<<<
 *             ordinal = self.ordinal + mult1 - 1
 *         else:
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_end); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 839, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "pandas/src/period.pyx":840
 *         end = how == 'E'
 *         if end:
 *             ordinal = self.ordinal + mult1 - 1             # <<<<<<<<<<<<<<
 *         else:
 *             ordinal = self.ordinal
 */
    __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_mult1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_ordinal = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "pandas/src/period.pyx":839
 *         # mult1 can't be negative or 0
 *         end = how == 'E'
 *         if end:             # <<<<<<<<<<<<<<
 *             ordinal = self.ordinal + mult1 - 1
 *         else:
 */
    goto __pyx_L7;
  }

  /* "pandas/src/period.pyx":842
 *             ordinal = self.ordinal + mult1 - 1
 *         else:
 *             ordinal = self.ordinal             # <<<<<<<<<<<<<<
 *         ordinal = period_asfreq(ordinal, base1, base2, end)
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_ordinal = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L7:;

  /* "pandas/src/period.pyx":843
 *         else:
 *             ordinal = self.ordinal
 *         ordinal = period_asfreq(ordinal, base1, base2, end)             # <<<<<<<<<<<<<<
 * 
 *         return Period(ordinal=ordinal, freq=freq)
 */
  __pyx_t_7 = __Pyx_PyInt_As_npy_int64(__pyx_v_ordinal); if (unlikely((__pyx_t_7 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 843, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_base1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 843, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_base2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 843, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_end); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 843, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_f_6pandas_7_period_period_asfreq(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_6, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_ordinal, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":845
 *         ordinal = period_asfreq(ordinal, base1, base2, end)
 * 
 *         return Period(ordinal=ordinal, freq=freq)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ordinal, __pyx_v_ordinal) < 0) __PYX_ERR(0, 845, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_freq, __pyx_v_freq) < 0) __PYX_ERR(0, 845, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":817
 *             return NotImplemented
 * 
 *     def asfreq(self, freq, how='E'):             # <<<<<<<<<<<<<<
 *         """
 *         Convert Period to desired frequency, either at the start or end of the
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pandas._period._Period.asfreq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_base1);
  __Pyx_XDECREF(__pyx_v_mult1);
  __Pyx_XDECREF(__pyx_v_base2);
  __Pyx_XDECREF(__pyx_v_mult2);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_ordinal);
  __Pyx_XDECREF(__pyx_v_freq);
  __Pyx_XDECREF(__pyx_v_how);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":848
 * 
 *     @property
 *     def start_time(self):             # <<<<<<<<<<<<<<
 *         return self.to_timestamp(how='S')
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_10start_time_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_10start_time_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_10start_time___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_10start_time___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":849
 *     @property
 *     def start_time(self):
 *         return self.to_timestamp(how='S')             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_how, __pyx_n_s_S) < 0) __PYX_ERR(0, 849, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":848
 * 
 *     @property
 *     def start_time(self):             # <<<<<<<<<<<<<<
 *         return self.to_timestamp(how='S')
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pandas._period._Period.start_time.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":852
 * 
 *     @property
 *     def end_time(self):             # <<<<<<<<<<<<<<
 *         # freq.n can't be negative or 0
 *         # ordinal = (self + self.freq.n).start_time.value - 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_8end_time_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_8end_time_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_8end_time___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_8end_time___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_v_ordinal = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":855
 *         # freq.n can't be negative or 0
 *         # ordinal = (self + self.freq.n).start_time.value - 1
 *         ordinal = (self + 1).start_time.value - 1             # <<<<<<<<<<<<<<
 *         return Timestamp(ordinal)
 * 
 */
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_self), __pyx_int_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_start_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ordinal = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pandas/src/period.pyx":856
 *         # ordinal = (self + self.freq.n).start_time.value - 1
 *         ordinal = (self + 1).start_time.value - 1
 *         return Timestamp(ordinal)             # <<<<<<<<<<<<<<
 * 
 *     def to_timestamp(self, freq=None, how='start', tz=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 856, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_ordinal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_ordinal);
    __Pyx_GIVEREF(__pyx_v_ordinal);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_ordinal);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":852
 * 
 *     @property
 *     def end_time(self):             # <<<<<<<<<<<<<<
 *         # freq.n can't be negative or 0
 *         # ordinal = (self + self.freq.n).start_time.value - 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pandas._period._Period.end_time.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ordinal);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":858
 *         return Timestamp(ordinal)
 * 
 *     def to_timestamp(self, freq=None, how='start', tz=None):             # <<<<<<<<<<<<<<
 *         """
 *         Return the Timestamp representation of the Period at the target
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_17to_timestamp(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6pandas_7_period_7_Period_16to_timestamp[] = "\n        Return the Timestamp representation of the Period at the target\n        frequency at the specified end (how) of the Period\n\n        Parameters\n        ----------\n        freq : string or DateOffset, default is 'D' if self.freq is week or\n               longer and 'S' otherwise\n            Target frequency\n        how: str, default 'S' (start)\n            'S', 'E'. Can be aliased as case insensitive\n            'Start', 'Finish', 'Begin', 'End'\n\n        Returns\n        -------\n        Timestamp\n        ";
static PyObject *__pyx_pw_6pandas_7_period_7_Period_17to_timestamp(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_v_how = 0;
  PyObject *__pyx_v_tz = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_timestamp (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_freq,&__pyx_n_s_how,&__pyx_n_s_tz,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)__pyx_n_s_start);
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_how);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tz);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "to_timestamp") < 0)) __PYX_ERR(0, 858, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_freq = values[0];
    __pyx_v_how = values[1];
    __pyx_v_tz = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("to_timestamp", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 858, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period._Period.to_timestamp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_16to_timestamp(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self), __pyx_v_freq, __pyx_v_how, __pyx_v_tz);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_16to_timestamp(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_freq, PyObject *__pyx_v_how, PyObject *__pyx_v_tz) {
  PyObject *__pyx_v_base = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult = NULL;
  PyObject *__pyx_v_val = NULL;
  __pyx_t_5numpy_int64_t __pyx_v_dt64;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  Py_ssize_t __pyx_t_8;
  __pyx_t_5numpy_int64_t __pyx_t_9;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("to_timestamp", 0);
  __Pyx_INCREF(__pyx_v_freq);
  __Pyx_INCREF(__pyx_v_how);

  /* "pandas/src/period.pyx":876
 *         Timestamp
 *         """
 *         if freq is not None:             # <<<<<<<<<<<<<<
 *             freq = self._maybe_convert_freq(freq)
 *         how = _validate_end_alias(how)
 */
  __pyx_t_1 = (__pyx_v_freq != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":877
 *         """
 *         if freq is not None:
 *             freq = self._maybe_convert_freq(freq)             # <<<<<<<<<<<<<<
 *         how = _validate_end_alias(how)
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_maybe_convert_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 877, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 877, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 877, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_freq);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 877, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":876
 *         Timestamp
 *         """
 *         if freq is not None:             # <<<<<<<<<<<<<<
 *             freq = self._maybe_convert_freq(freq)
 *         how = _validate_end_alias(how)
 */
  }

  /* "pandas/src/period.pyx":878
 *         if freq is not None:
 *             freq = self._maybe_convert_freq(freq)
 *         how = _validate_end_alias(how)             # <<<<<<<<<<<<<<
 * 
 *         if freq is None:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_validate_end_alias); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_how); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 878, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 878, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_how);
    __Pyx_GIVEREF(__pyx_v_how);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_how);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 878, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_how, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "pandas/src/period.pyx":880
 *         how = _validate_end_alias(how)
 * 
 *         if freq is None:             # <<<<<<<<<<<<<<
 *             base, mult = frequencies.get_freq_code(self.freq)
 *             freq = frequencies.get_to_timestamp_base(base)
 */
  __pyx_t_2 = (__pyx_v_freq == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":881
 * 
 *         if freq is None:
 *             base, mult = frequencies.get_freq_code(self.freq)             # <<<<<<<<<<<<<<
 *             freq = frequencies.get_to_timestamp_base(base)
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_self->freq);
      __Pyx_GIVEREF(__pyx_v_self->freq);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_self->freq);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 881, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_4), 2) < 0) __PYX_ERR(0, 881, __pyx_L1_error)
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 881, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __pyx_v_base = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_v_mult = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "pandas/src/period.pyx":882
 *         if freq is None:
 *             base, mult = frequencies.get_freq_code(self.freq)
 *             freq = frequencies.get_to_timestamp_base(base)             # <<<<<<<<<<<<<<
 * 
 *         base, mult = frequencies.get_freq_code(freq)
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_get_to_timestamp_base); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_base); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 882, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 882, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_base);
      __Pyx_GIVEREF(__pyx_v_base);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_base);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 882, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":880
 *         how = _validate_end_alias(how)
 * 
 *         if freq is None:             # <<<<<<<<<<<<<<
 *             base, mult = frequencies.get_freq_code(self.freq)
 *             freq = frequencies.get_to_timestamp_base(base)
 */
  }

  /* "pandas/src/period.pyx":884
 *             freq = frequencies.get_to_timestamp_base(base)
 * 
 *         base, mult = frequencies.get_freq_code(freq)             # <<<<<<<<<<<<<<
 *         val = self.asfreq(freq, how)
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 884, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_freq);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 884, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_6)) goto __pyx_L7_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_5), 2) < 0) __PYX_ERR(0, 884, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 884, __pyx_L1_error)
    __pyx_L8_unpacking_done:;
  }
  __Pyx_XDECREF_SET(__pyx_v_base, __pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_XDECREF_SET(__pyx_v_mult, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "pandas/src/period.pyx":885
 * 
 *         base, mult = frequencies.get_freq_code(freq)
 *         val = self.asfreq(freq, how)             # <<<<<<<<<<<<<<
 * 
 *         dt64 = period_ordinal_to_dt64(val.ordinal, base)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_asfreq); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_freq);
  __Pyx_GIVEREF(__pyx_v_freq);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_v_freq);
  __Pyx_INCREF(__pyx_v_how);
  __Pyx_GIVEREF(__pyx_v_how);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_v_how);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_val = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pandas/src/period.pyx":887
 *         val = self.asfreq(freq, how)
 * 
 *         dt64 = period_ordinal_to_dt64(val.ordinal, base)             # <<<<<<<<<<<<<<
 *         return Timestamp(dt64, tz=tz)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 887, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_PyInt_As_npy_int64(__pyx_t_3); if (unlikely((__pyx_t_9 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 887, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_base); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 887, __pyx_L1_error)
  __pyx_v_dt64 = __pyx_f_6pandas_7_period_period_ordinal_to_dt64(__pyx_t_9, __pyx_t_10, 0);

  /* "pandas/src/period.pyx":888
 * 
 *         dt64 = period_ordinal_to_dt64(val.ordinal, base)
 *         return Timestamp(dt64, tz=tz)             # <<<<<<<<<<<<<<
 * 
 *     cdef _field(self, alias):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timestamp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyInt_From_npy_int64(__pyx_v_dt64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_tz, __pyx_v_tz) < 0) __PYX_ERR(0, 888, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":858
 *         return Timestamp(ordinal)
 * 
 *     def to_timestamp(self, freq=None, how='start', tz=None):             # <<<<<<<<<<<<<<
 *         """
 *         Return the Timestamp representation of the Period at the target
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pandas._period._Period.to_timestamp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XDECREF(__pyx_v_freq);
  __Pyx_XDECREF(__pyx_v_how);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":890
 *         return Timestamp(dt64, tz=tz)
 * 
 *     cdef _field(self, alias):             # <<<<<<<<<<<<<<
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         return get_period_field(alias, self.ordinal, base)
 */

static PyObject *__pyx_f_6pandas_7_period_7_Period__field(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_alias) {
  PyObject *__pyx_v_base = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_field", 0);

  /* "pandas/src/period.pyx":891
 * 
 *     cdef _field(self, alias):
 *         base, mult = frequencies.get_freq_code(self.freq)             # <<<<<<<<<<<<<<
 *         return get_period_field(alias, self.ordinal, base)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->freq);
    __Pyx_GIVEREF(__pyx_v_self->freq);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 891, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 891, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 891, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_base = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mult = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":892
 *     cdef _field(self, alias):
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         return get_period_field(alias, self.ordinal, base)             # <<<<<<<<<<<<<<
 * 
 *     property year:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_period_field); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_2) {
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_v_alias);
  __Pyx_GIVEREF(__pyx_v_alias);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_alias);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_base);
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":890
 *         return Timestamp(dt64, tz=tz)
 * 
 *     cdef _field(self, alias):             # <<<<<<<<<<<<<<
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         return get_period_field(alias, self.ordinal, base)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pandas._period._Period._field", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":895
 * 
 *     property year:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(0)
 *     property month:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4year_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4year_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_4year___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_4year___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":896
 *     property year:
 *         def __get__(self):
 *             return self._field(0)             # <<<<<<<<<<<<<<
 *     property month:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":895
 * 
 *     property year:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(0)
 *     property month:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.year.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":898
 *             return self._field(0)
 *     property month:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(3)
 *     property day:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_5month_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_5month_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_5month___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_5month___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":899
 *     property month:
 *         def __get__(self):
 *             return self._field(3)             # <<<<<<<<<<<<<<
 *     property day:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":898
 *             return self._field(0)
 *     property month:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(3)
 *     property day:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.month.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":901
 *             return self._field(3)
 *     property day:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(4)
 *     property hour:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_3day_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_3day_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_3day___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_3day___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":902
 *     property day:
 *         def __get__(self):
 *             return self._field(4)             # <<<<<<<<<<<<<<
 *     property hour:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":901
 *             return self._field(3)
 *     property day:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(4)
 *     property hour:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.day.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":904
 *             return self._field(4)
 *     property hour:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(5)
 *     property minute:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4hour_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4hour_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_4hour___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_4hour___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":905
 *     property hour:
 *         def __get__(self):
 *             return self._field(5)             # <<<<<<<<<<<<<<
 *     property minute:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":904
 *             return self._field(4)
 *     property hour:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(5)
 *     property minute:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.hour.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":907
 *             return self._field(5)
 *     property minute:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(6)
 *     property second:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_6minute_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_6minute_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_6minute___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_6minute___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":908
 *     property minute:
 *         def __get__(self):
 *             return self._field(6)             # <<<<<<<<<<<<<<
 *     property second:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":907
 *             return self._field(5)
 *     property minute:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(6)
 *     property second:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.minute.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":910
 *             return self._field(6)
 *     property second:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(7)
 *     property weekofyear:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_6second_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_6second_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_6second___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_6second___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":911
 *     property second:
 *         def __get__(self):
 *             return self._field(7)             # <<<<<<<<<<<<<<
 *     property weekofyear:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":910
 *             return self._field(6)
 *     property second:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(7)
 *     property weekofyear:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.second.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":913
 *             return self._field(7)
 *     property weekofyear:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(8)
 *     property week:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_10weekofyear_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_10weekofyear_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_10weekofyear___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_10weekofyear___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":914
 *     property weekofyear:
 *         def __get__(self):
 *             return self._field(8)             # <<<<<<<<<<<<<<
 *     property week:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":913
 *             return self._field(7)
 *     property weekofyear:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(8)
 *     property week:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.weekofyear.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":916
 *             return self._field(8)
 *     property week:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.weekofyear
 *     property dayofweek:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4week_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4week_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_4week___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_4week___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":917
 *     property week:
 *         def __get__(self):
 *             return self.weekofyear             # <<<<<<<<<<<<<<
 *     property dayofweek:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_weekofyear); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 917, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":916
 *             return self._field(8)
 *     property week:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.weekofyear
 *     property dayofweek:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.week.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":919
 *             return self.weekofyear
 *     property dayofweek:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(10)
 *     property weekday:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_9dayofweek_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_9dayofweek_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_9dayofweek___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_9dayofweek___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":920
 *     property dayofweek:
 *         def __get__(self):
 *             return self._field(10)             # <<<<<<<<<<<<<<
 *     property weekday:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 920, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":919
 *             return self.weekofyear
 *     property dayofweek:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(10)
 *     property weekday:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.dayofweek.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":922
 *             return self._field(10)
 *     property weekday:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.dayofweek
 *     property dayofyear:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7weekday_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7weekday_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_7weekday___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_7weekday___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":923
 *     property weekday:
 *         def __get__(self):
 *             return self.dayofweek             # <<<<<<<<<<<<<<
 *     property dayofyear:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dayofweek); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":922
 *             return self._field(10)
 *     property weekday:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.dayofweek
 *     property dayofyear:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.weekday.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":925
 *             return self.dayofweek
 *     property dayofyear:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(9)
 *     property quarter:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_9dayofyear_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_9dayofyear_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_9dayofyear___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_9dayofyear___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":926
 *     property dayofyear:
 *         def __get__(self):
 *             return self._field(9)             # <<<<<<<<<<<<<<
 *     property quarter:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":925
 *             return self.dayofweek
 *     property dayofyear:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(9)
 *     property quarter:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.dayofyear.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":928
 *             return self._field(9)
 *     property quarter:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(2)
 *     property qyear:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7quarter_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7quarter_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_7quarter___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_7quarter___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":929
 *     property quarter:
 *         def __get__(self):
 *             return self._field(2)             # <<<<<<<<<<<<<<
 *     property qyear:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":928
 *             return self._field(9)
 *     property quarter:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(2)
 *     property qyear:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.quarter.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":931
 *             return self._field(2)
 *     property qyear:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(1)
 *     property days_in_month:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_5qyear_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_5qyear_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_5qyear___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_5qyear___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":932
 *     property qyear:
 *         def __get__(self):
 *             return self._field(1)             # <<<<<<<<<<<<<<
 *     property days_in_month:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":931
 *             return self._field(2)
 *     property qyear:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(1)
 *     property days_in_month:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.qyear.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":934
 *             return self._field(1)
 *     property days_in_month:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(11)
 *     property daysinmonth:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_13days_in_month_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_13days_in_month_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_13days_in_month___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_13days_in_month___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":935
 *     property days_in_month:
 *         def __get__(self):
 *             return self._field(11)             # <<<<<<<<<<<<<<
 *     property daysinmonth:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":934
 *             return self._field(1)
 *     property days_in_month:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._field(11)
 *     property daysinmonth:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.days_in_month.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":937
 *             return self._field(11)
 *     property daysinmonth:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.days_in_month
 *     property is_leap_year:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_11daysinmonth_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_11daysinmonth_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_11daysinmonth___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_11daysinmonth___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":938
 *     property daysinmonth:
 *         def __get__(self):
 *             return self.days_in_month             # <<<<<<<<<<<<<<
 *     property is_leap_year:
 *         def __get__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_days_in_month); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":937
 *             return self._field(11)
 *     property daysinmonth:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.days_in_month
 *     property is_leap_year:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.daysinmonth.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":940
 *             return self.days_in_month
 *     property is_leap_year:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return bool(is_leapyear(self._field(0)))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_12is_leap_year_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_12is_leap_year_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_12is_leap_year___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_12is_leap_year___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __pyx_t_5numpy_int64_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":941
 *     property is_leap_year:
 *         def __get__(self):
 *             return bool(is_leapyear(self._field(0)))             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6pandas_7_period__Period *)__pyx_v_self->__pyx_vtab)->_field(__pyx_v_self, __pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_npy_int64(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(is_leapyear(__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":940
 *             return self.days_in_month
 *     property is_leap_year:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return bool(is_leapyear(self._field(0)))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.is_leap_year.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":944
 * 
 *     @classmethod
 *     def now(cls, freq=None):             # <<<<<<<<<<<<<<
 *         return Period(datetime.now(), freq=freq)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_19now(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_19now(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("now (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_freq,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "now") < 0)) __PYX_ERR(0, 944, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_freq = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("now", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 944, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period._Period.now", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_18now(((PyTypeObject*)__pyx_v_cls), __pyx_v_freq);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_18now(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_freq) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("now", 0);

  /* "pandas/src/period.pyx":945
 *     @classmethod
 *     def now(cls, freq=None):
 *         return Period(datetime.now(), freq=freq)             # <<<<<<<<<<<<<<
 * 
 *     # HACK IT UP AND YOU BETTER FIX IT SOON
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_8datetime_datetime), __pyx_n_s_now); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 945, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 945, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_freq, __pyx_v_freq) < 0) __PYX_ERR(0, 945, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":944
 * 
 *     @classmethod
 *     def now(cls, freq=None):             # <<<<<<<<<<<<<<
 *         return Period(datetime.now(), freq=freq)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pandas._period._Period.now", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":948
 * 
 *     # HACK IT UP AND YOU BETTER FIX IT SOON
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self.__unicode__()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_21__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_21__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_20__str__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_20__str__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pandas/src/period.pyx":949
 *     # HACK IT UP AND YOU BETTER FIX IT SOON
 *     def __str__(self):
 *         return self.__unicode__()             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 949, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 949, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":948
 * 
 *     # HACK IT UP AND YOU BETTER FIX IT SOON
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self.__unicode__()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pandas._period._Period.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":952
 * 
 *     @property
 *     def freqstr(self):             # <<<<<<<<<<<<<<
 *         return self.freq.freqstr
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7freqstr_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7freqstr_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_7freqstr___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_7freqstr___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pandas/src/period.pyx":953
 *     @property
 *     def freqstr(self):
 *         return self.freq.freqstr             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->freq, __pyx_n_s_freqstr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":952
 * 
 *     @property
 *     def freqstr(self):             # <<<<<<<<<<<<<<
 *         return self.freq.freqstr
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.freqstr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":955
 *         return self.freq.freqstr
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         formatted = period_format(self.ordinal, base)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_23__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_23__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_22__repr__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_22__repr__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_v_base = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult = NULL;
  PyObject *__pyx_v_formatted = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "pandas/src/period.pyx":956
 * 
 *     def __repr__(self):
 *         base, mult = frequencies.get_freq_code(self.freq)             # <<<<<<<<<<<<<<
 *         formatted = period_format(self.ordinal, base)
 *         return "Period('%s', '%s')" % (formatted, self.freqstr)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 956, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 956, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->freq);
    __Pyx_GIVEREF(__pyx_v_self->freq);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 956, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 956, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 956, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 956, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_base = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mult = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":957
 *     def __repr__(self):
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         formatted = period_format(self.ordinal, base)             # <<<<<<<<<<<<<<
 *         return "Period('%s', '%s')" % (formatted, self.freqstr)
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_period_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_2) {
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_base);
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 957, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_formatted = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":958
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         formatted = period_format(self.ordinal, base)
 *         return "Period('%s', '%s')" % (formatted, self.freqstr)             # <<<<<<<<<<<<<<
 * 
 *     def __unicode__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_freqstr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_formatted);
  __Pyx_GIVEREF(__pyx_v_formatted);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_formatted);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Period_s_s, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":955
 *         return self.freq.freqstr
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         formatted = period_format(self.ordinal, base)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pandas._period._Period.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_XDECREF(__pyx_v_formatted);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":960
 *         return "Period('%s', '%s')" % (formatted, self.freqstr)
 * 
 *     def __unicode__(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return a string representation for a particular DataFrame
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_25__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6pandas_7_period_7_Period_24__unicode__[] = "\n        Return a string representation for a particular DataFrame\n\n        Invoked by unicode(df) in py2 only. Yields a Unicode String in both\n        py2/py3.\n        ";
static PyObject *__pyx_pw_6pandas_7_period_7_Period_25__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__unicode__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_24__unicode__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_24__unicode__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_v_base = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult = NULL;
  PyObject *__pyx_v_formatted = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("__unicode__", 0);

  /* "pandas/src/period.pyx":967
 *         py2/py3.
 *         """
 *         base, mult = frequencies.get_freq_code(self.freq)             # <<<<<<<<<<<<<<
 *         formatted = period_format(self.ordinal, base)
 *         value = ("%s" % formatted)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->freq);
    __Pyx_GIVEREF(__pyx_v_self->freq);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 967, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 967, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 967, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_base = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mult = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":968
 *         """
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         formatted = period_format(self.ordinal, base)             # <<<<<<<<<<<<<<
 *         value = ("%s" % formatted)
 *         return value
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_period_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 968, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 968, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 968, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_2) {
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_base);
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 968, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_formatted = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":969
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         formatted = period_format(self.ordinal, base)
 *         value = ("%s" % formatted)             # <<<<<<<<<<<<<<
 *         return value
 * 
 */
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_2, __pyx_v_formatted); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_value = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":970
 *         formatted = period_format(self.ordinal, base)
 *         value = ("%s" % formatted)
 *         return value             # <<<<<<<<<<<<<<
 * 
 *     def __setstate__(self, state):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_value);
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":960
 *         return "Period('%s', '%s')" % (formatted, self.freqstr)
 * 
 *     def __unicode__(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return a string representation for a particular DataFrame
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pandas._period._Period.__unicode__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_XDECREF(__pyx_v_formatted);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":972
 *         return value
 * 
 *     def __setstate__(self, state):             # <<<<<<<<<<<<<<
 *         self.freq=state[1]
 *         self.ordinal=state[2]
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_27__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_27__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_26__setstate__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_26__setstate__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __pyx_t_5numpy_int64_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "pandas/src/period.pyx":973
 * 
 *     def __setstate__(self, state):
 *         self.freq=state[1]             # <<<<<<<<<<<<<<
 *         self.ordinal=state[2]
 * 
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 973, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->freq);
  __Pyx_DECREF(__pyx_v_self->freq);
  __pyx_v_self->freq = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":974
 *     def __setstate__(self, state):
 *         self.freq=state[1]
 *         self.ordinal=state[2]             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 974, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_npy_int64(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 974, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->ordinal = __pyx_t_2;

  /* "pandas/src/period.pyx":972
 *         return value
 * 
 *     def __setstate__(self, state):             # <<<<<<<<<<<<<<
 *         self.freq=state[1]
 *         self.ordinal=state[2]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":976
 *         self.ordinal=state[2]
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         object_state = None, self.freq, self.ordinal
 *         return (Period, object_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_29__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_29__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_28__reduce__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_28__reduce__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_v_object_state = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "pandas/src/period.pyx":977
 * 
 *     def __reduce__(self):
 *         object_state = None, self.freq, self.ordinal             # <<<<<<<<<<<<<<
 *         return (Period, object_state)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None);
  __Pyx_INCREF(__pyx_v_self->freq);
  __Pyx_GIVEREF(__pyx_v_self->freq);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->freq);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_object_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pandas/src/period.pyx":978
 *     def __reduce__(self):
 *         object_state = None, self.freq, self.ordinal
 *         return (Period, object_state)             # <<<<<<<<<<<<<<
 * 
 *     def strftime(self, fmt):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_object_state);
  __Pyx_GIVEREF(__pyx_v_object_state);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_object_state);
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":976
 *         self.ordinal=state[2]
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         object_state = None, self.freq, self.ordinal
 *         return (Period, object_state)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pandas._period._Period.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_object_state);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":980
 *         return (Period, object_state)
 * 
 *     def strftime(self, fmt):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the string representation of the :class:`Period`, depending
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_31strftime(PyObject *__pyx_v_self, PyObject *__pyx_v_fmt); /*proto*/
static char __pyx_doc_6pandas_7_period_7_Period_30strftime[] = "\n        Returns the string representation of the :class:`Period`, depending\n        on the selected :keyword:`format`. :keyword:`format` must be a string\n        containing one or several directives.  The method recognizes the same\n        directives as the :func:`time.strftime` function of the standard Python\n        distribution, as well as the specific additional directives ``%f``,\n        ``%F``, ``%q``. (formatting & docs originally from scikits.timeries)\n\n        +-----------+--------------------------------+-------+\n        | Directive | Meaning                        | Notes |\n        +===========+================================+=======+\n        | ``%a``    | Locale's abbreviated weekday   |       |\n        |           | name.                          |       |\n        +-----------+--------------------------------+-------+\n        | ``%A``    | Locale's full weekday name.    |       |\n        +-----------+--------------------------------+-------+\n        | ``%b``    | Locale's abbreviated month     |       |\n        |           | name.                          |       |\n        +-----------+--------------------------------+-------+\n        | ``%B``    | Locale's full month name.      |       |\n        +-----------+--------------------------------+-------+\n        | ``%c``    | Locale's appropriate date and  |       |\n        |           | time representation.           |       |\n        +-----------+--------------------------------+-------+\n        | ``%d``    | Day of the month as a decimal  |       |\n        |           | number [01,31].                |       |\n        +-----------+--------------------------------+-------+\n        | ``%f``    | 'Fiscal' year without a        | \\(1)  |\n        |           | century  as a decimal number   |       |\n        |           | [00,99]                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%F``    | 'Fiscal' year with a century  "" | \\(2)  |\n        |           | as a decimal number            |       |\n        +-----------+--------------------------------+-------+\n        | ``%H``    | Hour (24-hour clock) as a      |       |\n        |           | decimal number [00,23].        |       |\n        +-----------+--------------------------------+-------+\n        | ``%I``    | Hour (12-hour clock) as a      |       |\n        |           | decimal number [01,12].        |       |\n        +-----------+--------------------------------+-------+\n        | ``%j``    | Day of the year as a decimal   |       |\n        |           | number [001,366].              |       |\n        +-----------+--------------------------------+-------+\n        | ``%m``    | Month as a decimal number      |       |\n        |           | [01,12].                       |       |\n        +-----------+--------------------------------+-------+\n        | ``%M``    | Minute as a decimal number     |       |\n        |           | [00,59].                       |       |\n        +-----------+--------------------------------+-------+\n        | ``%p``    | Locale's equivalent of either  | \\(3)  |\n        |           | AM or PM.                      |       |\n        +-----------+--------------------------------+-------+\n        | ``%q``    | Quarter as a decimal number    |       |\n        |           | [01,04]                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%S``    | Second as a decimal number     | \\(4)  |\n        |           | [00,61].                       |       |\n        +-----------+--------------------------------+-------+\n        | ``%U``    | Week number of the year        | \\(5)  |\n        |           | (Sunday as the first day of    |       |\n        |           | the week) as a decimal number  |       |\n        |           | [00,53].  All days in a new    |       |\n        |           | year preceding the first       |       |""\n        |           | Sunday are considered to be in |       |\n        |           | week 0.                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%w``    | Weekday as a decimal number    |       |\n        |           | [0(Sunday),6].                 |       |\n        +-----------+--------------------------------+-------+\n        | ``%W``    | Week number of the year        | \\(5)  |\n        |           | (Monday as the first day of    |       |\n        |           | the week) as a decimal number  |       |\n        |           | [00,53].  All days in a new    |       |\n        |           | year preceding the first       |       |\n        |           | Monday are considered to be in |       |\n        |           | week 0.                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%x``    | Locale's appropriate date      |       |\n        |           | representation.                |       |\n        +-----------+--------------------------------+-------+\n        | ``%X``    | Locale's appropriate time      |       |\n        |           | representation.                |       |\n        +-----------+--------------------------------+-------+\n        | ``%y``    | Year without century as a      |       |\n        |           | decimal number [00,99].        |       |\n        +-----------+--------------------------------+-------+\n        | ``%Y``    | Year with century as a decimal |       |\n        |           | number.                        |       |\n        +-----------+--------------------------------+-------+\n        | ``%Z``    | Time zone name (no characters  |       |\n        |           | if no time zone exists).       |       |\n        +-----------+--------------------------------+-------+\n        | ``%%``    | A literal ``'%'`` character.   |       |\n        +-----------+--------------------------------+-------+\n\n        .. ""note::\n\n            (1)\n                The ``%f`` directive is the same as ``%y`` if the frequency is\n                not quarterly.\n                Otherwise, it corresponds to the 'fiscal' year, as defined by\n                the :attr:`qyear` attribute.\n\n            (2)\n                The ``%F`` directive is the same as ``%Y`` if the frequency is\n                not quarterly.\n                Otherwise, it corresponds to the 'fiscal' year, as defined by\n                the :attr:`qyear` attribute.\n\n            (3)\n                The ``%p`` directive only affects the output hour field\n                if the ``%I`` directive is used to parse the hour.\n\n            (4)\n                The range really is ``0`` to ``61``; this accounts for leap\n                seconds and the (very rare) double leap seconds.\n\n            (5)\n                The ``%U`` and ``%W`` directives are only used in calculations\n                when the day of the week and the year are specified.\n\n        .. rubric::  Examples\n\n            >>> a = Period(freq='Q@JUL', year=2006, quarter=1)\n            >>> a.strftime('%F-Q%q')\n            '2006-Q1'\n            >>> # Output the last month in the quarter of this date\n            >>> a.strftime('%b-%Y')\n            'Oct-2005'\n            >>>\n            >>> a = Period(freq='D', year=2001, month=1, day=1)\n            >>> a.strftime('%d-%b-%Y')\n            '01-Jan-2006'\n            >>> a.strftime('%b. %d, %Y was a %A')\n            'Jan. 01, 2001 was a Monday'\n        ";
static PyObject *__pyx_pw_6pandas_7_period_7_Period_31strftime(PyObject *__pyx_v_self, PyObject *__pyx_v_fmt) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("strftime (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_30strftime(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self), ((PyObject *)__pyx_v_fmt));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_30strftime(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_fmt) {
  PyObject *__pyx_v_base = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("strftime", 0);

  /* "pandas/src/period.pyx":1117
 *             'Jan. 01, 2001 was a Monday'
 *         """
 *         base, mult = frequencies.get_freq_code(self.freq)             # <<<<<<<<<<<<<<
 *         return period_format(self.ordinal, base, fmt)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->freq);
    __Pyx_GIVEREF(__pyx_v_self->freq);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1117, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 1117, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1117, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_base = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mult = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":1118
 *         """
 *         base, mult = frequencies.get_freq_code(self.freq)
 *         return period_format(self.ordinal, base, fmt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_period_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_2) {
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_base);
  __Pyx_INCREF(__pyx_v_fmt);
  __Pyx_GIVEREF(__pyx_v_fmt);
  PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_fmt);
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":980
 *         return (Period, object_state)
 * 
 *     def strftime(self, fmt):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the string representation of the :class:`Period`, depending
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pandas._period._Period.strftime", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":693
 * 
 *     cdef public:
 *         int64_t ordinal             # <<<<<<<<<<<<<<
 *         object freq
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7ordinal_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_7ordinal_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_7ordinal___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_7ordinal___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->ordinal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pandas._period._Period.ordinal.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6pandas_7_period_7_Period_7ordinal_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6pandas_7_period_7_Period_7ordinal_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_7ordinal_2__set__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6pandas_7_period_7_Period_7ordinal_2__set__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_5numpy_int64_t __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_npy_int64(__pyx_v_value); if (unlikely((__pyx_t_1 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(0, 693, __pyx_L1_error)
  __pyx_v_self->ordinal = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pandas._period._Period.ordinal.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":694
 *     cdef public:
 *         int64_t ordinal
 *         object freq             # <<<<<<<<<<<<<<
 * 
 *     _comparables = ['name', 'freqstr']
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4freq_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6pandas_7_period_7_Period_4freq_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_4freq___get__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_7_Period_4freq___get__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->freq);
  __pyx_r = __pyx_v_self->freq;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6pandas_7_period_7_Period_4freq_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_6pandas_7_period_7_Period_4freq_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_4freq_2__set__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6pandas_7_period_7_Period_4freq_2__set__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->freq);
  __Pyx_DECREF(__pyx_v_self->freq);
  __pyx_v_self->freq = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6pandas_7_period_7_Period_4freq_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_6pandas_7_period_7_Period_4freq_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_7_Period_4freq_4__del__(((struct __pyx_obj_6pandas_7_period__Period *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6pandas_7_period_7_Period_4freq_4__del__(struct __pyx_obj_6pandas_7_period__Period *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->freq);
  __Pyx_DECREF(__pyx_v_self->freq);
  __pyx_v_self->freq = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":1140
 *     """
 * 
 *     def __new__(cls, value=None, freq=None, ordinal=None,             # <<<<<<<<<<<<<<
 *                 year=None, month=None, quarter=None, day=None,
 *                 hour=None, minute=None, second=None):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_6Period_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_6Period_1__new__ = {"__new__", (PyCFunction)__pyx_pw_6pandas_7_period_6Period_1__new__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_6Period_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_v_ordinal = 0;
  PyObject *__pyx_v_year = 0;
  PyObject *__pyx_v_month = 0;
  PyObject *__pyx_v_quarter = 0;
  PyObject *__pyx_v_day = 0;
  PyObject *__pyx_v_hour = 0;
  PyObject *__pyx_v_minute = 0;
  PyObject *__pyx_v_second = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_value,&__pyx_n_s_freq,&__pyx_n_s_ordinal,&__pyx_n_s_year,&__pyx_n_s_month,&__pyx_n_s_quarter,&__pyx_n_s_day,&__pyx_n_s_hour,&__pyx_n_s_minute,&__pyx_n_s_second,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    values[1] = ((PyObject *)((PyObject *)Py_None));
    values[2] = ((PyObject *)((PyObject *)Py_None));
    values[3] = ((PyObject *)((PyObject *)Py_None));

    /* "pandas/src/period.pyx":1141
 * 
 *     def __new__(cls, value=None, freq=None, ordinal=None,
 *                 year=None, month=None, quarter=None, day=None,             # <<<<<<<<<<<<<<
 *                 hour=None, minute=None, second=None):
 *         # freq points to a tuple (base, mult);  base is one of the defined
 */
    values[4] = ((PyObject *)((PyObject *)Py_None));
    values[5] = ((PyObject *)((PyObject *)Py_None));
    values[6] = ((PyObject *)((PyObject *)Py_None));
    values[7] = ((PyObject *)((PyObject *)Py_None));

    /* "pandas/src/period.pyx":1142
 *     def __new__(cls, value=None, freq=None, ordinal=None,
 *                 year=None, month=None, quarter=None, day=None,
 *                 hour=None, minute=None, second=None):             # <<<<<<<<<<<<<<
 *         # freq points to a tuple (base, mult);  base is one of the defined
 *         # periods such as A, Q, etc. Every five minutes would be, e.g.,
 */
    values[8] = ((PyObject *)((PyObject *)Py_None));
    values[9] = ((PyObject *)((PyObject *)Py_None));
    values[10] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ordinal);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_year);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_month);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quarter);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_day);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_hour);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minute);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_second);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 1140, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_cls = values[0];
    __pyx_v_value = values[1];
    __pyx_v_freq = values[2];
    __pyx_v_ordinal = values[3];
    __pyx_v_year = values[4];
    __pyx_v_month = values[5];
    __pyx_v_quarter = values[6];
    __pyx_v_day = values[7];
    __pyx_v_hour = values[8];
    __pyx_v_minute = values[9];
    __pyx_v_second = values[10];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__new__", 0, 1, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1140, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period.Period.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_6Period___new__(__pyx_self, __pyx_v_cls, __pyx_v_value, __pyx_v_freq, __pyx_v_ordinal, __pyx_v_year, __pyx_v_month, __pyx_v_quarter, __pyx_v_day, __pyx_v_hour, __pyx_v_minute, __pyx_v_second);

  /* "pandas/src/period.pyx":1140
 *     """
 * 
 *     def __new__(cls, value=None, freq=None, ordinal=None,             # <<<<<<<<<<<<<<
 *                 year=None, month=None, quarter=None, day=None,
 *                 hour=None, minute=None, second=None):
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_6Period___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_value, PyObject *__pyx_v_freq, PyObject *__pyx_v_ordinal, PyObject *__pyx_v_year, PyObject *__pyx_v_month, PyObject *__pyx_v_quarter, PyObject *__pyx_v_day, PyObject *__pyx_v_hour, PyObject *__pyx_v_minute, PyObject *__pyx_v_second) {
  PyObject *__pyx_v_other = NULL;
  PyObject *__pyx_v_converted = NULL;
  PyObject *__pyx_v_dt = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_reso = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_v_base = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  __pyx_t_5numpy_int64_t __pyx_t_23;
  __Pyx_RefNannySetupContext("__new__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_INCREF(__pyx_v_freq);
  __Pyx_INCREF(__pyx_v_ordinal);
  __Pyx_INCREF(__pyx_v_month);
  __Pyx_INCREF(__pyx_v_day);
  __Pyx_INCREF(__pyx_v_hour);
  __Pyx_INCREF(__pyx_v_minute);
  __Pyx_INCREF(__pyx_v_second);

  /* "pandas/src/period.pyx":1151
 *         cdef _Period self
 * 
 *         if freq is not None:             # <<<<<<<<<<<<<<
 *             freq = cls._maybe_convert_freq(freq)
 * 
 */
  __pyx_t_1 = (__pyx_v_freq != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1152
 * 
 *         if freq is not None:
 *             freq = cls._maybe_convert_freq(freq)             # <<<<<<<<<<<<<<
 * 
 *         if ordinal is not None and value is not None:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls, __pyx_n_s_maybe_convert_freq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_freq);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1151
 *         cdef _Period self
 * 
 *         if freq is not None:             # <<<<<<<<<<<<<<
 *             freq = cls._maybe_convert_freq(freq)
 * 
 */
  }

  /* "pandas/src/period.pyx":1154
 *             freq = cls._maybe_convert_freq(freq)
 * 
 *         if ordinal is not None and value is not None:             # <<<<<<<<<<<<<<
 *             raise ValueError(("Only value or ordinal but not both should be "
 *                               "given but not both"))
 */
  __pyx_t_1 = (__pyx_v_ordinal != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {
  } else {
    __pyx_t_2 = __pyx_t_7;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_7 = (__pyx_v_value != Py_None);
  __pyx_t_1 = (__pyx_t_7 != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1155
 * 
 *         if ordinal is not None and value is not None:
 *             raise ValueError(("Only value or ordinal but not both should be "             # <<<<<<<<<<<<<<
 *                               "given but not both"))
 *         elif ordinal is not None:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1155, __pyx_L1_error)

    /* "pandas/src/period.pyx":1154
 *             freq = cls._maybe_convert_freq(freq)
 * 
 *         if ordinal is not None and value is not None:             # <<<<<<<<<<<<<<
 *             raise ValueError(("Only value or ordinal but not both should be "
 *                               "given but not both"))
 */
  }

  /* "pandas/src/period.pyx":1157
 *             raise ValueError(("Only value or ordinal but not both should be "
 *                               "given but not both"))
 *         elif ordinal is not None:             # <<<<<<<<<<<<<<
 *             if not lib.is_integer(ordinal):
 *                 raise ValueError("Ordinal must be an integer")
 */
  __pyx_t_2 = (__pyx_v_ordinal != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "pandas/src/period.pyx":1158
 *                               "given but not both"))
 *         elif ordinal is not None:
 *             if not lib.is_integer(ordinal):             # <<<<<<<<<<<<<<
 *                 raise ValueError("Ordinal must be an integer")
 *             if freq is None:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_lib); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_is_integer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_ordinal);
      __Pyx_GIVEREF(__pyx_v_ordinal);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_ordinal);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = ((!__pyx_t_1) != 0);
    if (__pyx_t_2) {

      /* "pandas/src/period.pyx":1159
 *         elif ordinal is not None:
 *             if not lib.is_integer(ordinal):
 *                 raise ValueError("Ordinal must be an integer")             # <<<<<<<<<<<<<<
 *             if freq is None:
 *                 raise ValueError('Must supply freq for ordinal value')
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1159, __pyx_L1_error)

      /* "pandas/src/period.pyx":1158
 *                               "given but not both"))
 *         elif ordinal is not None:
 *             if not lib.is_integer(ordinal):             # <<<<<<<<<<<<<<
 *                 raise ValueError("Ordinal must be an integer")
 *             if freq is None:
 */
    }

    /* "pandas/src/period.pyx":1160
 *             if not lib.is_integer(ordinal):
 *                 raise ValueError("Ordinal must be an integer")
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for ordinal value')
 * 
 */
    __pyx_t_2 = (__pyx_v_freq == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "pandas/src/period.pyx":1161
 *                 raise ValueError("Ordinal must be an integer")
 *             if freq is None:
 *                 raise ValueError('Must supply freq for ordinal value')             # <<<<<<<<<<<<<<
 * 
 *         elif value is None:
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1161, __pyx_L1_error)

      /* "pandas/src/period.pyx":1160
 *             if not lib.is_integer(ordinal):
 *                 raise ValueError("Ordinal must be an integer")
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for ordinal value')
 * 
 */
    }

    /* "pandas/src/period.pyx":1157
 *             raise ValueError(("Only value or ordinal but not both should be "
 *                               "given but not both"))
 *         elif ordinal is not None:             # <<<<<<<<<<<<<<
 *             if not lib.is_integer(ordinal):
 *                 raise ValueError("Ordinal must be an integer")
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1163
 *                 raise ValueError('Must supply freq for ordinal value')
 * 
 *         elif value is None:             # <<<<<<<<<<<<<<
 *             if (year is None and month is None and
 *                         quarter is None and day is None and
 */
  __pyx_t_1 = (__pyx_v_value == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1164
 * 
 *         elif value is None:
 *             if (year is None and month is None and             # <<<<<<<<<<<<<<
 *                         quarter is None and day is None and
 *                         hour is None and minute is None and second is None):
 */
    __pyx_t_1 = (__pyx_v_year == Py_None);
    __pyx_t_7 = (__pyx_t_1 != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_2 = __pyx_t_7;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_month == Py_None);
    __pyx_t_1 = (__pyx_t_7 != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L10_bool_binop_done;
    }

    /* "pandas/src/period.pyx":1165
 *         elif value is None:
 *             if (year is None and month is None and
 *                         quarter is None and day is None and             # <<<<<<<<<<<<<<
 *                         hour is None and minute is None and second is None):
 *                 ordinal = tslib.iNaT
 */
    __pyx_t_1 = (__pyx_v_quarter == Py_None);
    __pyx_t_7 = (__pyx_t_1 != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_2 = __pyx_t_7;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_day == Py_None);
    __pyx_t_1 = (__pyx_t_7 != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L10_bool_binop_done;
    }

    /* "pandas/src/period.pyx":1166
 *             if (year is None and month is None and
 *                         quarter is None and day is None and
 *                         hour is None and minute is None and second is None):             # <<<<<<<<<<<<<<
 *                 ordinal = tslib.iNaT
 *             else:
 */
    __pyx_t_1 = (__pyx_v_hour == Py_None);
    __pyx_t_7 = (__pyx_t_1 != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_2 = __pyx_t_7;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_minute == Py_None);
    __pyx_t_1 = (__pyx_t_7 != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_1 = (__pyx_v_second == Py_None);
    __pyx_t_7 = (__pyx_t_1 != 0);
    __pyx_t_2 = __pyx_t_7;
    __pyx_L10_bool_binop_done:;

    /* "pandas/src/period.pyx":1164
 * 
 *         elif value is None:
 *             if (year is None and month is None and             # <<<<<<<<<<<<<<
 *                         quarter is None and day is None and
 *                         hour is None and minute is None and second is None):
 */
    if (__pyx_t_2) {

      /* "pandas/src/period.pyx":1167
 *                         quarter is None and day is None and
 *                         hour is None and minute is None and second is None):
 *                 ordinal = tslib.iNaT             # <<<<<<<<<<<<<<
 *             else:
 *                 if freq is None:
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_iNaT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_ordinal, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":1164
 * 
 *         elif value is None:
 *             if (year is None and month is None and             # <<<<<<<<<<<<<<
 *                         quarter is None and day is None and
 *                         hour is None and minute is None and second is None):
 */
      goto __pyx_L9;
    }

    /* "pandas/src/period.pyx":1169
 *                 ordinal = tslib.iNaT
 *             else:
 *                 if freq is None:             # <<<<<<<<<<<<<<
 *                     raise ValueError("If value is None, freq cannot be None")
 * 
 */
    /*else*/ {
      __pyx_t_2 = (__pyx_v_freq == Py_None);
      __pyx_t_7 = (__pyx_t_2 != 0);
      if (__pyx_t_7) {

        /* "pandas/src/period.pyx":1170
 *             else:
 *                 if freq is None:
 *                     raise ValueError("If value is None, freq cannot be None")             # <<<<<<<<<<<<<<
 * 
 *                 # set defaults
 */
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1170, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(0, 1170, __pyx_L1_error)

        /* "pandas/src/period.pyx":1169
 *                 ordinal = tslib.iNaT
 *             else:
 *                 if freq is None:             # <<<<<<<<<<<<<<
 *                     raise ValueError("If value is None, freq cannot be None")
 * 
 */
      }

      /* "pandas/src/period.pyx":1173
 * 
 *                 # set defaults
 *                 month = 1 if month is None else month             # <<<<<<<<<<<<<<
 *                 day = 1 if day is None else day
 *                 hour = 0 if hour is None else hour
 */
      __pyx_t_7 = (__pyx_v_month == Py_None);
      if ((__pyx_t_7 != 0)) {
        __Pyx_INCREF(__pyx_int_1);
        __pyx_t_6 = __pyx_int_1;
      } else {
        __Pyx_INCREF(__pyx_v_month);
        __pyx_t_6 = __pyx_v_month;
      }
      __Pyx_DECREF_SET(__pyx_v_month, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":1174
 *                 # set defaults
 *                 month = 1 if month is None else month
 *                 day = 1 if day is None else day             # <<<<<<<<<<<<<<
 *                 hour = 0 if hour is None else hour
 *                 minute = 0 if minute is None else minute
 */
      __pyx_t_7 = (__pyx_v_day == Py_None);
      if ((__pyx_t_7 != 0)) {
        __Pyx_INCREF(__pyx_int_1);
        __pyx_t_6 = __pyx_int_1;
      } else {
        __Pyx_INCREF(__pyx_v_day);
        __pyx_t_6 = __pyx_v_day;
      }
      __Pyx_DECREF_SET(__pyx_v_day, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":1175
 *                 month = 1 if month is None else month
 *                 day = 1 if day is None else day
 *                 hour = 0 if hour is None else hour             # <<<<<<<<<<<<<<
 *                 minute = 0 if minute is None else minute
 *                 second = 0 if second is None else second
 */
      __pyx_t_7 = (__pyx_v_hour == Py_None);
      if ((__pyx_t_7 != 0)) {
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_6 = __pyx_int_0;
      } else {
        __Pyx_INCREF(__pyx_v_hour);
        __pyx_t_6 = __pyx_v_hour;
      }
      __Pyx_DECREF_SET(__pyx_v_hour, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":1176
 *                 day = 1 if day is None else day
 *                 hour = 0 if hour is None else hour
 *                 minute = 0 if minute is None else minute             # <<<<<<<<<<<<<<
 *                 second = 0 if second is None else second
 * 
 */
      __pyx_t_7 = (__pyx_v_minute == Py_None);
      if ((__pyx_t_7 != 0)) {
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_6 = __pyx_int_0;
      } else {
        __Pyx_INCREF(__pyx_v_minute);
        __pyx_t_6 = __pyx_v_minute;
      }
      __Pyx_DECREF_SET(__pyx_v_minute, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":1177
 *                 hour = 0 if hour is None else hour
 *                 minute = 0 if minute is None else minute
 *                 second = 0 if second is None else second             # <<<<<<<<<<<<<<
 * 
 *                 ordinal = _ordinal_from_fields(year, month, quarter, day,
 */
      __pyx_t_7 = (__pyx_v_second == Py_None);
      if ((__pyx_t_7 != 0)) {
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_6 = __pyx_int_0;
      } else {
        __Pyx_INCREF(__pyx_v_second);
        __pyx_t_6 = __pyx_v_second;
      }
      __Pyx_DECREF_SET(__pyx_v_second, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":1179
 *                 second = 0 if second is None else second
 * 
 *                 ordinal = _ordinal_from_fields(year, month, quarter, day,             # <<<<<<<<<<<<<<
 *                                                hour, minute, second, freq)
 * 
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ordinal_from_fields); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1179, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "pandas/src/period.pyx":1180
 * 
 *                 ordinal = _ordinal_from_fields(year, month, quarter, day,
 *                                                hour, minute, second, freq)             # <<<<<<<<<<<<<<
 * 
 *         elif isinstance(value, Period):
 */
      __pyx_t_5 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_4 = PyTuple_New(8+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1179, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_year);
      __Pyx_GIVEREF(__pyx_v_year);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_v_year);
      __Pyx_INCREF(__pyx_v_month);
      __Pyx_GIVEREF(__pyx_v_month);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_month);
      __Pyx_INCREF(__pyx_v_quarter);
      __Pyx_GIVEREF(__pyx_v_quarter);
      PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, __pyx_v_quarter);
      __Pyx_INCREF(__pyx_v_day);
      __Pyx_GIVEREF(__pyx_v_day);
      PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_8, __pyx_v_day);
      __Pyx_INCREF(__pyx_v_hour);
      __Pyx_GIVEREF(__pyx_v_hour);
      PyTuple_SET_ITEM(__pyx_t_4, 4+__pyx_t_8, __pyx_v_hour);
      __Pyx_INCREF(__pyx_v_minute);
      __Pyx_GIVEREF(__pyx_v_minute);
      PyTuple_SET_ITEM(__pyx_t_4, 5+__pyx_t_8, __pyx_v_minute);
      __Pyx_INCREF(__pyx_v_second);
      __Pyx_GIVEREF(__pyx_v_second);
      PyTuple_SET_ITEM(__pyx_t_4, 6+__pyx_t_8, __pyx_v_second);
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_4, 7+__pyx_t_8, __pyx_v_freq);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1179, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_ordinal, __pyx_t_6);
      __pyx_t_6 = 0;
    }
    __pyx_L9:;

    /* "pandas/src/period.pyx":1163
 *                 raise ValueError('Must supply freq for ordinal value')
 * 
 *         elif value is None:             # <<<<<<<<<<<<<<
 *             if (year is None and month is None and
 *                         quarter is None and day is None and
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1182
 *                                                hour, minute, second, freq)
 * 
 *         elif isinstance(value, Period):             # <<<<<<<<<<<<<<
 *             other = value
 *             if freq is None or frequencies.get_freq_code(
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_Period); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyObject_IsInstance(__pyx_v_value, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1182, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_2 = (__pyx_t_7 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1183
 * 
 *         elif isinstance(value, Period):
 *             other = value             # <<<<<<<<<<<<<<
 *             if freq is None or frequencies.get_freq_code(
 *                     freq) == frequencies.get_freq_code(other.freq):
 */
    __Pyx_INCREF(__pyx_v_value);
    __pyx_v_other = __pyx_v_value;

    /* "pandas/src/period.pyx":1184
 *         elif isinstance(value, Period):
 *             other = value
 *             if freq is None or frequencies.get_freq_code(             # <<<<<<<<<<<<<<
 *                     freq) == frequencies.get_freq_code(other.freq):
 *                 ordinal = other.ordinal
 */
    __pyx_t_7 = (__pyx_v_freq == Py_None);
    __pyx_t_1 = (__pyx_t_7 != 0);
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L19_bool_binop_done;
    }

    /* "pandas/src/period.pyx":1185
 *             other = value
 *             if freq is None or frequencies.get_freq_code(
 *                     freq) == frequencies.get_freq_code(other.freq):             # <<<<<<<<<<<<<<
 *                 ordinal = other.ordinal
 *                 freq = other.freq
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "pandas/src/period.pyx":1184
 *         elif isinstance(value, Period):
 *             other = value
 *             if freq is None or frequencies.get_freq_code(             # <<<<<<<<<<<<<<
 *                     freq) == frequencies.get_freq_code(other.freq):
 *                 ordinal = other.ordinal
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1185
 *             other = value
 *             if freq is None or frequencies.get_freq_code(
 *                     freq) == frequencies.get_freq_code(other.freq):             # <<<<<<<<<<<<<<
 *                 ordinal = other.ordinal
 *                 freq = other.freq
 */
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_freq); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_freq);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_freq); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1185, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1185, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1185, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L19_bool_binop_done:;

    /* "pandas/src/period.pyx":1184
 *         elif isinstance(value, Period):
 *             other = value
 *             if freq is None or frequencies.get_freq_code(             # <<<<<<<<<<<<<<
 *                     freq) == frequencies.get_freq_code(other.freq):
 *                 ordinal = other.ordinal
 */
    if (__pyx_t_2) {

      /* "pandas/src/period.pyx":1186
 *             if freq is None or frequencies.get_freq_code(
 *                     freq) == frequencies.get_freq_code(other.freq):
 *                 ordinal = other.ordinal             # <<<<<<<<<<<<<<
 *                 freq = other.freq
 *             else:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_ordinal, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pandas/src/period.pyx":1187
 *                     freq) == frequencies.get_freq_code(other.freq):
 *                 ordinal = other.ordinal
 *                 freq = other.freq             # <<<<<<<<<<<<<<
 *             else:
 *                 converted = other.asfreq(freq)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1187, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pandas/src/period.pyx":1184
 *         elif isinstance(value, Period):
 *             other = value
 *             if freq is None or frequencies.get_freq_code(             # <<<<<<<<<<<<<<
 *                     freq) == frequencies.get_freq_code(other.freq):
 *                 ordinal = other.ordinal
 */
      goto __pyx_L18;
    }

    /* "pandas/src/period.pyx":1189
 *                 freq = other.freq
 *             else:
 *                 converted = other.asfreq(freq)             # <<<<<<<<<<<<<<
 *                 ordinal = converted.ordinal
 * 
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_asfreq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1189, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1189, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1189, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_freq);
        __Pyx_GIVEREF(__pyx_v_freq);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_freq);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1189, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_converted = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "pandas/src/period.pyx":1190
 *             else:
 *                 converted = other.asfreq(freq)
 *                 ordinal = converted.ordinal             # <<<<<<<<<<<<<<
 * 
 *         elif is_null_datetimelike(value) or value in tslib._nat_strings:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_converted, __pyx_n_s_ordinal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1190, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_ordinal, __pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L18:;

    /* "pandas/src/period.pyx":1182
 *                                                hour, minute, second, freq)
 * 
 *         elif isinstance(value, Period):             # <<<<<<<<<<<<<<
 *             other = value
 *             if freq is None or frequencies.get_freq_code(
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1192
 *                 ordinal = converted.ordinal
 * 
 *         elif is_null_datetimelike(value) or value in tslib._nat_strings:             # <<<<<<<<<<<<<<
 *             ordinal = tslib.iNaT
 * 
 */
  __pyx_t_1 = (__pyx_f_6pandas_3lib_is_null_datetimelike(__pyx_v_value) != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L21_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_nat_strings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_value, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1192, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__pyx_t_1 != 0);
  __pyx_t_2 = __pyx_t_7;
  __pyx_L21_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1193
 * 
 *         elif is_null_datetimelike(value) or value in tslib._nat_strings:
 *             ordinal = tslib.iNaT             # <<<<<<<<<<<<<<
 * 
 *         elif isinstance(value, compat.string_types) or lib.is_integer(value):
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_tslib); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1193, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_iNaT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1193, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_ordinal, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1192
 *                 ordinal = converted.ordinal
 * 
 *         elif is_null_datetimelike(value) or value in tslib._nat_strings:             # <<<<<<<<<<<<<<
 *             ordinal = tslib.iNaT
 * 
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1195
 *             ordinal = tslib.iNaT
 * 
 *         elif isinstance(value, compat.string_types) or lib.is_integer(value):             # <<<<<<<<<<<<<<
 *             if lib.is_integer(value):
 *                 value = str(value)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_compat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_string_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = PyObject_IsInstance(__pyx_v_value, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = (__pyx_t_7 != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L23_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_lib); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_integer); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_value);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __pyx_t_1;
  __pyx_L23_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1196
 * 
 *         elif isinstance(value, compat.string_types) or lib.is_integer(value):
 *             if lib.is_integer(value):             # <<<<<<<<<<<<<<
 *                 value = str(value)
 *             value = value.upper()
 */
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_lib); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1196, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_is_integer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1196, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1196, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1196, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_value);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1196, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1196, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "pandas/src/period.pyx":1197
 *         elif isinstance(value, compat.string_types) or lib.is_integer(value):
 *             if lib.is_integer(value):
 *                 value = str(value)             # <<<<<<<<<<<<<<
 *             value = value.upper()
 *             dt, _, reso = parse_time_string(value, freq)
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_value);
      __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pandas/src/period.pyx":1196
 * 
 *         elif isinstance(value, compat.string_types) or lib.is_integer(value):
 *             if lib.is_integer(value):             # <<<<<<<<<<<<<<
 *                 value = str(value)
 *             value = value.upper()
 */
    }

    /* "pandas/src/period.pyx":1198
 *             if lib.is_integer(value):
 *                 value = str(value)
 *             value = value.upper()             # <<<<<<<<<<<<<<
 *             dt, _, reso = parse_time_string(value, freq)
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_upper); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1198, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1198, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1198, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pandas/src/period.pyx":1199
 *                 value = str(value)
 *             value = value.upper()
 *             dt, _, reso = parse_time_string(value, freq)             # <<<<<<<<<<<<<<
 * 
 *             if freq is None:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_parse_time_string); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_10 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_8, __pyx_v_value);
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_8, __pyx_v_freq);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
      PyObject* sequence = __pyx_t_6;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1199, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L26_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_10 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_10)) goto __pyx_L26_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_10);
      index = 2; __pyx_t_3 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L26_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_5), 3) < 0) __PYX_ERR(0, 1199, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L27_unpacking_done;
      __pyx_L26_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1199, __pyx_L1_error)
      __pyx_L27_unpacking_done:;
    }
    __pyx_v_dt = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v__ = __pyx_t_10;
    __pyx_t_10 = 0;
    __pyx_v_reso = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1201
 *             dt, _, reso = parse_time_string(value, freq)
 * 
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 try:
 *                     freq = frequencies.Resolution.get_freq(reso)
 */
    __pyx_t_2 = (__pyx_v_freq == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "pandas/src/period.pyx":1202
 * 
 *             if freq is None:
 *                 try:             # <<<<<<<<<<<<<<
 *                     freq = frequencies.Resolution.get_freq(reso)
 *                 except KeyError:
 */
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_14);
        /*try:*/ {

          /* "pandas/src/period.pyx":1203
 *             if freq is None:
 *                 try:
 *                     freq = frequencies.Resolution.get_freq(reso)             # <<<<<<<<<<<<<<
 *                 except KeyError:
 *                     raise ValueError(
 */
          __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1203, __pyx_L29_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Resolution); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1203, __pyx_L29_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_get_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1203, __pyx_L29_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_10 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_10)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          if (!__pyx_t_10) {
            __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_reso); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1203, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_6);
          } else {
            __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1203, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL;
            __Pyx_INCREF(__pyx_v_reso);
            __Pyx_GIVEREF(__pyx_v_reso);
            PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_reso);
            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1203, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF_SET(__pyx_v_freq, __pyx_t_6);
          __pyx_t_6 = 0;

          /* "pandas/src/period.pyx":1202
 * 
 *             if freq is None:
 *                 try:             # <<<<<<<<<<<<<<
 *                     freq = frequencies.Resolution.get_freq(reso)
 *                 except KeyError:
 */
        }
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L36_try_end;
        __pyx_L29_error:;
        __Pyx_PyThreadState_assign
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "pandas/src/period.pyx":1204
 *                 try:
 *                     freq = frequencies.Resolution.get_freq(reso)
 *                 except KeyError:             # <<<<<<<<<<<<<<
 *                     raise ValueError(
 *                         "Invalid frequency or could not infer: %s" % reso)
 */
        __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
        if (__pyx_t_15) {
          __Pyx_AddTraceback("pandas._period.Period.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 1204, __pyx_L31_except_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_4);

          /* "pandas/src/period.pyx":1206
 *                 except KeyError:
 *                     raise ValueError(
 *                         "Invalid frequency or could not infer: %s" % reso)             # <<<<<<<<<<<<<<
 * 
 *         elif isinstance(value, datetime):
 */
          __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_frequency_or_could_not_i, __pyx_v_reso); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1206, __pyx_L31_except_error)
          __Pyx_GOTREF(__pyx_t_10);

          /* "pandas/src/period.pyx":1205
 *                     freq = frequencies.Resolution.get_freq(reso)
 *                 except KeyError:
 *                     raise ValueError(             # <<<<<<<<<<<<<<
 *                         "Invalid frequency or could not infer: %s" % reso)
 * 
 */
          __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1205, __pyx_L31_except_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1205, __pyx_L31_except_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_Raise(__pyx_t_10, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __PYX_ERR(0, 1205, __pyx_L31_except_error)
        }
        goto __pyx_L31_except_error;
        __pyx_L31_except_error:;

        /* "pandas/src/period.pyx":1202
 * 
 *             if freq is None:
 *                 try:             # <<<<<<<<<<<<<<
 *                     freq = frequencies.Resolution.get_freq(reso)
 *                 except KeyError:
 */
        __Pyx_PyThreadState_assign
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        goto __pyx_L1_error;
        __pyx_L36_try_end:;
      }

      /* "pandas/src/period.pyx":1201
 *             dt, _, reso = parse_time_string(value, freq)
 * 
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 try:
 *                     freq = frequencies.Resolution.get_freq(reso)
 */
    }

    /* "pandas/src/period.pyx":1195
 *             ordinal = tslib.iNaT
 * 
 *         elif isinstance(value, compat.string_types) or lib.is_integer(value):             # <<<<<<<<<<<<<<
 *             if lib.is_integer(value):
 *                 value = str(value)
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1208
 *                         "Invalid frequency or could not infer: %s" % reso)
 * 
 *         elif isinstance(value, datetime):             # <<<<<<<<<<<<<<
 *             dt = value
 *             if freq is None:
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_8datetime_datetime); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1209
 * 
 *         elif isinstance(value, datetime):
 *             dt = value             # <<<<<<<<<<<<<<
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')
 */
    __Pyx_INCREF(__pyx_v_value);
    __pyx_v_dt = __pyx_v_value;

    /* "pandas/src/period.pyx":1210
 *         elif isinstance(value, datetime):
 *             dt = value
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, np.datetime64):
 */
    __pyx_t_2 = (__pyx_v_freq == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "pandas/src/period.pyx":1211
 *             dt = value
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')             # <<<<<<<<<<<<<<
 *         elif isinstance(value, np.datetime64):
 *             dt = Timestamp(value)
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 1211, __pyx_L1_error)

      /* "pandas/src/period.pyx":1210
 *         elif isinstance(value, datetime):
 *             dt = value
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, np.datetime64):
 */
    }

    /* "pandas/src/period.pyx":1208
 *                         "Invalid frequency or could not infer: %s" % reso)
 * 
 *         elif isinstance(value, datetime):             # <<<<<<<<<<<<<<
 *             dt = value
 *             if freq is None:
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1212
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, np.datetime64):             # <<<<<<<<<<<<<<
 *             dt = Timestamp(value)
 *             if freq is None:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_datetime64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = PyObject_IsInstance(__pyx_v_value, __pyx_t_3); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 1212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1213
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, np.datetime64):
 *             dt = Timestamp(value)             # <<<<<<<<<<<<<<
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timestamp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1213, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1213, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_value);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1213, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_dt = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1214
 *         elif isinstance(value, np.datetime64):
 *             dt = Timestamp(value)
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, date):
 */
    __pyx_t_2 = (__pyx_v_freq == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "pandas/src/period.pyx":1215
 *             dt = Timestamp(value)
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')             # <<<<<<<<<<<<<<
 *         elif isinstance(value, date):
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1215, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1215, __pyx_L1_error)

      /* "pandas/src/period.pyx":1214
 *         elif isinstance(value, np.datetime64):
 *             dt = Timestamp(value)
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, date):
 */
    }

    /* "pandas/src/period.pyx":1212
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, np.datetime64):             # <<<<<<<<<<<<<<
 *             dt = Timestamp(value)
 *             if freq is None:
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1216
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, date):             # <<<<<<<<<<<<<<
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 *             if freq is None:
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_8datetime_date); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1217
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, date):
 *             dt = datetime(year=value.year, month=value.month, day=value.day)             # <<<<<<<<<<<<<<
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')
 */
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_year); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_year, __pyx_t_4) < 0) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_month); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_month, __pyx_t_4) < 0) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_day); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_day, __pyx_t_4) < 0) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8datetime_datetime), __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dt = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "pandas/src/period.pyx":1218
 *         elif isinstance(value, date):
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for datetime value')
 *         else:
 */
    __pyx_t_2 = (__pyx_v_freq == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "pandas/src/period.pyx":1219
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')             # <<<<<<<<<<<<<<
 *         else:
 *             msg = "Value must be Period, string, integer, or datetime"
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 1219, __pyx_L1_error)

      /* "pandas/src/period.pyx":1218
 *         elif isinstance(value, date):
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 *             if freq is None:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Must supply freq for datetime value')
 *         else:
 */
    }

    /* "pandas/src/period.pyx":1216
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')
 *         elif isinstance(value, date):             # <<<<<<<<<<<<<<
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 *             if freq is None:
 */
    goto __pyx_L4;
  }

  /* "pandas/src/period.pyx":1221
 *                 raise ValueError('Must supply freq for datetime value')
 *         else:
 *             msg = "Value must be Period, string, integer, or datetime"             # <<<<<<<<<<<<<<
 *             raise ValueError(msg)
 * 
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_kp_s_Value_must_be_Period_string_inte);
    __pyx_v_msg = __pyx_kp_s_Value_must_be_Period_string_inte;

    /* "pandas/src/period.pyx":1222
 *         else:
 *             msg = "Value must be Period, string, integer, or datetime"
 *             raise ValueError(msg)             # <<<<<<<<<<<<<<
 * 
 *         if ordinal is None:
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_msg);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1222, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "pandas/src/period.pyx":1224
 *             raise ValueError(msg)
 * 
 *         if ordinal is None:             # <<<<<<<<<<<<<<
 *             base, mult = frequencies.get_freq_code(freq)
 *             ordinal = get_period_ordinal(dt.year, dt.month, dt.day,
 */
  __pyx_t_1 = (__pyx_v_ordinal == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1225
 * 
 *         if ordinal is None:
 *             base, mult = frequencies.get_freq_code(freq)             # <<<<<<<<<<<<<<
 *             ordinal = get_period_ordinal(dt.year, dt.month, dt.day,
 *                                          dt.hour, dt.minute, dt.second,
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1225, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_freq);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1225, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext;
      index = 0; __pyx_t_10 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_10)) goto __pyx_L43_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_10);
      index = 1; __pyx_t_6 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L43_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1225, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L44_unpacking_done;
      __pyx_L43_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1225, __pyx_L1_error)
      __pyx_L44_unpacking_done:;
    }
    __pyx_v_base = __pyx_t_10;
    __pyx_t_10 = 0;
    __pyx_v_mult = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "pandas/src/period.pyx":1226
 *         if ordinal is None:
 *             base, mult = frequencies.get_freq_code(freq)
 *             ordinal = get_period_ordinal(dt.year, dt.month, dt.day,             # <<<<<<<<<<<<<<
 *                                          dt.hour, dt.minute, dt.second,
 *                                          dt.microsecond, 0, base)
 */
    if (unlikely(!__pyx_v_dt)) { __Pyx_RaiseUnboundLocalError("dt"); __PYX_ERR(0, 1226, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_year); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_v_dt)) { __Pyx_RaiseUnboundLocalError("dt"); __PYX_ERR(0, 1226, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_month); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_16 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_v_dt)) { __Pyx_RaiseUnboundLocalError("dt"); __PYX_ERR(0, 1226, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_day); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1227
 *             base, mult = frequencies.get_freq_code(freq)
 *             ordinal = get_period_ordinal(dt.year, dt.month, dt.day,
 *                                          dt.hour, dt.minute, dt.second,             # <<<<<<<<<<<<<<
 *                                          dt.microsecond, 0, base)
 * 
 */
    if (unlikely(!__pyx_v_dt)) { __Pyx_RaiseUnboundLocalError("dt"); __PYX_ERR(0, 1227, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_hour); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1227, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_v_dt)) { __Pyx_RaiseUnboundLocalError("dt"); __PYX_ERR(0, 1227, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_minute); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_19 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1227, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_v_dt)) { __Pyx_RaiseUnboundLocalError("dt"); __PYX_ERR(0, 1227, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_second); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_20 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_20 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1227, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1228
 *             ordinal = get_period_ordinal(dt.year, dt.month, dt.day,
 *                                          dt.hour, dt.minute, dt.second,
 *                                          dt.microsecond, 0, base)             # <<<<<<<<<<<<<<
 * 
 *         return cls._from_ordinal(ordinal, freq)
 */
    if (unlikely(!__pyx_v_dt)) { __Pyx_RaiseUnboundLocalError("dt"); __PYX_ERR(0, 1228, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_microsecond); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1228, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_21 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_21 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1228, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_22 = __Pyx_PyInt_As_int(__pyx_v_base); if (unlikely((__pyx_t_22 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1228, __pyx_L1_error)

    /* "pandas/src/period.pyx":1226
 *         if ordinal is None:
 *             base, mult = frequencies.get_freq_code(freq)
 *             ordinal = get_period_ordinal(dt.year, dt.month, dt.day,             # <<<<<<<<<<<<<<
 *                                          dt.hour, dt.minute, dt.second,
 *                                          dt.microsecond, 0, base)
 */
    __pyx_t_23 = get_period_ordinal(__pyx_t_15, __pyx_t_16, __pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20, __pyx_t_21, 0, __pyx_t_22); if (unlikely(__pyx_t_23 == INT32_MIN)) __PYX_ERR(0, 1226, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_t_23); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_ordinal, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1224
 *             raise ValueError(msg)
 * 
 *         if ordinal is None:             # <<<<<<<<<<<<<<
 *             base, mult = frequencies.get_freq_code(freq)
 *             ordinal = get_period_ordinal(dt.year, dt.month, dt.day,
 */
  }

  /* "pandas/src/period.pyx":1230
 *                                          dt.microsecond, 0, base)
 * 
 *         return cls._from_ordinal(ordinal, freq)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls, __pyx_n_s_from_ordinal); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_10 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_10) {
    __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL;
  }
  __Pyx_INCREF(__pyx_v_ordinal);
  __Pyx_GIVEREF(__pyx_v_ordinal);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_v_ordinal);
  __Pyx_INCREF(__pyx_v_freq);
  __Pyx_GIVEREF(__pyx_v_freq);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_freq);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":1140
 *     """
 * 
 *     def __new__(cls, value=None, freq=None, ordinal=None,             # <<<<<<<<<<<<<<
 *                 year=None, month=None, quarter=None, day=None,
 *                 hour=None, minute=None, second=None):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pandas._period.Period.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_other);
  __Pyx_XDECREF(__pyx_v_converted);
  __Pyx_XDECREF(__pyx_v_dt);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_reso);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_freq);
  __Pyx_XDECREF(__pyx_v_ordinal);
  __Pyx_XDECREF(__pyx_v_month);
  __Pyx_XDECREF(__pyx_v_day);
  __Pyx_XDECREF(__pyx_v_hour);
  __Pyx_XDECREF(__pyx_v_minute);
  __Pyx_XDECREF(__pyx_v_second);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":1233
 * 
 * 
 * def _ordinal_from_fields(year, month, quarter, day,             # <<<<<<<<<<<<<<
 *                          hour, minute, second, freq):
 *     base, mult = frequencies.get_freq_code(freq)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_25_ordinal_from_fields(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_25_ordinal_from_fields = {"_ordinal_from_fields", (PyCFunction)__pyx_pw_6pandas_7_period_25_ordinal_from_fields, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_25_ordinal_from_fields(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_year = 0;
  PyObject *__pyx_v_month = 0;
  PyObject *__pyx_v_quarter = 0;
  PyObject *__pyx_v_day = 0;
  PyObject *__pyx_v_hour = 0;
  PyObject *__pyx_v_minute = 0;
  PyObject *__pyx_v_second = 0;
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_ordinal_from_fields (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_year,&__pyx_n_s_month,&__pyx_n_s_quarter,&__pyx_n_s_day,&__pyx_n_s_hour,&__pyx_n_s_minute,&__pyx_n_s_second,&__pyx_n_s_freq,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_year)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_month)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, 1); __PYX_ERR(0, 1233, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quarter)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, 2); __PYX_ERR(0, 1233, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_day)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, 3); __PYX_ERR(0, 1233, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_hour)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, 4); __PYX_ERR(0, 1233, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_minute)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, 5); __PYX_ERR(0, 1233, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_second)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, 6); __PYX_ERR(0, 1233, __pyx_L3_error)
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, 7); __PYX_ERR(0, 1233, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_ordinal_from_fields") < 0)) __PYX_ERR(0, 1233, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
    }
    __pyx_v_year = values[0];
    __pyx_v_month = values[1];
    __pyx_v_quarter = values[2];
    __pyx_v_day = values[3];
    __pyx_v_hour = values[4];
    __pyx_v_minute = values[5];
    __pyx_v_second = values[6];
    __pyx_v_freq = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_ordinal_from_fields", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1233, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period._ordinal_from_fields", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_24_ordinal_from_fields(__pyx_self, __pyx_v_year, __pyx_v_month, __pyx_v_quarter, __pyx_v_day, __pyx_v_hour, __pyx_v_minute, __pyx_v_second, __pyx_v_freq);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_24_ordinal_from_fields(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_year, PyObject *__pyx_v_month, PyObject *__pyx_v_quarter, PyObject *__pyx_v_day, PyObject *__pyx_v_hour, PyObject *__pyx_v_minute, PyObject *__pyx_v_second, PyObject *__pyx_v_freq) {
  PyObject *__pyx_v_base = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_mult = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  __pyx_t_5numpy_int64_t __pyx_t_16;
  __Pyx_RefNannySetupContext("_ordinal_from_fields", 0);
  __Pyx_INCREF(__pyx_v_year);
  __Pyx_INCREF(__pyx_v_month);

  /* "pandas/src/period.pyx":1235
 * def _ordinal_from_fields(year, month, quarter, day,
 *                          hour, minute, second, freq):
 *     base, mult = frequencies.get_freq_code(freq)             # <<<<<<<<<<<<<<
 *     if quarter is not None:
 *         year, month = _quarter_to_myear(year, quarter, freq)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_freq_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_freq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1235, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 1235, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1235, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_base = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_mult = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":1236
 *                          hour, minute, second, freq):
 *     base, mult = frequencies.get_freq_code(freq)
 *     if quarter is not None:             # <<<<<<<<<<<<<<
 *         year, month = _quarter_to_myear(year, quarter, freq)
 * 
 */
  __pyx_t_6 = (__pyx_v_quarter != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "pandas/src/period.pyx":1237
 *     base, mult = frequencies.get_freq_code(freq)
 *     if quarter is not None:
 *         year, month = _quarter_to_myear(year, quarter, freq)             # <<<<<<<<<<<<<<
 * 
 *     return get_period_ordinal(year, month, day, hour,
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_quarter_to_myear); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_2 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_year);
    __Pyx_GIVEREF(__pyx_v_year);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_8, __pyx_v_year);
    __Pyx_INCREF(__pyx_v_quarter);
    __Pyx_GIVEREF(__pyx_v_quarter);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_8, __pyx_v_quarter);
    __Pyx_INCREF(__pyx_v_freq);
    __Pyx_GIVEREF(__pyx_v_freq);
    PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_8, __pyx_v_freq);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1237, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_3), 2) < 0) __PYX_ERR(0, 1237, __pyx_L1_error)
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1237, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_DECREF_SET(__pyx_v_year, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_month, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pandas/src/period.pyx":1236
 *                          hour, minute, second, freq):
 *     base, mult = frequencies.get_freq_code(freq)
 *     if quarter is not None:             # <<<<<<<<<<<<<<
 *         year, month = _quarter_to_myear(year, quarter, freq)
 * 
 */
  }

  /* "pandas/src/period.pyx":1239
 *         year, month = _quarter_to_myear(year, quarter, freq)
 * 
 *     return get_period_ordinal(year, month, day, hour,             # <<<<<<<<<<<<<<
 *                               minute, second, 0, 0, base)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_year); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1239, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_month); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1239, __pyx_L1_error)
  __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_day); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1239, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_v_hour); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1239, __pyx_L1_error)

  /* "pandas/src/period.pyx":1240
 * 
 *     return get_period_ordinal(year, month, day, hour,
 *                               minute, second, 0, 0, base)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_v_minute); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1240, __pyx_L1_error)
  __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_v_second); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1240, __pyx_L1_error)
  __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_v_base); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1240, __pyx_L1_error)

  /* "pandas/src/period.pyx":1239
 *         year, month = _quarter_to_myear(year, quarter, freq)
 * 
 *     return get_period_ordinal(year, month, day, hour,             # <<<<<<<<<<<<<<
 *                               minute, second, 0, 0, base)
 * 
 */
  __pyx_t_16 = get_period_ordinal(__pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_t_14, 0, 0, __pyx_t_15); if (unlikely(__pyx_t_16 == INT32_MIN)) __PYX_ERR(0, 1239, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":1233
 * 
 * 
 * def _ordinal_from_fields(year, month, quarter, day,             # <<<<<<<<<<<<<<
 *                          hour, minute, second, freq):
 *     base, mult = frequencies.get_freq_code(freq)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pandas._period._ordinal_from_fields", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_XDECREF(__pyx_v_year);
  __Pyx_XDECREF(__pyx_v_month);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":1243
 * 
 * 
 * def _quarter_to_myear(year, quarter, freq):             # <<<<<<<<<<<<<<
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_27_quarter_to_myear(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_27_quarter_to_myear = {"_quarter_to_myear", (PyCFunction)__pyx_pw_6pandas_7_period_27_quarter_to_myear, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6pandas_7_period_27_quarter_to_myear(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_year = 0;
  PyObject *__pyx_v_quarter = 0;
  PyObject *__pyx_v_freq = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_quarter_to_myear (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_year,&__pyx_n_s_quarter,&__pyx_n_s_freq,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_year)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quarter)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_quarter_to_myear", 1, 3, 3, 1); __PYX_ERR(0, 1243, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_quarter_to_myear", 1, 3, 3, 2); __PYX_ERR(0, 1243, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_quarter_to_myear") < 0)) __PYX_ERR(0, 1243, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_year = values[0];
    __pyx_v_quarter = values[1];
    __pyx_v_freq = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_quarter_to_myear", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1243, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pandas._period._quarter_to_myear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6pandas_7_period_26_quarter_to_myear(__pyx_self, __pyx_v_year, __pyx_v_quarter, __pyx_v_freq);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_26_quarter_to_myear(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_year, PyObject *__pyx_v_quarter, PyObject *__pyx_v_freq) {
  PyObject *__pyx_v_mnum = NULL;
  PyObject *__pyx_v_month = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_quarter_to_myear", 0);
  __Pyx_INCREF(__pyx_v_year);

  /* "pandas/src/period.pyx":1244
 * 
 * def _quarter_to_myear(year, quarter, freq):
 *     if quarter is not None:             # <<<<<<<<<<<<<<
 *         if quarter <= 0 or quarter > 4:
 *             raise ValueError('Quarter must be 1 <= q <= 4')
 */
  __pyx_t_1 = (__pyx_v_quarter != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pandas/src/period.pyx":1245
 * def _quarter_to_myear(year, quarter, freq):
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:             # <<<<<<<<<<<<<<
 *             raise ValueError('Quarter must be 1 <= q <= 4')
 * 
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_quarter, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1245, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1245, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_quarter, __pyx_int_4, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1245, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1245, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_2) {

      /* "pandas/src/period.pyx":1246
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:
 *             raise ValueError('Quarter must be 1 <= q <= 4')             # <<<<<<<<<<<<<<
 * 
 *         mnum = frequencies._month_numbers[
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1246, __pyx_L1_error)

      /* "pandas/src/period.pyx":1245
 * def _quarter_to_myear(year, quarter, freq):
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:             # <<<<<<<<<<<<<<
 *             raise ValueError('Quarter must be 1 <= q <= 4')
 * 
 */
    }

    /* "pandas/src/period.pyx":1248
 *             raise ValueError('Quarter must be 1 <= q <= 4')
 * 
 *         mnum = frequencies._month_numbers[             # <<<<<<<<<<<<<<
 *             frequencies._get_rule_month(freq)] + 1
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_month_numbers); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1249
 * 
 *         mnum = frequencies._month_numbers[
 *             frequencies._get_rule_month(freq)] + 1             # <<<<<<<<<<<<<<
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1
 *         if month > mnum:
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_rule_month); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_freq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_freq);
      __Pyx_GIVEREF(__pyx_v_freq);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_freq);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "pandas/src/period.pyx":1248
 *             raise ValueError('Quarter must be 1 <= q <= 4')
 * 
 *         mnum = frequencies._month_numbers[             # <<<<<<<<<<<<<<
 *             frequencies._get_rule_month(freq)] + 1
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1
 */
    __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1249
 * 
 *         mnum = frequencies._month_numbers[
 *             frequencies._get_rule_month(freq)] + 1             # <<<<<<<<<<<<<<
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1
 *         if month > mnum:
 */
    __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1249, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_mnum = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1250
 *         mnum = frequencies._month_numbers[
 *             frequencies._get_rule_month(freq)] + 1
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1             # <<<<<<<<<<<<<<
 *         if month > mnum:
 *             year -= 1
 */
    __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_v_quarter, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyNumber_Multiply(__pyx_t_3, __pyx_int_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_v_mnum, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_RemainderObjC(__pyx_t_3, __pyx_int_12, 12, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_month = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "pandas/src/period.pyx":1251
 *             frequencies._get_rule_month(freq)] + 1
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1
 *         if month > mnum:             # <<<<<<<<<<<<<<
 *             year -= 1
 * 
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_month, __pyx_v_mnum, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1251, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1251, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "pandas/src/period.pyx":1252
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1
 *         if month > mnum:
 *             year -= 1             # <<<<<<<<<<<<<<
 * 
 *     return year, month
 */
      __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_v_year, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1252, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_year, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pandas/src/period.pyx":1251
 *             frequencies._get_rule_month(freq)] + 1
 *         month = (mnum + (quarter - 1) * 3) % 12 + 1
 *         if month > mnum:             # <<<<<<<<<<<<<<
 *             year -= 1
 * 
 */
    }

    /* "pandas/src/period.pyx":1244
 * 
 * def _quarter_to_myear(year, quarter, freq):
 *     if quarter is not None:             # <<<<<<<<<<<<<<
 *         if quarter <= 0 or quarter > 4:
 *             raise ValueError('Quarter must be 1 <= q <= 4')
 */
  }

  /* "pandas/src/period.pyx":1254
 *             year -= 1
 * 
 *     return year, month             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_month)) { __Pyx_RaiseUnboundLocalError("month"); __PYX_ERR(0, 1254, __pyx_L1_error) }
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_year);
  __Pyx_GIVEREF(__pyx_v_year);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_year);
  __Pyx_INCREF(__pyx_v_month);
  __Pyx_GIVEREF(__pyx_v_month);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_month);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":1243
 * 
 * 
 * def _quarter_to_myear(year, quarter, freq):             # <<<<<<<<<<<<<<
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pandas._period._quarter_to_myear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mnum);
  __Pyx_XDECREF(__pyx_v_month);
  __Pyx_XDECREF(__pyx_v_year);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pandas/src/period.pyx":1257
 * 
 * 
 * def _validate_end_alias(how):             # <<<<<<<<<<<<<<
 *     how_dict = {'S': 'S', 'E': 'E',
 *                 'START': 'S', 'FINISH': 'E',
 */

/* Python wrapper */
static PyObject *__pyx_pw_6pandas_7_period_29_validate_end_alias(PyObject *__pyx_self, PyObject *__pyx_v_how); /*proto*/
static PyMethodDef __pyx_mdef_6pandas_7_period_29_validate_end_alias = {"_validate_end_alias", (PyCFunction)__pyx_pw_6pandas_7_period_29_validate_end_alias, METH_O, 0};
static PyObject *__pyx_pw_6pandas_7_period_29_validate_end_alias(PyObject *__pyx_self, PyObject *__pyx_v_how) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_validate_end_alias (wrapper)", 0);
  __pyx_r = __pyx_pf_6pandas_7_period_28_validate_end_alias(__pyx_self, ((PyObject *)__pyx_v_how));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6pandas_7_period_28_validate_end_alias(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_how) {
  PyObject *__pyx_v_how_dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("_validate_end_alias", 0);
  __Pyx_INCREF(__pyx_v_how);

  /* "pandas/src/period.pyx":1258
 * 
 * def _validate_end_alias(how):
 *     how_dict = {'S': 'S', 'E': 'E',             # <<<<<<<<<<<<<<
 *                 'START': 'S', 'FINISH': 'E',
 *                 'BEGIN': 'S', 'END': 'E'}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_S, __pyx_n_s_S) < 0) __PYX_ERR(0, 1258, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_E, __pyx_n_s_E) < 0) __PYX_ERR(0, 1258, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_START, __pyx_n_s_S) < 0) __PYX_ERR(0, 1258, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FINISH, __pyx_n_s_E) < 0) __PYX_ERR(0, 1258, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_BEGIN, __pyx_n_s_S) < 0) __PYX_ERR(0, 1258, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_END, __pyx_n_s_E) < 0) __PYX_ERR(0, 1258, __pyx_L1_error)
  __pyx_v_how_dict = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pandas/src/period.pyx":1261
 *                 'START': 'S', 'FINISH': 'E',
 *                 'BEGIN': 'S', 'END': 'E'}
 *     how = how_dict.get(str(how).upper())             # <<<<<<<<<<<<<<
 *     if how not in set(['S', 'E']):
 *         raise ValueError('How must be one of S or E')
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_how);
  __Pyx_GIVEREF(__pyx_v_how);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_how);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_upper); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1261, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_how_dict, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_how, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "pandas/src/period.pyx":1262
 *                 'BEGIN': 'S', 'END': 'E'}
 *     how = how_dict.get(str(how).upper())
 *     if how not in set(['S', 'E']):             # <<<<<<<<<<<<<<
 *         raise ValueError('How must be one of S or E')
 *     return how
 */
  __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PySet_Add(__pyx_t_2, __pyx_n_s_S) < 0) __PYX_ERR(0, 1262, __pyx_L1_error)
  if (PySet_Add(__pyx_t_2, __pyx_n_s_E) < 0) __PYX_ERR(0, 1262, __pyx_L1_error)
  __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_how, __pyx_t_2, Py_NE)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1262, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pandas/src/period.pyx":1263
 *     how = how_dict.get(str(how).upper())
 *     if how not in set(['S', 'E']):
 *         raise ValueError('How must be one of S or E')             # <<<<<<<<<<<<<<
 *     return how
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1263, __pyx_L1_error)

    /* "pandas/src/period.pyx":1262
 *                 'BEGIN': 'S', 'END': 'E'}
 *     how = how_dict.get(str(how).upper())
 *     if how not in set(['S', 'E']):             # <<<<<<<<<<<<<<
 *         raise ValueError('How must be one of S or E')
 *     return how
 */
  }

  /* "pandas/src/period.pyx":1264
 *     if how not in set(['S', 'E']):
 *         raise ValueError('How must be one of S or E')
 *     return how             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_how);
  __pyx_r = __pyx_v_how;
  goto __pyx_L0;

  /* "pandas/src/period.pyx":1257
 * 
 * 
 * def _validate_end_alias(how):             # <<<<<<<<<<<<<<
 *     how_dict = {'S': 'S', 'E': 'E',
 *                 'START': 'S', 'FINISH': 'E',
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pandas._period._validate_end_alias", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_how_dict);
  __Pyx_XDECREF(__pyx_v_how);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":55
 *     enum: INT64_MIN
 * 
 * cdef inline object get_value_at(ndarray arr, object loc):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, sz
 */

static CYTHON_INLINE PyObject *__pyx_f_4util_get_value_at(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_loc) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_sz;
  PyObject *__pyx_v_casted = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("get_value_at", 0);
  __Pyx_INCREF(__pyx_v_loc);

  /* "util.pxd":59
 *         Py_ssize_t i, sz
 *         void* data_ptr
 *     if is_float_object(loc):             # <<<<<<<<<<<<<<
 *         casted = int(loc)
 *         if casted == loc:
 */
  __pyx_t_1 = (is_float_object(__pyx_v_loc) != 0);
  if (__pyx_t_1) {

    /* "util.pxd":60
 *         void* data_ptr
 *     if is_float_object(loc):
 *         casted = int(loc)             # <<<<<<<<<<<<<<
 *         if casted == loc:
 *             loc = casted
 */
    __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_loc); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_casted = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "util.pxd":61
 *     if is_float_object(loc):
 *         casted = int(loc)
 *         if casted == loc:             # <<<<<<<<<<<<<<
 *             loc = casted
 *     i = <Py_ssize_t> loc
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_casted, __pyx_v_loc, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 61, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_1) {

      /* "util.pxd":62
 *         casted = int(loc)
 *         if casted == loc:
 *             loc = casted             # <<<<<<<<<<<<<<
 *     i = <Py_ssize_t> loc
 *     sz = cnp.PyArray_SIZE(arr)
 */
      __Pyx_INCREF(__pyx_v_casted);
      __Pyx_DECREF_SET(__pyx_v_loc, __pyx_v_casted);

      /* "util.pxd":61
 *     if is_float_object(loc):
 *         casted = int(loc)
 *         if casted == loc:             # <<<<<<<<<<<<<<
 *             loc = casted
 *     i = <Py_ssize_t> loc
 */
    }

    /* "util.pxd":59
 *         Py_ssize_t i, sz
 *         void* data_ptr
 *     if is_float_object(loc):             # <<<<<<<<<<<<<<
 *         casted = int(loc)
 *         if casted == loc:
 */
  }

  /* "util.pxd":63
 *         if casted == loc:
 *             loc = casted
 *     i = <Py_ssize_t> loc             # <<<<<<<<<<<<<<
 *     sz = cnp.PyArray_SIZE(arr)
 * 
 */
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loc); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 63, __pyx_L1_error)
  __pyx_v_i = ((Py_ssize_t)__pyx_t_3);

  /* "util.pxd":64
 *             loc = casted
 *     i = <Py_ssize_t> loc
 *     sz = cnp.PyArray_SIZE(arr)             # <<<<<<<<<<<<<<
 * 
 *     if i < 0 and sz > 0:
 */
  __pyx_v_sz = PyArray_SIZE(__pyx_v_arr);

  /* "util.pxd":66
 *     sz = cnp.PyArray_SIZE(arr)
 * 
 *     if i < 0 and sz > 0:             # <<<<<<<<<<<<<<
 *         i += sz
 *     elif i >= sz or sz == 0:
 */
  __pyx_t_4 = ((__pyx_v_i < 0) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_sz > 0) != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_1) {

    /* "util.pxd":67
 * 
 *     if i < 0 and sz > 0:
 *         i += sz             # <<<<<<<<<<<<<<
 *     elif i >= sz or sz == 0:
 *         raise IndexError('index out of bounds')
 */
    __pyx_v_i = (__pyx_v_i + __pyx_v_sz);

    /* "util.pxd":66
 *     sz = cnp.PyArray_SIZE(arr)
 * 
 *     if i < 0 and sz > 0:             # <<<<<<<<<<<<<<
 *         i += sz
 *     elif i >= sz or sz == 0:
 */
    goto __pyx_L5;
  }

  /* "util.pxd":68
 *     if i < 0 and sz > 0:
 *         i += sz
 *     elif i >= sz or sz == 0:             # <<<<<<<<<<<<<<
 *         raise IndexError('index out of bounds')
 * 
 */
  __pyx_t_4 = ((__pyx_v_i >= __pyx_v_sz) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_sz == 0) != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "util.pxd":69
 *         i += sz
 *     elif i >= sz or sz == 0:
 *         raise IndexError('index out of bounds')             # <<<<<<<<<<<<<<
 * 
 *     return get_value_1d(arr, i)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 69, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 69, __pyx_L1_error)

    /* "util.pxd":68
 *     if i < 0 and sz > 0:
 *         i += sz
 *     elif i >= sz or sz == 0:             # <<<<<<<<<<<<<<
 *         raise IndexError('index out of bounds')
 * 
 */
  }
  __pyx_L5:;

  /* "util.pxd":71
 *         raise IndexError('index out of bounds')
 * 
 *     return get_value_1d(arr, i)             # <<<<<<<<<<<<<<
 * 
 * cdef inline set_value_at_unsafe(ndarray arr, object loc, object value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = get_value_1d(__pyx_v_arr, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "util.pxd":55
 *     enum: INT64_MIN
 * 
 * cdef inline object get_value_at(ndarray arr, object loc):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, sz
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("util.get_value_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_casted);
  __Pyx_XDECREF(__pyx_v_loc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":73
 *     return get_value_1d(arr, i)
 * 
 * cdef inline set_value_at_unsafe(ndarray arr, object loc, object value):             # <<<<<<<<<<<<<<
 *     """Sets a value into the array without checking the writeable flag.
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_4util_set_value_at_unsafe(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_loc, PyObject *__pyx_v_value) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_sz;
  PyObject *__pyx_v_casted = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("set_value_at_unsafe", 0);
  __Pyx_INCREF(__pyx_v_loc);

  /* "util.pxd":81
 *     cdef:
 *         Py_ssize_t i, sz
 *     if is_float_object(loc):             # <<<<<<<<<<<<<<
 *         casted = int(loc)
 *         if casted == loc:
 */
  __pyx_t_1 = (is_float_object(__pyx_v_loc) != 0);
  if (__pyx_t_1) {

    /* "util.pxd":82
 *         Py_ssize_t i, sz
 *     if is_float_object(loc):
 *         casted = int(loc)             # <<<<<<<<<<<<<<
 *         if casted == loc:
 *             loc = casted
 */
    __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_loc); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 82, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_casted = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "util.pxd":83
 *     if is_float_object(loc):
 *         casted = int(loc)
 *         if casted == loc:             # <<<<<<<<<<<<<<
 *             loc = casted
 *     i = <Py_ssize_t> loc
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_casted, __pyx_v_loc, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 83, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 83, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_1) {

      /* "util.pxd":84
 *         casted = int(loc)
 *         if casted == loc:
 *             loc = casted             # <<<<<<<<<<<<<<
 *     i = <Py_ssize_t> loc
 *     sz = cnp.PyArray_SIZE(arr)
 */
      __Pyx_INCREF(__pyx_v_casted);
      __Pyx_DECREF_SET(__pyx_v_loc, __pyx_v_casted);

      /* "util.pxd":83
 *     if is_float_object(loc):
 *         casted = int(loc)
 *         if casted == loc:             # <<<<<<<<<<<<<<
 *             loc = casted
 *     i = <Py_ssize_t> loc
 */
    }

    /* "util.pxd":81
 *     cdef:
 *         Py_ssize_t i, sz
 *     if is_float_object(loc):             # <<<<<<<<<<<<<<
 *         casted = int(loc)
 *         if casted == loc:
 */
  }

  /* "util.pxd":85
 *         if casted == loc:
 *             loc = casted
 *     i = <Py_ssize_t> loc             # <<<<<<<<<<<<<<
 *     sz = cnp.PyArray_SIZE(arr)
 * 
 */
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_loc); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 85, __pyx_L1_error)
  __pyx_v_i = ((Py_ssize_t)__pyx_t_3);

  /* "util.pxd":86
 *             loc = casted
 *     i = <Py_ssize_t> loc
 *     sz = cnp.PyArray_SIZE(arr)             # <<<<<<<<<<<<<<
 * 
 *     if i < 0:
 */
  __pyx_v_sz = PyArray_SIZE(__pyx_v_arr);

  /* "util.pxd":88
 *     sz = cnp.PyArray_SIZE(arr)
 * 
 *     if i < 0:             # <<<<<<<<<<<<<<
 *         i += sz
 *     elif i >= sz:
 */
  __pyx_t_1 = ((__pyx_v_i < 0) != 0);
  if (__pyx_t_1) {

    /* "util.pxd":89
 * 
 *     if i < 0:
 *         i += sz             # <<<<<<<<<<<<<<
 *     elif i >= sz:
 *         raise IndexError('index out of bounds')
 */
    __pyx_v_i = (__pyx_v_i + __pyx_v_sz);

    /* "util.pxd":88
 *     sz = cnp.PyArray_SIZE(arr)
 * 
 *     if i < 0:             # <<<<<<<<<<<<<<
 *         i += sz
 *     elif i >= sz:
 */
    goto __pyx_L5;
  }

  /* "util.pxd":90
 *     if i < 0:
 *         i += sz
 *     elif i >= sz:             # <<<<<<<<<<<<<<
 *         raise IndexError('index out of bounds')
 * 
 */
  __pyx_t_1 = ((__pyx_v_i >= __pyx_v_sz) != 0);
  if (__pyx_t_1) {

    /* "util.pxd":91
 *         i += sz
 *     elif i >= sz:
 *         raise IndexError('index out of bounds')             # <<<<<<<<<<<<<<
 * 
 *     assign_value_1d(arr, i, value)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 91, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 91, __pyx_L1_error)

    /* "util.pxd":90
 *     if i < 0:
 *         i += sz
 *     elif i >= sz:             # <<<<<<<<<<<<<<
 *         raise IndexError('index out of bounds')
 * 
 */
  }
  __pyx_L5:;

  /* "util.pxd":93
 *         raise IndexError('index out of bounds')
 * 
 *     assign_value_1d(arr, i, value)             # <<<<<<<<<<<<<<
 * 
 * cdef inline set_value_at(ndarray arr, object loc, object value):
 */
  __pyx_t_4 = assign_value_1d(__pyx_v_arr, __pyx_v_i, __pyx_v_value); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 93, __pyx_L1_error)

  /* "util.pxd":73
 *     return get_value_1d(arr, i)
 * 
 * cdef inline set_value_at_unsafe(ndarray arr, object loc, object value):             # <<<<<<<<<<<<<<
 *     """Sets a value into the array without checking the writeable flag.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("util.set_value_at_unsafe", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_casted);
  __Pyx_XDECREF(__pyx_v_loc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":95
 *     assign_value_1d(arr, i, value)
 * 
 * cdef inline set_value_at(ndarray arr, object loc, object value):             # <<<<<<<<<<<<<<
 *     """Sets a value into the array after checking that the array is mutable.
 *     """
 */

static CYTHON_INLINE PyObject *__pyx_f_4util_set_value_at(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_loc, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("set_value_at", 0);

  /* "util.pxd":98
 *     """Sets a value into the array after checking that the array is mutable.
 *     """
 *     if not cnp.PyArray_ISWRITEABLE(arr):             # <<<<<<<<<<<<<<
 *         raise ValueError('assignment destination is read-only')
 * 
 */
  __pyx_t_1 = ((!(PyArray_ISWRITEABLE(__pyx_v_arr) != 0)) != 0);
  if (__pyx_t_1) {

    /* "util.pxd":99
 *     """
 *     if not cnp.PyArray_ISWRITEABLE(arr):
 *         raise ValueError('assignment destination is read-only')             # <<<<<<<<<<<<<<
 * 
 *     set_value_at_unsafe(arr, loc, value)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 99, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 99, __pyx_L1_error)

    /* "util.pxd":98
 *     """Sets a value into the array after checking that the array is mutable.
 *     """
 *     if not cnp.PyArray_ISWRITEABLE(arr):             # <<<<<<<<<<<<<<
 *         raise ValueError('assignment destination is read-only')
 * 
 */
  }

  /* "util.pxd":101
 *         raise ValueError('assignment destination is read-only')
 * 
 *     set_value_at_unsafe(arr, loc, value)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int is_contiguous(ndarray arr):
 */
  __pyx_t_2 = __pyx_f_4util_set_value_at_unsafe(__pyx_v_arr, __pyx_v_loc, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "util.pxd":95
 *     assign_value_1d(arr, i, value)
 * 
 * cdef inline set_value_at(ndarray arr, object loc, object value):             # <<<<<<<<<<<<<<
 *     """Sets a value into the array after checking that the array is mutable.
 *     """
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("util.set_value_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":103
 *     set_value_at_unsafe(arr, loc, value)
 * 
 * cdef inline int is_contiguous(ndarray arr):             # <<<<<<<<<<<<<<
 *     return cnp.PyArray_CHKFLAGS(arr, cnp.NPY_C_CONTIGUOUS)
 * 
 */

static CYTHON_INLINE int __pyx_f_4util_is_contiguous(PyArrayObject *__pyx_v_arr) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_contiguous", 0);

  /* "util.pxd":104
 * 
 * cdef inline int is_contiguous(ndarray arr):
 *     return cnp.PyArray_CHKFLAGS(arr, cnp.NPY_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 * 
 * cdef inline is_array(object o):
 */
  __pyx_r = PyArray_CHKFLAGS(__pyx_v_arr, NPY_C_CONTIGUOUS);
  goto __pyx_L0;

  /* "util.pxd":103
 *     set_value_at_unsafe(arr, loc, value)
 * 
 * cdef inline int is_contiguous(ndarray arr):             # <<<<<<<<<<<<<<
 *     return cnp.PyArray_CHKFLAGS(arr, cnp.NPY_C_CONTIGUOUS)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":106
 *     return cnp.PyArray_CHKFLAGS(arr, cnp.NPY_C_CONTIGUOUS)
 * 
 * cdef inline is_array(object o):             # <<<<<<<<<<<<<<
 *     return cnp.PyArray_Check(o)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_4util_is_array(PyObject *__pyx_v_o) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("is_array", 0);

  /* "util.pxd":107
 * 
 * cdef inline is_array(object o):
 *     return cnp.PyArray_Check(o)             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint _checknull(object val):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(PyArray_Check(__pyx_v_o)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "util.pxd":106
 *     return cnp.PyArray_CHKFLAGS(arr, cnp.NPY_C_CONTIGUOUS)
 * 
 * cdef inline is_array(object o):             # <<<<<<<<<<<<<<
 *     return cnp.PyArray_Check(o)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("util.is_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":109
 *     return cnp.PyArray_Check(o)
 * 
 * cdef inline bint _checknull(object val):             # <<<<<<<<<<<<<<
 *     try:
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)
 */

static CYTHON_INLINE int __pyx_f_4util__checknull(PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("_checknull", 0);

  /* "util.pxd":110
 * 
 * cdef inline bint _checknull(object val):
 *     try:             # <<<<<<<<<<<<<<
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)
 *     except ValueError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "util.pxd":111
 * cdef inline bint _checknull(object val):
 *     try:
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)             # <<<<<<<<<<<<<<
 *     except ValueError:
 *         return False
 */
      __pyx_t_5 = (__pyx_v_val == Py_None);
      __pyx_t_6 = (__pyx_t_5 != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_6 = (PyFloat_Check(__pyx_v_val) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 111, __pyx_L3_error)
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 111, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_4 = __pyx_t_6;
      __pyx_L11_bool_binop_done:;
      __pyx_r = __pyx_t_4;
      goto __pyx_L7_try_return;

      /* "util.pxd":110
 * 
 * cdef inline bint _checknull(object val):
 *     try:             # <<<<<<<<<<<<<<
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)
 *     except ValueError:
 */
    }
    __pyx_L3_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "util.pxd":112
 *     try:
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)
 *     except ValueError:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
    __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_8) {
      __Pyx_AddTraceback("util._checknull", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(1, 112, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_10);

      /* "util.pxd":113
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)
 *     except ValueError:
 *         return False             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint _checknull_old(object val):
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "util.pxd":110
 * 
 * cdef inline bint _checknull(object val):
 *     try:             # <<<<<<<<<<<<<<
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)
 *     except ValueError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "util.pxd":109
 *     return cnp.PyArray_Check(o)
 * 
 * cdef inline bint _checknull(object val):             # <<<<<<<<<<<<<<
 *     try:
 *         return val is None or (cpython.PyFloat_Check(val) and val != val)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("util._checknull", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":115
 *         return False
 * 
 * cdef inline bint _checknull_old(object val):             # <<<<<<<<<<<<<<
 *     import numpy as np
 *     cdef double INF = <double> np.inf
 */

static CYTHON_INLINE int __pyx_f_4util__checknull_old(PyObject *__pyx_v_val) {
  PyObject *__pyx_v_np = NULL;
  double __pyx_v_INF;
  double __pyx_v_NEGINF;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  double __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_checknull_old", 0);

  /* "util.pxd":116
 * 
 * cdef inline bint _checknull_old(object val):
 *     import numpy as np             # <<<<<<<<<<<<<<
 *     cdef double INF = <double> np.inf
 *     cdef double NEGINF = -INF
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_np = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "util.pxd":117
 * cdef inline bint _checknull_old(object val):
 *     import numpy as np
 *     cdef double INF = <double> np.inf             # <<<<<<<<<<<<<<
 *     cdef double NEGINF = -INF
 *     try:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_np, __pyx_n_s_inf); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 117, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_INF = ((double)__pyx_t_2);

  /* "util.pxd":118
 *     import numpy as np
 *     cdef double INF = <double> np.inf
 *     cdef double NEGINF = -INF             # <<<<<<<<<<<<<<
 *     try:
 *         return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))
 */
  __pyx_v_NEGINF = (-__pyx_v_INF);

  /* "util.pxd":119
 *     cdef double INF = <double> np.inf
 *     cdef double NEGINF = -INF
 *     try:             # <<<<<<<<<<<<<<
 *         return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))
 *     except ValueError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "util.pxd":120
 *     cdef double NEGINF = -INF
 *     try:
 *         return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))             # <<<<<<<<<<<<<<
 *     except ValueError:
 *         return False
 */
      __pyx_t_7 = (__pyx_v_val == Py_None);
      __pyx_t_8 = (__pyx_t_7 != 0);
      if (!__pyx_t_8) {
      } else {
        __pyx_t_6 = __pyx_t_8;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_8 = (PyFloat_Check(__pyx_v_val) != 0);
      if (__pyx_t_8) {
      } else {
        __pyx_t_6 = __pyx_t_8;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 120, __pyx_L3_error)
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 120, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!__pyx_t_8) {
      } else {
        __pyx_t_6 = __pyx_t_8;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_INF); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 120, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = PyObject_RichCompare(__pyx_v_val, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 120, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 120, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (!__pyx_t_8) {
      } else {
        __pyx_t_6 = __pyx_t_8;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_NEGINF); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 120, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_val, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 120, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 120, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_t_8;
      __pyx_L11_bool_binop_done:;
      __pyx_r = __pyx_t_6;
      goto __pyx_L7_try_return;

      /* "util.pxd":119
 *     cdef double INF = <double> np.inf
 *     cdef double NEGINF = -INF
 *     try:             # <<<<<<<<<<<<<<
 *         return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))
 *     except ValueError:
 */
    }
    __pyx_L3_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "util.pxd":121
 *     try:
 *         return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))
 *     except ValueError:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("util._checknull_old", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_11) < 0) __PYX_ERR(1, 121, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_11);

      /* "util.pxd":122
 *         return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))
 *     except ValueError:
 *         return False             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint _checknan(object val):
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "util.pxd":119
 *     cdef double INF = <double> np.inf
 *     cdef double NEGINF = -INF
 *     try:             # <<<<<<<<<<<<<<
 *         return val is None or (cpython.PyFloat_Check(val) and (val != val or val == INF or val == NEGINF))
 *     except ValueError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
  }

  /* "util.pxd":115
 *         return False
 * 
 * cdef inline bint _checknull_old(object val):             # <<<<<<<<<<<<<<
 *     import numpy as np
 *     cdef double INF = <double> np.inf
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_WriteUnraisable("util._checknull_old", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_np);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":124
 *         return False
 * 
 * cdef inline bint _checknan(object val):             # <<<<<<<<<<<<<<
 *     return not cnp.PyArray_Check(val) and val != val
 * 
 */

static CYTHON_INLINE int __pyx_f_4util__checknan(PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_checknan", 0);

  /* "util.pxd":125
 * 
 * cdef inline bint _checknan(object val):
 *     return not cnp.PyArray_Check(val) and val != val             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint is_period_object(object val):
 */
  __pyx_t_2 = ((!(PyArray_Check(__pyx_v_val) != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_val, __pyx_v_val, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 125, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 125, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "util.pxd":124
 *         return False
 * 
 * cdef inline bint _checknan(object val):             # <<<<<<<<<<<<<<
 *     return not cnp.PyArray_Check(val) and val != val
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("util._checknan", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "util.pxd":127
 *     return not cnp.PyArray_Check(val) and val != val
 * 
 * cdef inline bint is_period_object(object val):             # <<<<<<<<<<<<<<
 *     return getattr(val, '_typ', '_typ') == 'period'
 */

static CYTHON_INLINE int __pyx_f_4util_is_period_object(PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("is_period_object", 0);

  /* "util.pxd":128
 * 
 * cdef inline bint is_period_object(object val):
 *     return getattr(val, '_typ', '_typ') == 'period'             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_val, __pyx_n_s_typ, __pyx_n_s_typ); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_n_s_period, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 128, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 128, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "util.pxd":127
 *     return not cnp.PyArray_Check(val) and val != val
 * 
 * cdef inline bint is_period_object(object val):             # <<<<<<<<<<<<<<
 *     return getattr(val, '_typ', '_typ') == 'period'
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_WriteUnraisable("util.is_period_object", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "datetime.pxd":126
 * 
 * 
 * cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts,             # <<<<<<<<<<<<<<
 *                            int* out_local, int* out_tzoffset) except? -1:
 *     cdef int result
 */

static CYTHON_INLINE int __pyx_f_8datetime__string_to_dts(PyObject *__pyx_v_val, pandas_datetimestruct *__pyx_v_dts, int *__pyx_v_out_local, int *__pyx_v_out_tzoffset) {
  int __pyx_v_result;
  char *__pyx_v_tmp;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_string_to_dts", 0);
  __Pyx_INCREF(__pyx_v_val);

  /* "datetime.pxd":131
 *     cdef char *tmp
 * 
 *     if PyUnicode_Check(val):             # <<<<<<<<<<<<<<
 *         val = PyUnicode_AsASCIIString(val);
 * 
 */
  __pyx_t_1 = (PyUnicode_Check(__pyx_v_val) != 0);
  if (__pyx_t_1) {

    /* "datetime.pxd":132
 * 
 *     if PyUnicode_Check(val):
 *         val = PyUnicode_AsASCIIString(val);             # <<<<<<<<<<<<<<
 * 
 *     tmp = val
 */
    __pyx_t_2 = PyUnicode_AsASCIIString(__pyx_v_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 132, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_val, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "datetime.pxd":131
 *     cdef char *tmp
 * 
 *     if PyUnicode_Check(val):             # <<<<<<<<<<<<<<
 *         val = PyUnicode_AsASCIIString(val);
 * 
 */
  }

  /* "datetime.pxd":134
 *         val = PyUnicode_AsASCIIString(val);
 * 
 *     tmp = val             # <<<<<<<<<<<<<<
 *     result = _cstring_to_dts(tmp, len(val), dts, out_local, out_tzoffset)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_val); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(2, 134, __pyx_L1_error)
  __pyx_v_tmp = __pyx_t_3;

  /* "datetime.pxd":135
 * 
 *     tmp = val
 *     result = _cstring_to_dts(tmp, len(val), dts, out_local, out_tzoffset)             # <<<<<<<<<<<<<<
 * 
 *     if result == -1:
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_val); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 135, __pyx_L1_error)
  __pyx_t_5 = __pyx_f_8datetime__cstring_to_dts(__pyx_v_tmp, __pyx_t_4, __pyx_v_dts, __pyx_v_out_local, __pyx_v_out_tzoffset); if (unlikely(__pyx_t_5 == -1 && PyErr_Occurred())) __PYX_ERR(2, 135, __pyx_L1_error)
  __pyx_v_result = __pyx_t_5;

  /* "datetime.pxd":137
 *     result = _cstring_to_dts(tmp, len(val), dts, out_local, out_tzoffset)
 * 
 *     if result == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unable to parse %s' % str(val))
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result == -1L) != 0);
  if (__pyx_t_1) {

    /* "datetime.pxd":138
 * 
 *     if result == -1:
 *         raise ValueError('Unable to parse %s' % str(val))             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_val);
    __Pyx_GIVEREF(__pyx_v_val);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_val);
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Unable_to_parse_s, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(2, 138, __pyx_L1_error)

    /* "datetime.pxd":137
 *     result = _cstring_to_dts(tmp, len(val), dts, out_local, out_tzoffset)
 * 
 *     if result == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError('Unable to parse %s' % str(val))
 *     return result
 */
  }

  /* "datetime.pxd":139
 *     if result == -1:
 *         raise ValueError('Unable to parse %s' % str(val))
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _cstring_to_dts(char *val, int length,
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "datetime.pxd":126
 * 
 * 
 * cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts,             # <<<<<<<<<<<<<<
 *                            int* out_local, int* out_tzoffset) except? -1:
 *     cdef int result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("datetime._string_to_dts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "datetime.pxd":141
 *     return result
 * 
 * cdef inline int _cstring_to_dts(char *val, int length,             # <<<<<<<<<<<<<<
 *                                 pandas_datetimestruct* dts,
 *                                 int* out_local, int* out_tzoffset) except? -1:
 */

static CYTHON_INLINE int __pyx_f_8datetime__cstring_to_dts(char *__pyx_v_val, int __pyx_v_length, pandas_datetimestruct *__pyx_v_dts, int *__pyx_v_out_local, int *__pyx_v_out_tzoffset) {
  npy_bool __pyx_v_special;
  PANDAS_DATETIMEUNIT __pyx_v_out_bestunit;
  int __pyx_v_result;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_cstring_to_dts", 0);

  /* "datetime.pxd":149
 *         int result
 * 
 *     result = parse_iso_8601_datetime(val, length, PANDAS_FR_ns,             # <<<<<<<<<<<<<<
 *                                      NPY_UNSAFE_CASTING,
 *                                      dts, out_local, out_tzoffset, &out_bestunit, &special)
 */
  __pyx_v_result = parse_iso_8601_datetime(__pyx_v_val, __pyx_v_length, PANDAS_FR_ns, NPY_UNSAFE_CASTING, __pyx_v_dts, __pyx_v_out_local, __pyx_v_out_tzoffset, (&__pyx_v_out_bestunit), (&__pyx_v_special));

  /* "datetime.pxd":152
 *                                      NPY_UNSAFE_CASTING,
 *                                      dts, out_local, out_tzoffset, &out_bestunit, &special)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "datetime.pxd":141
 *     return result
 * 
 * cdef inline int _cstring_to_dts(char *val, int length,             # <<<<<<<<<<<<<<
 *                                 pandas_datetimestruct* dts,
 *                                 int* out_local, int* out_tzoffset) except? -1:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "datetime.pxd":155
 * 
 * 
 * cdef inline object _datetime64_to_datetime(int64_t val):             # <<<<<<<<<<<<<<
 *     cdef pandas_datetimestruct dts
 *     pandas_datetime_to_datetimestruct(val, PANDAS_FR_ns, &dts)
 */

static CYTHON_INLINE PyObject *__pyx_f_8datetime__datetime64_to_datetime(__pyx_t_5numpy_int64_t __pyx_v_val) {
  pandas_datetimestruct __pyx_v_dts;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_datetime64_to_datetime", 0);

  /* "datetime.pxd":157
 * cdef inline object _datetime64_to_datetime(int64_t val):
 *     cdef pandas_datetimestruct dts
 *     pandas_datetime_to_datetimestruct(val, PANDAS_FR_ns, &dts)             # <<<<<<<<<<<<<<
 *     return _dts_to_pydatetime(&dts)
 * 
 */
  pandas_datetime_to_datetimestruct(__pyx_v_val, PANDAS_FR_ns, (&__pyx_v_dts));

  /* "datetime.pxd":158
 *     cdef pandas_datetimestruct dts
 *     pandas_datetime_to_datetimestruct(val, PANDAS_FR_ns, &dts)
 *     return _dts_to_pydatetime(&dts)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object _dts_to_pydatetime(pandas_datetimestruct *dts):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_8datetime__dts_to_pydatetime((&__pyx_v_dts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "datetime.pxd":155
 * 
 * 
 * cdef inline object _datetime64_to_datetime(int64_t val):             # <<<<<<<<<<<<<<
 *     cdef pandas_datetimestruct dts
 *     pandas_datetime_to_datetimestruct(val, PANDAS_FR_ns, &dts)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("datetime._datetime64_to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "datetime.pxd":160
 *     return _dts_to_pydatetime(&dts)
 * 
 * cdef inline object _dts_to_pydatetime(pandas_datetimestruct *dts):             # <<<<<<<<<<<<<<
 *     return <object> PyDateTime_FromDateAndTime(dts.year, dts.month,
 *                                                dts.day, dts.hour,
 */

static CYTHON_INLINE PyObject *__pyx_f_8datetime__dts_to_pydatetime(pandas_datetimestruct *__pyx_v_dts) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_dts_to_pydatetime", 0);

  /* "datetime.pxd":161
 * 
 * cdef inline object _dts_to_pydatetime(pandas_datetimestruct *dts):
 *     return <object> PyDateTime_FromDateAndTime(dts.year, dts.month,             # <<<<<<<<<<<<<<
 *                                                dts.day, dts.hour,
 *                                                dts.min, dts.sec, dts.us)
 */
  __Pyx_XDECREF(__pyx_r);

  /* "datetime.pxd":163
 *     return <object> PyDateTime_FromDateAndTime(dts.year, dts.month,
 *                                                dts.day, dts.hour,
 *                                                dts.min, dts.sec, dts.us)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int64_t _pydatetime_to_dts(object val, pandas_datetimestruct *dts):
 */
  __pyx_t_1 = PyDateTime_FromDateAndTime(__pyx_v_dts->year, __pyx_v_dts->month, __pyx_v_dts->day, __pyx_v_dts->hour, __pyx_v_dts->min, __pyx_v_dts->sec, __pyx_v_dts->us); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "datetime.pxd":161
 * 
 * cdef inline object _dts_to_pydatetime(pandas_datetimestruct *dts):
 *     return <object> PyDateTime_FromDateAndTime(dts.year, dts.month,             # <<<<<<<<<<<<<<
 *                                                dts.day, dts.hour,
 *                                                dts.min, dts.sec, dts.us)
 */
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  __pyx_r = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "datetime.pxd":160
 *     return _dts_to_pydatetime(&dts)
 * 
 * cdef inline object _dts_to_pydatetime(pandas_datetimestruct *dts):             # <<<<<<<<<<<<<<
 *     return <object> PyDateTime_FromDateAndTime(dts.year, dts.month,
 *                                                dts.day, dts.hour,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("datetime._dts_to_pydatetime", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "datetime.pxd":165
 *                                                dts.min, dts.sec, dts.us)
 * 
 * cdef inline int64_t _pydatetime_to_dts(object val, pandas_datetimestruct *dts):             # <<<<<<<<<<<<<<
 *     dts.year = PyDateTime_GET_YEAR(val)
 *     dts.month = PyDateTime_GET_MONTH(val)
 */

static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_8datetime__pydatetime_to_dts(PyObject *__pyx_v_val, pandas_datetimestruct *__pyx_v_dts) {
  __pyx_t_5numpy_int64_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_pydatetime_to_dts", 0);

  /* "datetime.pxd":166
 * 
 * cdef inline int64_t _pydatetime_to_dts(object val, pandas_datetimestruct *dts):
 *     dts.year = PyDateTime_GET_YEAR(val)             # <<<<<<<<<<<<<<
 *     dts.month = PyDateTime_GET_MONTH(val)
 *     dts.day = PyDateTime_GET_DAY(val)
 */
  if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_8datetime_date))))) __PYX_ERR(2, 166, __pyx_L1_error)
  __pyx_v_dts->year = PyDateTime_GET_YEAR(((PyDateTime_Date *)__pyx_v_val));

  /* "datetime.pxd":167
 * cdef inline int64_t _pydatetime_to_dts(object val, pandas_datetimestruct *dts):
 *     dts.year = PyDateTime_GET_YEAR(val)
 *     dts.month = PyDateTime_GET_MONTH(val)             # <<<<<<<<<<<<<<
 *     dts.day = PyDateTime_GET_DAY(val)
 *     dts.hour = PyDateTime_DATE_GET_HOUR(val)
 */
  if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_8datetime_date))))) __PYX_ERR(2, 167, __pyx_L1_error)
  __pyx_v_dts->month = PyDateTime_GET_MONTH(((PyDateTime_Date *)__pyx_v_val));

  /* "datetime.pxd":168
 *     dts.year = PyDateTime_GET_YEAR(val)
 *     dts.month = PyDateTime_GET_MONTH(val)
 *     dts.day = PyDateTime_GET_DAY(val)             # <<<<<<<<<<<<<<
 *     dts.hour = PyDateTime_DATE_GET_HOUR(val)
 *     dts.min = PyDateTime_DATE_GET_MINUTE(val)
 */
  if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_8datetime_date))))) __PYX_ERR(2, 168, __pyx_L1_error)
  __pyx_v_dts->day = PyDateTime_GET_DAY(((PyDateTime_Date *)__pyx_v_val));

  /* "datetime.pxd":169
 *     dts.month = PyDateTime_GET_MONTH(val)
 *     dts.day = PyDateTime_GET_DAY(val)
 *     dts.hour = PyDateTime_DATE_GET_HOUR(val)             # <<<<<<<<<<<<<<
 *     dts.min = PyDateTime_DATE_GET_MINUTE(val)
 *     dts.sec = PyDateTime_DATE_GET_SECOND(val)
 */
  __pyx_v_dts->hour = PyDateTime_DATE_GET_HOUR(__pyx_v_val);

  /* "datetime.pxd":170
 *     dts.day = PyDateTime_GET_DAY(val)
 *     dts.hour = PyDateTime_DATE_GET_HOUR(val)
 *     dts.min = PyDateTime_DATE_GET_MINUTE(val)             # <<<<<<<<<<<<<<
 *     dts.sec = PyDateTime_DATE_GET_SECOND(val)
 *     dts.us = PyDateTime_DATE_GET_MICROSECOND(val)
 */
  __pyx_v_dts->min = PyDateTime_DATE_GET_MINUTE(__pyx_v_val);

  /* "datetime.pxd":171
 *     dts.hour = PyDateTime_DATE_GET_HOUR(val)
 *     dts.min = PyDateTime_DATE_GET_MINUTE(val)
 *     dts.sec = PyDateTime_DATE_GET_SECOND(val)             # <<<<<<<<<<<<<<
 *     dts.us = PyDateTime_DATE_GET_MICROSECOND(val)
 *     dts.ps = dts.as = 0
 */
  __pyx_v_dts->sec = PyDateTime_DATE_GET_SECOND(__pyx_v_val);

  /* "datetime.pxd":172
 *     dts.min = PyDateTime_DATE_GET_MINUTE(val)
 *     dts.sec = PyDateTime_DATE_GET_SECOND(val)
 *     dts.us = PyDateTime_DATE_GET_MICROSECOND(val)             # <<<<<<<<<<<<<<
 *     dts.ps = dts.as = 0
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 */
  __pyx_v_dts->us = PyDateTime_DATE_GET_MICROSECOND(__pyx_v_val);

  /* "datetime.pxd":173
 *     dts.sec = PyDateTime_DATE_GET_SECOND(val)
 *     dts.us = PyDateTime_DATE_GET_MICROSECOND(val)
 *     dts.ps = dts.as = 0             # <<<<<<<<<<<<<<
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 * 
 */
  __pyx_v_dts->ps = 0;
  __pyx_v_dts->as = 0;

  /* "datetime.pxd":174
 *     dts.us = PyDateTime_DATE_GET_MICROSECOND(val)
 *     dts.ps = dts.as = 0
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int64_t _dtlike_to_datetime64(object val,
 */
  __pyx_r = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, __pyx_v_dts);
  goto __pyx_L0;

  /* "datetime.pxd":165
 *                                                dts.min, dts.sec, dts.us)
 * 
 * cdef inline int64_t _pydatetime_to_dts(object val, pandas_datetimestruct *dts):             # <<<<<<<<<<<<<<
 *     dts.year = PyDateTime_GET_YEAR(val)
 *     dts.month = PyDateTime_GET_MONTH(val)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("datetime._pydatetime_to_dts", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "datetime.pxd":176
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 * 
 * cdef inline int64_t _dtlike_to_datetime64(object val,             # <<<<<<<<<<<<<<
 *                                           pandas_datetimestruct *dts):
 *     dts.year = val.year
 */

static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_8datetime__dtlike_to_datetime64(PyObject *__pyx_v_val, pandas_datetimestruct *__pyx_v_dts) {
  __pyx_t_5numpy_int64_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  npy_int64 __pyx_t_2;
  npy_int32 __pyx_t_3;
  __Pyx_RefNannySetupContext("_dtlike_to_datetime64", 0);

  /* "datetime.pxd":178
 * cdef inline int64_t _dtlike_to_datetime64(object val,
 *                                           pandas_datetimestruct *dts):
 *     dts.year = val.year             # <<<<<<<<<<<<<<
 *     dts.month = val.month
 *     dts.day = val.day
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_year); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_npy_int64(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_int64)-1) && PyErr_Occurred())) __PYX_ERR(2, 178, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dts->year = __pyx_t_2;

  /* "datetime.pxd":179
 *                                           pandas_datetimestruct *dts):
 *     dts.year = val.year
 *     dts.month = val.month             # <<<<<<<<<<<<<<
 *     dts.day = val.day
 *     dts.hour = val.hour
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_month); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_int32)-1) && PyErr_Occurred())) __PYX_ERR(2, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dts->month = __pyx_t_3;

  /* "datetime.pxd":180
 *     dts.year = val.year
 *     dts.month = val.month
 *     dts.day = val.day             # <<<<<<<<<<<<<<
 *     dts.hour = val.hour
 *     dts.min = val.minute
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_day); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_int32)-1) && PyErr_Occurred())) __PYX_ERR(2, 180, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dts->day = __pyx_t_3;

  /* "datetime.pxd":181
 *     dts.month = val.month
 *     dts.day = val.day
 *     dts.hour = val.hour             # <<<<<<<<<<<<<<
 *     dts.min = val.minute
 *     dts.sec = val.second
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_hour); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_int32)-1) && PyErr_Occurred())) __PYX_ERR(2, 181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dts->hour = __pyx_t_3;

  /* "datetime.pxd":182
 *     dts.day = val.day
 *     dts.hour = val.hour
 *     dts.min = val.minute             # <<<<<<<<<<<<<<
 *     dts.sec = val.second
 *     dts.us = val.microsecond
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_int32)-1) && PyErr_Occurred())) __PYX_ERR(2, 182, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dts->min = __pyx_t_3;

  /* "datetime.pxd":183
 *     dts.hour = val.hour
 *     dts.min = val.minute
 *     dts.sec = val.second             # <<<<<<<<<<<<<<
 *     dts.us = val.microsecond
 *     dts.ps = dts.as = 0
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_second); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_int32)-1) && PyErr_Occurred())) __PYX_ERR(2, 183, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dts->sec = __pyx_t_3;

  /* "datetime.pxd":184
 *     dts.min = val.minute
 *     dts.sec = val.second
 *     dts.us = val.microsecond             # <<<<<<<<<<<<<<
 *     dts.ps = dts.as = 0
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_val, __pyx_n_s_microsecond); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_int32)-1) && PyErr_Occurred())) __PYX_ERR(2, 184, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dts->us = __pyx_t_3;

  /* "datetime.pxd":185
 *     dts.sec = val.second
 *     dts.us = val.microsecond
 *     dts.ps = dts.as = 0             # <<<<<<<<<<<<<<
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 * 
 */
  __pyx_v_dts->ps = 0;
  __pyx_v_dts->as = 0;

  /* "datetime.pxd":186
 *     dts.us = val.microsecond
 *     dts.ps = dts.as = 0
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int64_t _date_to_datetime64(object val,
 */
  __pyx_r = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, __pyx_v_dts);
  goto __pyx_L0;

  /* "datetime.pxd":176
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 * 
 * cdef inline int64_t _dtlike_to_datetime64(object val,             # <<<<<<<<<<<<<<
 *                                           pandas_datetimestruct *dts):
 *     dts.year = val.year
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_WriteUnraisable("datetime._dtlike_to_datetime64", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "datetime.pxd":188
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 * 
 * cdef inline int64_t _date_to_datetime64(object val,             # <<<<<<<<<<<<<<
 *                                         pandas_datetimestruct *dts):
 *     dts.year = PyDateTime_GET_YEAR(val)
 */

static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_8datetime__date_to_datetime64(PyObject *__pyx_v_val, pandas_datetimestruct *__pyx_v_dts) {
  __pyx_t_5numpy_int64_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_date_to_datetime64", 0);

  /* "datetime.pxd":190
 * cdef inline int64_t _date_to_datetime64(object val,
 *                                         pandas_datetimestruct *dts):
 *     dts.year = PyDateTime_GET_YEAR(val)             # <<<<<<<<<<<<<<
 *     dts.month = PyDateTime_GET_MONTH(val)
 *     dts.day = PyDateTime_GET_DAY(val)
 */
  if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_8datetime_date))))) __PYX_ERR(2, 190, __pyx_L1_error)
  __pyx_v_dts->year = PyDateTime_GET_YEAR(((PyDateTime_Date *)__pyx_v_val));

  /* "datetime.pxd":191
 *                                         pandas_datetimestruct *dts):
 *     dts.year = PyDateTime_GET_YEAR(val)
 *     dts.month = PyDateTime_GET_MONTH(val)             # <<<<<<<<<<<<<<
 *     dts.day = PyDateTime_GET_DAY(val)
 *     dts.hour = dts.min = dts.sec = dts.us = 0
 */
  if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_8datetime_date))))) __PYX_ERR(2, 191, __pyx_L1_error)
  __pyx_v_dts->month = PyDateTime_GET_MONTH(((PyDateTime_Date *)__pyx_v_val));

  /* "datetime.pxd":192
 *     dts.year = PyDateTime_GET_YEAR(val)
 *     dts.month = PyDateTime_GET_MONTH(val)
 *     dts.day = PyDateTime_GET_DAY(val)             # <<<<<<<<<<<<<<
 *     dts.hour = dts.min = dts.sec = dts.us = 0
 *     dts.ps = dts.as = 0
 */
  if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_8datetime_date))))) __PYX_ERR(2, 192, __pyx_L1_error)
  __pyx_v_dts->day = PyDateTime_GET_DAY(((PyDateTime_Date *)__pyx_v_val));

  /* "datetime.pxd":193
 *     dts.month = PyDateTime_GET_MONTH(val)
 *     dts.day = PyDateTime_GET_DAY(val)
 *     dts.hour = dts.min = dts.sec = dts.us = 0             # <<<<<<<<<<<<<<
 *     dts.ps = dts.as = 0
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 */
  __pyx_v_dts->hour = 0;
  __pyx_v_dts->min = 0;
  __pyx_v_dts->sec = 0;
  __pyx_v_dts->us = 0;

  /* "datetime.pxd":194
 *     dts.day = PyDateTime_GET_DAY(val)
 *     dts.hour = dts.min = dts.sec = dts.us = 0
 *     dts.ps = dts.as = 0             # <<<<<<<<<<<<<<
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 */
  __pyx_v_dts->ps = 0;
  __pyx_v_dts->as = 0;

  /* "datetime.pxd":195
 *     dts.hour = dts.min = dts.sec = dts.us = 0
 *     dts.ps = dts.as = 0
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)             # <<<<<<<<<<<<<<
 */
  __pyx_r = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, __pyx_v_dts);
  goto __pyx_L0;

  /* "datetime.pxd":188
 *     return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
 * 
 * cdef inline int64_t _date_to_datetime64(object val,             # <<<<<<<<<<<<<<
 *                                         pandas_datetimestruct *dts):
 *     dts.year = PyDateTime_GET_YEAR(val)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("datetime._date_to_datetime64", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":196
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_copy_shape;
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  int __pyx_v_offset;
  int __pyx_v_hasfields;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "numpy.pxd":202
 *             # of flags
 * 
 *             if info == NULL: return             # <<<<<<<<<<<<<<
 * 
 *             cdef int copy_shape, i, ndim
 */
  __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "numpy.pxd":205
 * 
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 */
  __pyx_v_endian_detector = 1;

  /* "numpy.pxd":206
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 * 
 *             ndim = PyArray_NDIM(self)
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "numpy.pxd":208
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);

  /* "numpy.pxd":210
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "numpy.pxd":211
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;

    /* "numpy.pxd":210
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
    goto __pyx_L4;
  }

  /* "numpy.pxd":213
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
  /*else*/ {
    __pyx_v_copy_shape = 0;
  }
  __pyx_L4:;

  /* "numpy.pxd":215
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }

  /* "numpy.pxd":216
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;

  /* "numpy.pxd":215
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  if (__pyx_t_1) {

    /* "numpy.pxd":217
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(3, 217, __pyx_L1_error)

    /* "numpy.pxd":215
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  }

  /* "numpy.pxd":219
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L9_bool_binop_done;
  }

  /* "numpy.pxd":220
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L9_bool_binop_done:;

  /* "numpy.pxd":219
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  if (__pyx_t_1) {

    /* "numpy.pxd":221
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(3, 221, __pyx_L1_error)

    /* "numpy.pxd":219
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  }

  /* "numpy.pxd":223
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if copy_shape:
 */
  __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);

  /* "numpy.pxd":224
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if copy_shape:
 *                 # Allocate new buffer for strides and shape info.
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "numpy.pxd":225
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
  __pyx_t_1 = (__pyx_v_copy_shape != 0);
  if (__pyx_t_1) {

    /* "numpy.pxd":228
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));

    /* "numpy.pxd":229
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "numpy.pxd":230
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    __pyx_t_4 = __pyx_v_ndim;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "numpy.pxd":231
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);

      /* "numpy.pxd":232
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
    }

    /* "numpy.pxd":225
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
    goto __pyx_L11;
  }

  /* "numpy.pxd":234
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
  /*else*/ {
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));

    /* "numpy.pxd":235
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  }
  __pyx_L11:;

  /* "numpy.pxd":236
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "numpy.pxd":237
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);

  /* "numpy.pxd":238
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));

  /* "numpy.pxd":241
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef list stack
 */
  __pyx_v_f = NULL;

  /* "numpy.pxd":242
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef list stack
 *             cdef int offset
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "numpy.pxd":246
 *             cdef int offset
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields and not copy_shape:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "numpy.pxd":248
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
  __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L15_bool_binop_done;
  }
  __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L15_bool_binop_done:;
  if (__pyx_t_1) {

    /* "numpy.pxd":250
 *             if not hasfields and not copy_shape:
 *                 # do not call releasebuffer
 *                 info.obj = None             # <<<<<<<<<<<<<<
 *             else:
 *                 # need to call releasebuffer
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = Py_None;

    /* "numpy.pxd":248
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
    goto __pyx_L14;
  }

  /* "numpy.pxd":253
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
  }
  __pyx_L14:;

  /* "numpy.pxd":255
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or
 */
  __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_1) {

    /* "numpy.pxd":256
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == '>' and little_endian) or
 *                     (descr.byteorder == '<' and not little_endian)):
 */
    __pyx_t_4 = __pyx_v_descr->type_num;
    __pyx_v_t = __pyx_t_4;

    /* "numpy.pxd":257
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
    if (!__pyx_t_2) {
      goto __pyx_L20_next_or;
    } else {
    }
    __pyx_t_2 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_L20_next_or:;

    /* "numpy.pxd":258
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or
 *                     (descr.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L19_bool_binop_done:;

    /* "numpy.pxd":257
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    if (__pyx_t_1) {

      /* "numpy.pxd":259
 *                 if ((descr.byteorder == '>' and little_endian) or
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 259, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(3, 259, __pyx_L1_error)

      /* "numpy.pxd":257
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    }

    /* "numpy.pxd":260
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
    switch (__pyx_v_t) {
      case NPY_BYTE:
      __pyx_v_f = ((char *)"b");
      break;

      /* "numpy.pxd":261
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
      case NPY_UBYTE:
      __pyx_v_f = ((char *)"B");
      break;

      /* "numpy.pxd":262
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
      case NPY_SHORT:
      __pyx_v_f = ((char *)"h");
      break;

      /* "numpy.pxd":263
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
      case NPY_USHORT:
      __pyx_v_f = ((char *)"H");
      break;

      /* "numpy.pxd":264
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
      case NPY_INT:
      __pyx_v_f = ((char *)"i");
      break;

      /* "numpy.pxd":265
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
      case NPY_UINT:
      __pyx_v_f = ((char *)"I");
      break;

      /* "numpy.pxd":266
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
      case NPY_LONG:
      __pyx_v_f = ((char *)"l");
      break;

      /* "numpy.pxd":267
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
      case NPY_ULONG:
      __pyx_v_f = ((char *)"L");
      break;

      /* "numpy.pxd":268
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
      case NPY_LONGLONG:
      __pyx_v_f = ((char *)"q");
      break;

      /* "numpy.pxd":269
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
      case NPY_ULONGLONG:
      __pyx_v_f = ((char *)"Q");
      break;

      /* "numpy.pxd":270
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
      case NPY_FLOAT:
      __pyx_v_f = ((char *)"f");
      break;

      /* "numpy.pxd":271
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
      case NPY_DOUBLE:
      __pyx_v_f = ((char *)"d");
      break;

      /* "numpy.pxd":272
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
      case NPY_LONGDOUBLE:
      __pyx_v_f = ((char *)"g");
      break;

      /* "numpy.pxd":273
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
      case NPY_CFLOAT:
      __pyx_v_f = ((char *)"Zf");
      break;

      /* "numpy.pxd":274
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
      case NPY_CDOUBLE:
      __pyx_v_f = ((char *)"Zd");
      break;

      /* "numpy.pxd":275
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
      case NPY_CLONGDOUBLE:
      __pyx_v_f = ((char *)"Zg");
      break;

      /* "numpy.pxd":276
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      case NPY_OBJECT:
      __pyx_v_f = ((char *)"O");
      break;
      default:

      /* "numpy.pxd":278
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(3, 278, __pyx_L1_error)
      break;
    }

    /* "numpy.pxd":279
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "numpy.pxd":280
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "numpy.pxd":255
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or
 */
  }

  /* "numpy.pxd":282
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = '^' # Native data types, manual alignment
 *                 offset = 0
 */
  /*else*/ {
    __pyx_v_info->format = ((char *)malloc(0xFF));

    /* "numpy.pxd":283
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = '^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,
 */
    (__pyx_v_info->format[0]) = '^';

    /* "numpy.pxd":284
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = '^' # Native data types, manual alignment
 *                 offset = 0             # <<<<<<<<<<<<<<
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 */
    __pyx_v_offset = 0;

    /* "numpy.pxd":285
 *                 info.format[0] = '^' # Native data types, manual alignment
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,             # <<<<<<<<<<<<<<
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 */
    __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(3, 285, __pyx_L1_error)
    __pyx_v_f = __pyx_t_7;

    /* "numpy.pxd":288
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 *                 f[0] = 0 # Terminate format string             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
    (__pyx_v_f[0]) = 0;
  }

  /* "numpy.pxd":196
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":290
 *                 f[0] = 0 # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "numpy.pxd":291
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
  if (__pyx_t_1) {

    /* "numpy.pxd":292
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)
 */
    free(__pyx_v_info->format);

    /* "numpy.pxd":291
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  }

  /* "numpy.pxd":293
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "numpy.pxd":294
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    free(__pyx_v_info->strides);

    /* "numpy.pxd":293
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  }

  /* "numpy.pxd":290
 *                 f[0] = 0 # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "numpy.pxd":772
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);

  /* "numpy.pxd":773
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "numpy.pxd":772
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":775
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);

  /* "numpy.pxd":776
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "numpy.pxd":775
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":778
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);

  /* "numpy.pxd":779
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 779, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "numpy.pxd":778
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":781
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);

  /* "numpy.pxd":782
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "numpy.pxd":781
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":784
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);

  /* "numpy.pxd":785
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "numpy.pxd":784
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":787
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  PyArray_Descr *__pyx_v_child = 0;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  PyObject *__pyx_v_fields = 0;
  PyObject *__pyx_v_childname = NULL;
  PyObject *__pyx_v_new_offset = NULL;
  PyObject *__pyx_v_t = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  long __pyx_t_8;
  char *__pyx_t_9;
  __Pyx_RefNannySetupContext("_util_dtypestring", 0);

  /* "numpy.pxd":794
 *     cdef int delta_offset
 *     cdef tuple i
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "numpy.pxd":795
 *     cdef tuple i
 *     cdef int endian_detector = 1
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 *     cdef tuple fields
 * 
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "numpy.pxd":798
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (unlikely(__pyx_v_descr->names == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(3, 798, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(3, 798, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "numpy.pxd":799
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 799, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(3, 799, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "numpy.pxd":800
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 */
    if (likely(__pyx_v_fields != Py_None)) {
      PyObject* sequence = __pyx_v_fields;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(3, 800, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 800, __pyx_L1_error)
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(3, 800, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "numpy.pxd":802
 *         child, new_offset = fields
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_From_ptrdiff_t((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 802, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 802, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_6) {

      /* "numpy.pxd":803
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == '>' and little_endian) or
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 803, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(3, 803, __pyx_L1_error)

      /* "numpy.pxd":802
 *         child, new_offset = fields
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    }

    /* "numpy.pxd":805
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == '<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
    if (!__pyx_t_7) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_7 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;

    /* "numpy.pxd":806
 * 
 *         if ((child.byteorder == '>' and little_endian) or
 *             (child.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
 *             raise ValueError(u"Non-native byte order not supported")
 *             # One could encode it in the format string and have Cython
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L7_bool_binop_done:;

    /* "numpy.pxd":805
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == '<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    if (__pyx_t_6) {

      /* "numpy.pxd":807
 *         if ((child.byteorder == '>' and little_endian) or
 *             (child.byteorder == '<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 807, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(3, 807, __pyx_L1_error)

      /* "numpy.pxd":805
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == '<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    }

    /* "numpy.pxd":817
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 817, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 817, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!__pyx_t_6) break;

      /* "numpy.pxd":818
 *         # Output padding bytes
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 *             f += 1
 *             offset[0] += 1
 */
      (__pyx_v_f[0]) = 0x78;

      /* "numpy.pxd":819
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte
 *             f += 1             # <<<<<<<<<<<<<<
 *             offset[0] += 1
 * 
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "numpy.pxd":820
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      __pyx_t_8 = 0;
      (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
    }

    /* "numpy.pxd":822
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    __pyx_t_8 = 0;
    (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);

    /* "numpy.pxd":824
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
    if (__pyx_t_6) {

      /* "numpy.pxd":825
 * 
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num             # <<<<<<<<<<<<<<
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 825, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "numpy.pxd":826
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
      if (__pyx_t_6) {

        /* "numpy.pxd":827
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 827, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(3, 827, __pyx_L1_error)

        /* "numpy.pxd":826
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      }

      /* "numpy.pxd":830
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 830, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 830, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 830, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L15;
      }

      /* "numpy.pxd":831
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 831, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 831, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 831, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L15;
      }

      /* "numpy.pxd":832
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 832, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 832, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 832, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x68;
        goto __pyx_L15;
      }

      /* "numpy.pxd":833
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 833, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 833, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 833, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L15;
      }

      /* "numpy.pxd":834
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 834, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 834, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 834, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x69;
        goto __pyx_L15;
      }

      /* "numpy.pxd":835
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 835, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 835, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 835, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L15;
      }

      /* "numpy.pxd":836
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 836, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 836, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 836, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x6C;
        goto __pyx_L15;
      }

      /* "numpy.pxd":837
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 837, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 837, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L15;
      }

      /* "numpy.pxd":838
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 838, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 838, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 838, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x71;
        goto __pyx_L15;
      }

      /* "numpy.pxd":839
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 839, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 839, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 839, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L15;
      }

      /* "numpy.pxd":840
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 840, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 840, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 840, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x66;
        goto __pyx_L15;
      }

      /* "numpy.pxd":841
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 841, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 841, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x64;
        goto __pyx_L15;
      }

      /* "numpy.pxd":842
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 842, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 842, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 842, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x67;
        goto __pyx_L15;
      }

      /* "numpy.pxd":843
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 843, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 843, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 843, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x66;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "numpy.pxd":844
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 844, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 844, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 844, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x64;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "numpy.pxd":845
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 */
      __pyx_t_5 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 845, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 845, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 845, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x67;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "numpy.pxd":846
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 846, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 846, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 846, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L15;
      }

      /* "numpy.pxd":848
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *             f += 1
 *         else:
 */
      /*else*/ {
        __pyx_t_5 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 848, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 848, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 848, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(3, 848, __pyx_L1_error)
      }
      __pyx_L15:;

      /* "numpy.pxd":849
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *             f += 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Cython ignores struct boundary information ("T{...}"),
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "numpy.pxd":824
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
      goto __pyx_L13;
    }

    /* "numpy.pxd":853
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
    /*else*/ {
      __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(3, 853, __pyx_L1_error)
      __pyx_v_f = __pyx_t_9;
    }
    __pyx_L13:;

    /* "numpy.pxd":798
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "numpy.pxd":854
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  /* "numpy.pxd":787
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_fields);
  __Pyx_XDECREF(__pyx_v_childname);
  __Pyx_XDECREF(__pyx_v_new_offset);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":970
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  PyObject *__pyx_v_baseptr;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("set_array_base", 0);

  /* "numpy.pxd":972
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
  __pyx_t_1 = (__pyx_v_base == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "numpy.pxd":973
 *      cdef PyObject* baseptr
 *      if base is None:
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 */
    __pyx_v_baseptr = NULL;

    /* "numpy.pxd":972
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
    goto __pyx_L3;
  }

  /* "numpy.pxd":975
 *          baseptr = NULL
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 */
  /*else*/ {
    Py_INCREF(__pyx_v_base);

    /* "numpy.pxd":976
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr
 */
    __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
  }
  __pyx_L3:;

  /* "numpy.pxd":977
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
 *      arr.base = baseptr
 * 
 */
  Py_XDECREF(__pyx_v_arr->base);

  /* "numpy.pxd":978
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  __pyx_v_arr->base = __pyx_v_baseptr;

  /* "numpy.pxd":970
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "numpy.pxd":980
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_array_base", 0);

  /* "numpy.pxd":981
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
  if (__pyx_t_1) {

    /* "numpy.pxd":982
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         return <object>arr.base
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;

    /* "numpy.pxd":981
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  }

  /* "numpy.pxd":984
 *         return None
 *     else:
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
    goto __pyx_L0;
  }

  /* "numpy.pxd":980
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6pandas_7_period__Period __pyx_vtable_6pandas_7_period__Period;

static PyObject *__pyx_tp_new_6pandas_7_period__Period(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6pandas_7_period__Period *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6pandas_7_period__Period *)o);
  p->__pyx_vtab = __pyx_vtabptr_6pandas_7_period__Period;
  p->freq = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6pandas_7_period__Period(PyObject *o) {
  struct __pyx_obj_6pandas_7_period__Period *p = (struct __pyx_obj_6pandas_7_period__Period *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->freq);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6pandas_7_period__Period(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6pandas_7_period__Period *p = (struct __pyx_obj_6pandas_7_period__Period *)o;
  if (p->freq) {
    e = (*v)(p->freq, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6pandas_7_period__Period(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6pandas_7_period__Period *p = (struct __pyx_obj_6pandas_7_period__Period *)o;
  tmp = ((PyObject*)p->freq);
  p->freq = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_start_time(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_10start_time_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_end_time(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_8end_time_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_year(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_4year_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_month(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_5month_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_day(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_3day_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_hour(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_4hour_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_minute(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_6minute_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_second(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_6second_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_weekofyear(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_10weekofyear_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_week(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_4week_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_dayofweek(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_9dayofweek_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_weekday(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_7weekday_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_dayofyear(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_9dayofyear_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_quarter(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_7quarter_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_qyear(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_5qyear_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_days_in_month(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_13days_in_month_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_daysinmonth(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_11daysinmonth_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_is_leap_year(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_12is_leap_year_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_freqstr(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_7freqstr_1__get__(o);
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_ordinal(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_7ordinal_1__get__(o);
}

static int __pyx_setprop_6pandas_7_period_7_Period_ordinal(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6pandas_7_period_7_Period_7ordinal_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_6pandas_7_period_7_Period_freq(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6pandas_7_period_7_Period_4freq_1__get__(o);
}

static int __pyx_setprop_6pandas_7_period_7_Period_freq(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_6pandas_7_period_7_Period_4freq_3__set__(o, v);
  }
  else {
    return __pyx_pw_6pandas_7_period_7_Period_4freq_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_6pandas_7_period__Period[] = {
  {"_maybe_convert_freq", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_1_maybe_convert_freq, METH_O, 0},
  {"_from_ordinal", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_3_from_ordinal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6pandas_7_period_7_Period_2_from_ordinal},
  {"_add_delta", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_9_add_delta, METH_O, 0},
  {"asfreq", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_15asfreq, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6pandas_7_period_7_Period_14asfreq},
  {"to_timestamp", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_17to_timestamp, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6pandas_7_period_7_Period_16to_timestamp},
  {"now", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_19now, METH_VARARGS|METH_KEYWORDS, 0},
  {"__unicode__", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_25__unicode__, METH_NOARGS, __pyx_doc_6pandas_7_period_7_Period_24__unicode__},
  {"__setstate__", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_27__setstate__, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_29__reduce__, METH_NOARGS, 0},
  {"strftime", (PyCFunction)__pyx_pw_6pandas_7_period_7_Period_31strftime, METH_O, __pyx_doc_6pandas_7_period_7_Period_30strftime},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6pandas_7_period__Period[] = {
  {(char *)"start_time", __pyx_getprop_6pandas_7_period_7_Period_start_time, 0, (char *)0, 0},
  {(char *)"end_time", __pyx_getprop_6pandas_7_period_7_Period_end_time, 0, (char *)0, 0},
  {(char *)"year", __pyx_getprop_6pandas_7_period_7_Period_year, 0, (char *)0, 0},
  {(char *)"month", __pyx_getprop_6pandas_7_period_7_Period_month, 0, (char *)0, 0},
  {(char *)"day", __pyx_getprop_6pandas_7_period_7_Period_day, 0, (char *)0, 0},
  {(char *)"hour", __pyx_getprop_6pandas_7_period_7_Period_hour, 0, (char *)0, 0},
  {(char *)"minute", __pyx_getprop_6pandas_7_period_7_Period_minute, 0, (char *)0, 0},
  {(char *)"second", __pyx_getprop_6pandas_7_period_7_Period_second, 0, (char *)0, 0},
  {(char *)"weekofyear", __pyx_getprop_6pandas_7_period_7_Period_weekofyear, 0, (char *)0, 0},
  {(char *)"week", __pyx_getprop_6pandas_7_period_7_Period_week, 0, (char *)0, 0},
  {(char *)"dayofweek", __pyx_getprop_6pandas_7_period_7_Period_dayofweek, 0, (char *)0, 0},
  {(char *)"weekday", __pyx_getprop_6pandas_7_period_7_Period_weekday, 0, (char *)0, 0},
  {(char *)"dayofyear", __pyx_getprop_6pandas_7_period_7_Period_dayofyear, 0, (char *)0, 0},
  {(char *)"quarter", __pyx_getprop_6pandas_7_period_7_Period_quarter, 0, (char *)0, 0},
  {(char *)"qyear", __pyx_getprop_6pandas_7_period_7_Period_qyear, 0, (char *)0, 0},
  {(char *)"days_in_month", __pyx_getprop_6pandas_7_period_7_Period_days_in_month, 0, (char *)0, 0},
  {(char *)"daysinmonth", __pyx_getprop_6pandas_7_period_7_Period_daysinmonth, 0, (char *)0, 0},
  {(char *)"is_leap_year", __pyx_getprop_6pandas_7_period_7_Period_is_leap_year, 0, (char *)0, 0},
  {(char *)"freqstr", __pyx_getprop_6pandas_7_period_7_Period_freqstr, 0, (char *)0, 0},
  {(char *)"ordinal", __pyx_getprop_6pandas_7_period_7_Period_ordinal, __pyx_setprop_6pandas_7_period_7_Period_ordinal, (char *)0, 0},
  {(char *)"freq", __pyx_getprop_6pandas_7_period_7_Period_freq, __pyx_setprop_6pandas_7_period_7_Period_freq, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Period = {
  __pyx_pw_6pandas_7_period_7_Period_11__add__, /*nb_add*/
  __pyx_pw_6pandas_7_period_7_Period_13__sub__, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PyTypeObject __pyx_type_6pandas_7_period__Period = {
  PyVarObject_HEAD_INIT(0, 0)
  "pandas._period._Period", /*tp_name*/
  sizeof(struct __pyx_obj_6pandas_7_period__Period), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6pandas_7_period__Period, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_6pandas_7_period_7_Period_23__repr__, /*tp_repr*/
  &__pyx_tp_as_number__Period, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  __pyx_pw_6pandas_7_period_7_Period_7__hash__, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_6pandas_7_period_7_Period_21__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6pandas_7_period__Period, /*tp_traverse*/
  __pyx_tp_clear_6pandas_7_period__Period, /*tp_clear*/
  __pyx_pw_6pandas_7_period_7_Period_5__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6pandas_7_period__Period, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6pandas_7_period__Period, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6pandas_7_period__Period, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {"period_asfreq", (PyCFunction)__pyx_pw_6pandas_7_period_5period_asfreq, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6pandas_7_period_4period_asfreq},
  {"period_ordinal_to_dt64", (PyCFunction)__pyx_pw_6pandas_7_period_11period_ordinal_to_dt64, METH_VARARGS|METH_KEYWORDS, 0},
  {"resolution", (PyCFunction)__pyx_pw_6pandas_7_period_23resolution, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "_period",
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_03d, __pyx_k_03d, sizeof(__pyx_k_03d), 0, 0, 1, 0},
  {&__pyx_kp_s_06d, __pyx_k_06d, sizeof(__pyx_k_06d), 0, 0, 1, 0},
  {&__pyx_kp_s_09d, __pyx_k_09d, sizeof(__pyx_k_09d), 0, 0, 1, 0},
  {&__pyx_kp_s_2d, __pyx_k_2d, sizeof(__pyx_k_2d), 0, 0, 1, 0},
  {&__pyx_kp_b_AB, __pyx_k_AB, sizeof(__pyx_k_AB), 0, 0, 0, 0},
  {&__pyx_kp_s_AB, __pyx_k_AB, sizeof(__pyx_k_AB), 0, 0, 1, 0},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s_BEGIN, __pyx_k_BEGIN, sizeof(__pyx_k_BEGIN), 0, 0, 1, 1},
  {&__pyx_kp_b_CD, __pyx_k_CD, sizeof(__pyx_k_CD), 0, 0, 0, 0},
  {&__pyx_kp_s_CD, __pyx_k_CD, sizeof(__pyx_k_CD), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_compare_type_r_with_type, __pyx_k_Cannot_compare_type_r_with_type, sizeof(__pyx_k_Cannot_compare_type_r_with_type), 0, 0, 1, 0},
  {&__pyx_kp_s_Could_not_find_pytz_module, __pyx_k_Could_not_find_pytz_module, sizeof(__pyx_k_Could_not_find_pytz_module), 0, 0, 1, 0},
  {&__pyx_n_s_DIFFERENT_FREQ, __pyx_k_DIFFERENT_FREQ, sizeof(__pyx_k_DIFFERENT_FREQ), 0, 0, 1, 1},
  {&__pyx_n_s_DIFFERENT_FREQ_INDEX, __pyx_k_DIFFERENT_FREQ_INDEX, sizeof(__pyx_k_DIFFERENT_FREQ_INDEX), 0, 0, 1, 1},
  {&__pyx_n_s_D_RESO, __pyx_k_D_RESO, sizeof(__pyx_k_D_RESO), 0, 0, 1, 1},
  {&__pyx_n_s_DateOffset, __pyx_k_DateOffset, sizeof(__pyx_k_DateOffset), 0, 0, 1, 1},
  {&__pyx_n_s_E, __pyx_k_E, sizeof(__pyx_k_E), 0, 0, 1, 1},
  {&__pyx_kp_b_EF, __pyx_k_EF, sizeof(__pyx_k_EF), 0, 0, 0, 0},
  {&__pyx_kp_s_EF, __pyx_k_EF, sizeof(__pyx_k_EF), 0, 0, 1, 0},
  {&__pyx_n_s_END, __pyx_k_END, sizeof(__pyx_k_END), 0, 0, 1, 1},
  {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  {&__pyx_kp_b_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 0, 0, 0},
  {&__pyx_n_s_FINISH, __pyx_k_FINISH, sizeof(__pyx_k_FINISH), 0, 0, 1, 1},
  {&__pyx_kp_b_FQ_q, __pyx_k_FQ_q, sizeof(__pyx_k_FQ_q), 0, 0, 0, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  {&__pyx_kp_s_Frequency_conversion_failed, __pyx_k_Frequency_conversion_failed, sizeof(__pyx_k_Frequency_conversion_failed), 0, 0, 1, 0},
  {&__pyx_kp_s_Frequency_must_be_positive_becau, __pyx_k_Frequency_must_be_positive_becau, sizeof(__pyx_k_Frequency_must_be_positive_becau), 0, 0, 1, 0},
  {&__pyx_kp_b_GH, __pyx_k_GH, sizeof(__pyx_k_GH), 0, 0, 0, 0},
  {&__pyx_kp_s_GH, __pyx_k_GH, sizeof(__pyx_k_GH), 0, 0, 1, 0},
  {&__pyx_n_s_H_RESO, __pyx_k_H_RESO, sizeof(__pyx_k_H_RESO), 0, 0, 1, 1},
  {&__pyx_kp_s_How_must_be_one_of_S_or_E, __pyx_k_How_must_be_one_of_S_or_E, sizeof(__pyx_k_How_must_be_one_of_S_or_E), 0, 0, 1, 0},
  {&__pyx_kp_b_IJ, __pyx_k_IJ, sizeof(__pyx_k_IJ), 0, 0, 0, 0},
  {&__pyx_kp_s_IJ, __pyx_k_IJ, sizeof(__pyx_k_IJ), 0, 0, 1, 0},
  {&__pyx_kp_s_If_value_is_None_freq_cannot_be, __pyx_k_If_value_is_None_freq_cannot_be, sizeof(__pyx_k_If_value_is_None_freq_cannot_be), 0, 0, 1, 0},
  {&__pyx_n_s_IncompatibleFrequency, __pyx_k_IncompatibleFrequency, sizeof(__pyx_k_IncompatibleFrequency), 0, 0, 1, 1},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_kp_s_Input_cannot_be_converted_to_Per, __pyx_k_Input_cannot_be_converted_to_Per, sizeof(__pyx_k_Input_cannot_be_converted_to_Per), 0, 0, 1, 0},
  {&__pyx_kp_s_Input_has_different_freq_1_from, __pyx_k_Input_has_different_freq_1_from, sizeof(__pyx_k_Input_has_different_freq_1_from), 0, 0, 1, 0},
  {&__pyx_kp_s_Input_has_different_freq_1_from_2, __pyx_k_Input_has_different_freq_1_from_2, sizeof(__pyx_k_Input_has_different_freq_1_from_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_frequency_or_could_not_i, __pyx_k_Invalid_frequency_or_could_not_i, sizeof(__pyx_k_Invalid_frequency_or_could_not_i), 0, 0, 1, 0},
  {&__pyx_kp_b_KL, __pyx_k_KL, sizeof(__pyx_k_KL), 0, 0, 0, 0},
  {&__pyx_kp_s_KL, __pyx_k_KL, sizeof(__pyx_k_KL), 0, 0, 1, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_MS_RESO, __pyx_k_MS_RESO, sizeof(__pyx_k_MS_RESO), 0, 0, 1, 1},
  {&__pyx_kp_s_Must_supply_freq_for_datetime_va, __pyx_k_Must_supply_freq_for_datetime_va, sizeof(__pyx_k_Must_supply_freq_for_datetime_va), 0, 0, 1, 0},
  {&__pyx_kp_s_Must_supply_freq_for_ordinal_val, __pyx_k_Must_supply_freq_for_ordinal_val, sizeof(__pyx_k_Must_supply_freq_for_ordinal_val), 0, 0, 1, 0},
  {&__pyx_n_s_NaT, __pyx_k_NaT, sizeof(__pyx_k_NaT), 0, 0, 1, 1},
  {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  {&__pyx_n_s_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1},
  {&__pyx_kp_s_Only_value_or_ordinal_but_not_bo, __pyx_k_Only_value_or_ordinal_but_not_bo, sizeof(__pyx_k_Only_value_or_ordinal_but_not_bo), 0, 0, 1, 0},
  {&__pyx_kp_s_Ordinal_must_be_an_integer, __pyx_k_Ordinal_must_be_an_integer, sizeof(__pyx_k_Ordinal_must_be_an_integer), 0, 0, 1, 0},
  {&__pyx_n_s_Period, __pyx_k_Period, sizeof(__pyx_k_Period), 0, 0, 1, 1},
  {&__pyx_n_s_Period___new, __pyx_k_Period___new, sizeof(__pyx_k_Period___new), 0, 0, 1, 1},
  {&__pyx_kp_s_Period_s_s, __pyx_k_Period_s_s, sizeof(__pyx_k_Period_s_s), 0, 0, 1, 0},
  {&__pyx_kp_u_Period_strftime_line_980, __pyx_k_Period_strftime_line_980, sizeof(__pyx_k_Period_strftime_line_980), 0, 1, 0, 0},
  {&__pyx_kp_s_Quarter_must_be_1_q_4, __pyx_k_Quarter_must_be_1_q_4, sizeof(__pyx_k_Quarter_must_be_1_q_4), 0, 0, 1, 0},
  {&__pyx_kp_s_Represents_an_period_of_time_Pa, __pyx_k_Represents_an_period_of_time_Pa, sizeof(__pyx_k_Represents_an_period_of_time_Pa), 0, 0, 1, 0},
  {&__pyx_n_s_Resolution, __pyx_k_Resolution, sizeof(__pyx_k_Resolution), 0, 0, 1, 1},
  {&__pyx_kp_u_Returns_the_string_representati, __pyx_k_Returns_the_string_representati, sizeof(__pyx_k_Returns_the_string_representati), 0, 1, 0, 0},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s_S, __pyx_k_S, sizeof(__pyx_k_S), 0, 0, 1, 1},
  {&__pyx_n_s_START, __pyx_k_START, sizeof(__pyx_k_START), 0, 0, 1, 1},
  {&__pyx_n_s_S_RESO, __pyx_k_S_RESO, sizeof(__pyx_k_S_RESO), 0, 0, 1, 1},
  {&__pyx_n_s_T_RESO, __pyx_k_T_RESO, sizeof(__pyx_k_T_RESO), 0, 0, 1, 1},
  {&__pyx_n_s_Tick, __pyx_k_Tick, sizeof(__pyx_k_Tick), 0, 0, 1, 1},
  {&__pyx_n_s_Timedelta, __pyx_k_Timedelta, sizeof(__pyx_k_Timedelta), 0, 0, 1, 1},
  {&__pyx_n_s_Timestamp, __pyx_k_Timestamp, sizeof(__pyx_k_Timestamp), 0, 0, 1, 1},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_n_s_US_RESO, __pyx_k_US_RESO, sizeof(__pyx_k_US_RESO), 0, 0, 1, 1},
  {&__pyx_kp_s_Unable_to_convert_to_desired_fre, __pyx_k_Unable_to_convert_to_desired_fre, sizeof(__pyx_k_Unable_to_convert_to_desired_fre), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_get_quarter_and_year, __pyx_k_Unable_to_get_quarter_and_year, sizeof(__pyx_k_Unable_to_get_quarter_and_year), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_parse_s, __pyx_k_Unable_to_parse_s, sizeof(__pyx_k_Unable_to_parse_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_freq_d, __pyx_k_Unknown_freq_d, sizeof(__pyx_k_Unknown_freq_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Unrecognized_period_code_d, __pyx_k_Unrecognized_period_code_d, sizeof(__pyx_k_Unrecognized_period_code_d), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s_Value_must_be_Period_string_inte, __pyx_k_Value_must_be_Period_string_inte, sizeof(__pyx_k_Value_must_be_Period_string_inte), 0, 0, 1, 0},
  {&__pyx_kp_b_Y, __pyx_k_Y, sizeof(__pyx_k_Y), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m, __pyx_k_Y_m, sizeof(__pyx_k_Y_m), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m_d, __pyx_k_Y_m_d, sizeof(__pyx_k_Y_m_d), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m_d_H_00, __pyx_k_Y_m_d_H_00, sizeof(__pyx_k_Y_m_d_H_00), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m_d_H_M, __pyx_k_Y_m_d_H_M, sizeof(__pyx_k_Y_m_d_H_M), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m_d_H_M_S, __pyx_k_Y_m_d_H_M_S, sizeof(__pyx_k_Y_m_d_H_M_S), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m_d_H_M_S_l, __pyx_k_Y_m_d_H_M_S_l, sizeof(__pyx_k_Y_m_d_H_M_S_l), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m_d_H_M_S_n, __pyx_k_Y_m_d_H_M_S_n, sizeof(__pyx_k_Y_m_d_H_M_S_n), 0, 0, 0, 0},
  {&__pyx_kp_b_Y_m_d_H_M_S_u, __pyx_k_Y_m_d_H_M_S_u, sizeof(__pyx_k_Y_m_d_H_M_S_u), 0, 0, 0, 0},
  {&__pyx_n_s__51, __pyx_k__51, sizeof(__pyx_k__51), 0, 0, 1, 1},
  {&__pyx_n_s_add_delta, __pyx_k_add_delta, sizeof(__pyx_k_add_delta), 0, 0, 1, 1},
  {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1},
  {&__pyx_n_s_arr, __pyx_k_arr, sizeof(__pyx_k_arr), 0, 0, 1, 1},
  {&__pyx_n_s_asfreq, __pyx_k_asfreq, sizeof(__pyx_k_asfreq), 0, 0, 1, 1},
  {&__pyx_kp_s_assignment_destination_is_read_o, __pyx_k_assignment_destination_is_read_o, sizeof(__pyx_k_assignment_destination_is_read_o), 0, 0, 1, 0},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
  {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  {&__pyx_n_s_code, __pyx_k_code, sizeof(__pyx_k_code), 0, 0, 1, 1},
  {&__pyx_n_s_comparables, __pyx_k_comparables, sizeof(__pyx_k_comparables), 0, 0, 1, 1},
  {&__pyx_n_s_compat, __pyx_k_compat, sizeof(__pyx_k_compat), 0, 0, 1, 1},
  {&__pyx_n_s_converted, __pyx_k_converted, sizeof(__pyx_k_converted), 0, 0, 1, 1},
  {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
  {&__pyx_kp_s_d_2, __pyx_k_d_2, sizeof(__pyx_k_d_2), 0, 0, 1, 0},
  {&__pyx_n_s_date, __pyx_k_date, sizeof(__pyx_k_date), 0, 0, 1, 1},
  {&__pyx_n_s_datetime, __pyx_k_datetime, sizeof(__pyx_k_datetime), 0, 0, 1, 1},
  {&__pyx_n_s_datetime64, __pyx_k_datetime64, sizeof(__pyx_k_datetime64), 0, 0, 1, 1},
  {&__pyx_n_s_dateutil, __pyx_k_dateutil, sizeof(__pyx_k_dateutil), 0, 0, 1, 1},
  {&__pyx_n_s_day, __pyx_k_day, sizeof(__pyx_k_day), 0, 0, 1, 1},
  {&__pyx_n_s_dayofweek, __pyx_k_dayofweek, sizeof(__pyx_k_dayofweek), 0, 0, 1, 1},
  {&__pyx_n_s_days_in_month, __pyx_k_days_in_month, sizeof(__pyx_k_days_in_month), 0, 0, 1, 1},
  {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
  {&__pyx_n_s_delta_to_nanoseconds, __pyx_k_delta_to_nanoseconds, sizeof(__pyx_k_delta_to_nanoseconds), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1},
  {&__pyx_n_s_dt64arr_to_periodarr, __pyx_k_dt64arr_to_periodarr, sizeof(__pyx_k_dt64arr_to_periodarr), 0, 0, 1, 1},
  {&__pyx_n_s_dtarr, __pyx_k_dtarr, sizeof(__pyx_k_dtarr), 0, 0, 1, 1},
  {&__pyx_n_s_dts, __pyx_k_dts, sizeof(__pyx_k_dts), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_extract_freq, __pyx_k_extract_freq, sizeof(__pyx_k_extract_freq), 0, 0, 1, 1},
  {&__pyx_n_s_extract_ordinals, __pyx_k_extract_ordinals, sizeof(__pyx_k_extract_ordinals), 0, 0, 1, 1},
  {&__pyx_kp_b_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 0, 0},
  {&__pyx_n_s_f_2, __pyx_k_f_2, sizeof(__pyx_k_f_2), 0, 0, 1, 1},
  {&__pyx_n_s_finfo, __pyx_k_finfo, sizeof(__pyx_k_finfo), 0, 0, 1, 1},
  {&__pyx_n_s_fmt, __pyx_k_fmt, sizeof(__pyx_k_fmt), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_freq, __pyx_k_freq, sizeof(__pyx_k_freq), 0, 0, 1, 1},
  {&__pyx_n_s_freq1, __pyx_k_freq1, sizeof(__pyx_k_freq1), 0, 0, 1, 1},
  {&__pyx_n_s_freq2, __pyx_k_freq2, sizeof(__pyx_k_freq2), 0, 0, 1, 1},
  {&__pyx_n_s_freq_group, __pyx_k_freq_group, sizeof(__pyx_k_freq_group), 0, 0, 1, 1},
  {&__pyx_kp_s_freq_not_specified_and_cannot_be, __pyx_k_freq_not_specified_and_cannot_be, sizeof(__pyx_k_freq_not_specified_and_cannot_be), 0, 0, 1, 0},
  {&__pyx_n_s_freqstr, __pyx_k_freqstr, sizeof(__pyx_k_freqstr), 0, 0, 1, 1},
  {&__pyx_n_s_frequencies, __pyx_k_frequencies, sizeof(__pyx_k_frequencies), 0, 0, 1, 1},
  {&__pyx_n_s_from_ordinal, __pyx_k_from_ordinal, sizeof(__pyx_k_from_ordinal), 0, 0, 1, 1},
  {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_base_alias, __pyx_k_get_base_alias, sizeof(__pyx_k_get_base_alias), 0, 0, 1, 1},
  {&__pyx_n_s_get_freq, __pyx_k_get_freq, sizeof(__pyx_k_get_freq), 0, 0, 1, 1},
  {&__pyx_n_s_get_freq_code, __pyx_k_get_freq_code, sizeof(__pyx_k_get_freq_code), 0, 0, 1, 1},
  {&__pyx_n_s_get_freq_str, __pyx_k_get_freq_str, sizeof(__pyx_k_get_freq_str), 0, 0, 1, 1},
  {&__pyx_n_s_get_period_field, __pyx_k_get_period_field, sizeof(__pyx_k_get_period_field), 0, 0, 1, 1},
  {&__pyx_n_s_get_period_field_arr, __pyx_k_get_period_field_arr, sizeof(__pyx_k_get_period_field_arr), 0, 0, 1, 1},
  {&__pyx_n_s_get_rule_month, __pyx_k_get_rule_month, sizeof(__pyx_k_get_rule_month), 0, 0, 1, 1},
  {&__pyx_n_s_get_to_timestamp_base, __pyx_k_get_to_timestamp_base, sizeof(__pyx_k_get_to_timestamp_base), 0, 0, 1, 1},
  {&__pyx_n_s_get_utcoffset, __pyx_k_get_utcoffset, sizeof(__pyx_k_get_utcoffset), 0, 0, 1, 1},
  {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1},
  {&__pyx_n_s_have_pytz, __pyx_k_have_pytz, sizeof(__pyx_k_have_pytz), 0, 0, 1, 1},
  {&__pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_k_home_joris_scipy_pandas_pandas, sizeof(__pyx_k_home_joris_scipy_pandas_pandas), 0, 0, 1, 0},
  {&__pyx_n_s_hour, __pyx_k_hour, sizeof(__pyx_k_hour), 0, 0, 1, 1},
  {&__pyx_n_s_how, __pyx_k_how, sizeof(__pyx_k_how), 0, 0, 1, 1},
  {&__pyx_n_s_how_dict, __pyx_k_how_dict, sizeof(__pyx_k_how_dict), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_i8, __pyx_k_i8, sizeof(__pyx_k_i8), 0, 0, 1, 1},
  {&__pyx_n_s_iNaT, __pyx_k_iNaT, sizeof(__pyx_k_iNaT), 0, 0, 1, 1},
  {&__pyx_n_s_ignore, __pyx_k_ignore, sizeof(__pyx_k_ignore), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_kp_s_index_out_of_bounds, __pyx_k_index_out_of_bounds, sizeof(__pyx_k_index_out_of_bounds), 0, 0, 1, 0},
  {&__pyx_n_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 1},
  {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
  {&__pyx_n_s_is_integer, __pyx_k_is_integer, sizeof(__pyx_k_is_integer), 0, 0, 1, 1},
  {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
  {&__pyx_kp_b_l_2, __pyx_k_l_2, sizeof(__pyx_k_l_2), 0, 0, 0, 0},
  {&__pyx_n_s_left, __pyx_k_left, sizeof(__pyx_k_left), 0, 0, 1, 1},
  {&__pyx_n_s_lib, __pyx_k_lib, sizeof(__pyx_k_lib), 0, 0, 1, 1},
  {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
  {&__pyx_n_s_maybe_convert_freq, __pyx_k_maybe_convert_freq, sizeof(__pyx_k_maybe_convert_freq), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_microsecond, __pyx_k_microsecond, sizeof(__pyx_k_microsecond), 0, 0, 1, 1},
  {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1},
  {&__pyx_n_s_minute, __pyx_k_minute, sizeof(__pyx_k_minute), 0, 0, 1, 1},
  {&__pyx_n_s_mnum, __pyx_k_mnum, sizeof(__pyx_k_mnum), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_month, __pyx_k_month, sizeof(__pyx_k_month), 0, 0, 1, 1},
  {&__pyx_n_s_month_numbers, __pyx_k_month_numbers, sizeof(__pyx_k_month_numbers), 0, 0, 1, 1},
  {&__pyx_n_s_msg, __pyx_k_msg, sizeof(__pyx_k_msg), 0, 0, 1, 1},
  {&__pyx_n_s_mult, __pyx_k_mult, sizeof(__pyx_k_mult), 0, 0, 1, 1},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_kp_b_n_2, __pyx_k_n_2, sizeof(__pyx_k_n_2), 0, 0, 0, 0},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1},
  {&__pyx_n_s_nat_strings, __pyx_k_nat_strings, sizeof(__pyx_k_nat_strings), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_now, __pyx_k_now, sizeof(__pyx_k_now), 0, 0, 1, 1},
  {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_offsets, __pyx_k_offsets, sizeof(__pyx_k_offsets), 0, 0, 1, 1},
  {&__pyx_n_s_operator, __pyx_k_operator, sizeof(__pyx_k_operator), 0, 0, 1, 1},
  {&__pyx_n_s_ordinal, __pyx_k_ordinal, sizeof(__pyx_k_ordinal), 0, 0, 1, 1},
  {&__pyx_n_s_ordinal_from_fields, __pyx_k_ordinal_from_fields, sizeof(__pyx_k_ordinal_from_fields), 0, 0, 1, 1},
  {&__pyx_n_s_ordinals, __pyx_k_ordinals, sizeof(__pyx_k_ordinals), 0, 0, 1, 1},
  {&__pyx_n_s_other, __pyx_k_other, sizeof(__pyx_k_other), 0, 0, 1, 1},
  {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
  {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
  {&__pyx_n_s_pandas, __pyx_k_pandas, sizeof(__pyx_k_pandas), 0, 0, 1, 1},
  {&__pyx_n_s_pandas__period, __pyx_k_pandas__period, sizeof(__pyx_k_pandas__period), 0, 0, 1, 1},
  {&__pyx_n_s_pandas_tseries, __pyx_k_pandas_tseries, sizeof(__pyx_k_pandas_tseries), 0, 0, 1, 1},
  {&__pyx_n_s_pandas_tseries_tools, __pyx_k_pandas_tseries_tools, sizeof(__pyx_k_pandas_tseries_tools), 0, 0, 1, 1},
  {&__pyx_n_s_parse_time_string, __pyx_k_parse_time_string, sizeof(__pyx_k_parse_time_string), 0, 0, 1, 1},
  {&__pyx_n_s_period, __pyx_k_period, sizeof(__pyx_k_period), 0, 0, 1, 1},
  {&__pyx_n_s_period_asfreq_arr, __pyx_k_period_asfreq_arr, sizeof(__pyx_k_period_asfreq_arr), 0, 0, 1, 1},
  {&__pyx_n_s_period_format, __pyx_k_period_format, sizeof(__pyx_k_period_format), 0, 0, 1, 1},
  {&__pyx_n_s_period_ordinal, __pyx_k_period_ordinal, sizeof(__pyx_k_period_ordinal), 0, 0, 1, 1},
  {&__pyx_n_s_periodarr, __pyx_k_periodarr, sizeof(__pyx_k_periodarr), 0, 0, 1, 1},
  {&__pyx_n_s_periodarr_to_dt64arr, __pyx_k_periodarr_to_dt64arr, sizeof(__pyx_k_periodarr_to_dt64arr), 0, 0, 1, 1},
  {&__pyx_n_s_periodindex, __pyx_k_periodindex, sizeof(__pyx_k_periodindex), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 0, 0, 1, 1},
  {&__pyx_n_s_pytz, __pyx_k_pytz, sizeof(__pyx_k_pytz), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_kp_b_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 0, 0},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_quarter, __pyx_k_quarter, sizeof(__pyx_k_quarter), 0, 0, 1, 1},
  {&__pyx_n_s_quarter_to_myear, __pyx_k_quarter_to_myear, sizeof(__pyx_k_quarter_to_myear), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_relation, __pyx_k_relation, sizeof(__pyx_k_relation), 0, 0, 1, 1},
  {&__pyx_n_s_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 0, 0, 1, 1},
  {&__pyx_n_s_reso, __pyx_k_reso, sizeof(__pyx_k_reso), 0, 0, 1, 1},
  {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  {&__pyx_n_s_right, __pyx_k_right, sizeof(__pyx_k_right), 0, 0, 1, 1},
  {&__pyx_n_s_rule_code, __pyx_k_rule_code, sizeof(__pyx_k_rule_code), 0, 0, 1, 1},
  {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
  {&__pyx_kp_s_s_2, __pyx_k_s_2, sizeof(__pyx_k_s_2), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_searchsorted, __pyx_k_searchsorted, sizeof(__pyx_k_searchsorted), 0, 0, 1, 1},
  {&__pyx_n_s_second, __pyx_k_second, sizeof(__pyx_k_second), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_side, __pyx_k_side, sizeof(__pyx_k_side), 0, 0, 1, 1},
  {&__pyx_n_s_stamps, __pyx_k_stamps, sizeof(__pyx_k_stamps), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_start_time, __pyx_k_start_time, sizeof(__pyx_k_start_time), 0, 0, 1, 1},
  {&__pyx_n_s_string_types, __pyx_k_string_types, sizeof(__pyx_k_string_types), 0, 0, 1, 1},
  {&__pyx_n_s_sub, __pyx_k_sub, sizeof(__pyx_k_sub), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_sz, __pyx_k_sz, sizeof(__pyx_k_sz), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_timedelta, __pyx_k_timedelta, sizeof(__pyx_k_timedelta), 0, 0, 1, 1},
  {&__pyx_n_s_timedelta64, __pyx_k_timedelta64, sizeof(__pyx_k_timedelta64), 0, 0, 1, 1},
  {&__pyx_n_s_to_offset, __pyx_k_to_offset, sizeof(__pyx_k_to_offset), 0, 0, 1, 1},
  {&__pyx_n_s_to_timestamp, __pyx_k_to_timestamp, sizeof(__pyx_k_to_timestamp), 0, 0, 1, 1},
  {&__pyx_n_s_tslib, __pyx_k_tslib, sizeof(__pyx_k_tslib), 0, 0, 1, 1},
  {&__pyx_n_s_typ, __pyx_k_typ, sizeof(__pyx_k_typ), 0, 0, 1, 1},
  {&__pyx_n_s_tz, __pyx_k_tz, sizeof(__pyx_k_tz), 0, 0, 1, 1},
  {&__pyx_kp_b_u, __pyx_k_u, sizeof(__pyx_k_u), 0, 0, 0, 0},
  {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1},
  {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
  {&__pyx_n_s_us, __pyx_k_us, sizeof(__pyx_k_us), 0, 0, 1, 1},
  {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0},
  {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1},
  {&__pyx_n_s_validate_end_alias, __pyx_k_validate_end_alias, sizeof(__pyx_k_validate_end_alias), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  {&__pyx_n_s_weekofyear, __pyx_k_weekofyear, sizeof(__pyx_k_weekofyear), 0, 0, 1, 1},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {&__pyx_n_s_year, __pyx_k_year, sizeof(__pyx_k_year), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 686, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 160, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 486, __pyx_L1_error)
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) __PYX_ERR(0, 620, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 737, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 743, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 1204, __pyx_L1_error)
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 69, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(3, 803, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "pandas/src/period.pyx":218
 * 
 *     if retval == INT32_MIN:
 *         raise ValueError('Frequency conversion failed')             # <<<<<<<<<<<<<<
 * 
 *     return retval
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Frequency_conversion_failed); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "pandas/src/period.pyx":254
 *                 val = func(val, relation, &finfo)
 *                 if val == INT32_MIN:
 *                     raise ValueError("Unable to convert to desired frequency.")             # <<<<<<<<<<<<<<
 *             result[i] = val
 *     else:
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_to_desired_fre); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "pandas/src/period.pyx":260
 *             val = func(arr[i], relation, &finfo)
 *             if val == INT32_MIN:
 *                 raise ValueError("Unable to convert to desired frequency.")             # <<<<<<<<<<<<<<
 *             result[i] = val
 * 
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_to_desired_fre); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "pandas/src/period.pyx":361
 * 
 *     if PyUnicode_Check(fmt):
 *         fmt = fmt.encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *     get_date_info(value, freq, &dinfo)
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "pandas/src/period.pyx":379
 *         if found_pat[i]:
 *             if get_yq(value, freq, &quarter, &year) < 0:
 *                 raise ValueError('Unable to get quarter and year')             # <<<<<<<<<<<<<<
 * 
 *             if i == 0:
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_get_quarter_and_year); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "pandas/src/period.pyx":397
 * 
 *     if PY2:
 *         result = result.decode('utf-8', 'ignore')             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
  __pyx_tuple__6 = PyTuple_Pack(2, __pyx_kp_s_utf_8, __pyx_n_s_ignore); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "pandas/src/period.pyx":512
 *             pass
 * 
 *     raise ValueError('freq not specified and cannot be inferred')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_freq_not_specified_and_cannot_be); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "pandas/src/period.pyx":620
 * 
 *     if not have_pytz:
 *         raise Exception('Could not find pytz module')             # <<<<<<<<<<<<<<
 * 
 *     if _is_utc(tz):
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_Could_not_find_pytz_module); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "pandas/src/period.pyx":1155
 * 
 *         if ordinal is not None and value is not None:
 *             raise ValueError(("Only value or ordinal but not both should be "             # <<<<<<<<<<<<<<
 *                               "given but not both"))
 *         elif ordinal is not None:
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Only_value_or_ordinal_but_not_bo); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "pandas/src/period.pyx":1159
 *         elif ordinal is not None:
 *             if not lib.is_integer(ordinal):
 *                 raise ValueError("Ordinal must be an integer")             # <<<<<<<<<<<<<<
 *             if freq is None:
 *                 raise ValueError('Must supply freq for ordinal value')
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Ordinal_must_be_an_integer); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 1159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "pandas/src/period.pyx":1161
 *                 raise ValueError("Ordinal must be an integer")
 *             if freq is None:
 *                 raise ValueError('Must supply freq for ordinal value')             # <<<<<<<<<<<<<<
 * 
 *         elif value is None:
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Must_supply_freq_for_ordinal_val); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "pandas/src/period.pyx":1170
 *             else:
 *                 if freq is None:
 *                     raise ValueError("If value is None, freq cannot be None")             # <<<<<<<<<<<<<<
 * 
 *                 # set defaults
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_If_value_is_None_freq_cannot_be); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "pandas/src/period.pyx":1211
 *             dt = value
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')             # <<<<<<<<<<<<<<
 *         elif isinstance(value, np.datetime64):
 *             dt = Timestamp(value)
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Must_supply_freq_for_datetime_va); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "pandas/src/period.pyx":1215
 *             dt = Timestamp(value)
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')             # <<<<<<<<<<<<<<
 *         elif isinstance(value, date):
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Must_supply_freq_for_datetime_va); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "pandas/src/period.pyx":1219
 *             dt = datetime(year=value.year, month=value.month, day=value.day)
 *             if freq is None:
 *                 raise ValueError('Must supply freq for datetime value')             # <<<<<<<<<<<<<<
 *         else:
 *             msg = "Value must be Period, string, integer, or datetime"
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Must_supply_freq_for_datetime_va); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "pandas/src/period.pyx":1246
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:
 *             raise ValueError('Quarter must be 1 <= q <= 4')             # <<<<<<<<<<<<<<
 * 
 *         mnum = frequencies._month_numbers[
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Quarter_must_be_1_q_4); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 1246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "pandas/src/period.pyx":1263
 *     how = how_dict.get(str(how).upper())
 *     if how not in set(['S', 'E']):
 *         raise ValueError('How must be one of S or E')             # <<<<<<<<<<<<<<
 *     return how
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_How_must_be_one_of_S_or_E); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 1263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "util.pxd":69
 *         i += sz
 *     elif i >= sz or sz == 0:
 *         raise IndexError('index out of bounds')             # <<<<<<<<<<<<<<
 * 
 *     return get_value_1d(arr, i)
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_index_out_of_bounds); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "util.pxd":91
 *         i += sz
 *     elif i >= sz:
 *         raise IndexError('index out of bounds')             # <<<<<<<<<<<<<<
 * 
 *     assign_value_1d(arr, i, value)
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_index_out_of_bounds); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "util.pxd":99
 *     """
 *     if not cnp.PyArray_ISWRITEABLE(arr):
 *         raise ValueError('assignment destination is read-only')             # <<<<<<<<<<<<<<
 * 
 *     set_value_at_unsafe(arr, loc, value)
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_assignment_destination_is_read_o); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "numpy.pxd":217
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(3, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "numpy.pxd":221
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(3, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "numpy.pxd":259
 *                 if ((descr.byteorder == '>' and little_endian) or
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(3, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "numpy.pxd":803
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == '>' and little_endian) or
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(3, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "numpy.pxd":807
 *         if ((child.byteorder == '>' and little_endian) or
 *             (child.byteorder == '<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(3, 807, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "numpy.pxd":827
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(3, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "pandas/src/period.pyx":144
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def dt64arr_to_periodarr(ndarray[int64_t] dtarr, int freq, tz=None):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array of datetime64 values (passed in as 'i8' dtype) to a set of
 */
  __pyx_tuple__27 = PyTuple_Pack(7, __pyx_n_s_dtarr, __pyx_n_s_freq, __pyx_n_s_tz, __pyx_n_s_out, __pyx_n_s_i, __pyx_n_s_l, __pyx_n_s_dts); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_dt64arr_to_periodarr, 144, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 144, __pyx_L1_error)

  /* "pandas/src/period.pyx":175
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def periodarr_to_dt64arr(ndarray[int64_t] periodarr, int freq):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array to datetime64 values from a set of ordinals corresponding to
 */
  __pyx_tuple__29 = PyTuple_Pack(5, __pyx_n_s_periodarr, __pyx_n_s_freq, __pyx_n_s_out, __pyx_n_s_i, __pyx_n_s_l); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_periodarr_to_dt64arr, 175, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 175, __pyx_L1_error)

  /* "pandas/src/period.pyx":223
 * 
 * 
 * def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end):             # <<<<<<<<<<<<<<
 *     """
 *     Convert int64-array of period ordinals from one frequency to another, and
 */
  __pyx_tuple__31 = PyTuple_Pack(13, __pyx_n_s_arr, __pyx_n_s_freq1, __pyx_n_s_freq2, __pyx_n_s_end, __pyx_n_s_result, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_func, __pyx_n_s_finfo, __pyx_n_s_val, __pyx_n_s_ordinal, __pyx_n_s_relation, __pyx_n_s_mask); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
  __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_period_asfreq_arr, 223, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 223, __pyx_L1_error)

  /* "pandas/src/period.pyx":266
 * 
 * 
 * def period_ordinal(int y, int m, int d, int h, int min,             # <<<<<<<<<<<<<<
 *                    int s, int us, int ps, int freq):
 *     cdef:
 */
  __pyx_tuple__33 = PyTuple_Pack(10, __pyx_n_s_y, __pyx_n_s_m, __pyx_n_s_d, __pyx_n_s_h, __pyx_n_s_min, __pyx_n_s_s, __pyx_n_s_us, __pyx_n_s_ps, __pyx_n_s_freq, __pyx_n_s_ordinal); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(9, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_period_ordinal, 266, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 266, __pyx_L1_error)

  /* "pandas/src/period.pyx":298
 * 
 * 
 * def period_format(int64_t value, int freq, object fmt=None):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int freq_group
 */
  __pyx_tuple__35 = PyTuple_Pack(6, __pyx_n_s_value, __pyx_n_s_freq, __pyx_n_s_fmt, __pyx_n_s_freq_group, __pyx_n_s_left, __pyx_n_s_right); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_period_format, 298, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 298, __pyx_L1_error)

  /* "pandas/src/period.pyx":339
 * 
 * 
 * cdef list extra_fmts = [(b"%q", b"^`AB`^"),             # <<<<<<<<<<<<<<
 *                         (b"%f", b"^`CD`^"),
 *                         (b"%F", b"^`EF`^"),
 */
  __pyx_tuple__37 = PyTuple_Pack(2, __pyx_kp_b_q, __pyx_kp_b_AB); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "pandas/src/period.pyx":340
 * 
 * cdef list extra_fmts = [(b"%q", b"^`AB`^"),
 *                         (b"%f", b"^`CD`^"),             # <<<<<<<<<<<<<<
 *                         (b"%F", b"^`EF`^"),
 *                         (b"%l", b"^`GH`^"),
 */
  __pyx_tuple__38 = PyTuple_Pack(2, __pyx_kp_b_f, __pyx_kp_b_CD); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "pandas/src/period.pyx":341
 * cdef list extra_fmts = [(b"%q", b"^`AB`^"),
 *                         (b"%f", b"^`CD`^"),
 *                         (b"%F", b"^`EF`^"),             # <<<<<<<<<<<<<<
 *                         (b"%l", b"^`GH`^"),
 *                         (b"%u", b"^`IJ`^"),
 */
  __pyx_tuple__39 = PyTuple_Pack(2, __pyx_kp_b_F, __pyx_kp_b_EF); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "pandas/src/period.pyx":342
 *                         (b"%f", b"^`CD`^"),
 *                         (b"%F", b"^`EF`^"),
 *                         (b"%l", b"^`GH`^"),             # <<<<<<<<<<<<<<
 *                         (b"%u", b"^`IJ`^"),
 *                         (b"%n", b"^`KL`^")]
 */
  __pyx_tuple__40 = PyTuple_Pack(2, __pyx_kp_b_l_2, __pyx_kp_b_GH); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "pandas/src/period.pyx":343
 *                         (b"%F", b"^`EF`^"),
 *                         (b"%l", b"^`GH`^"),
 *                         (b"%u", b"^`IJ`^"),             # <<<<<<<<<<<<<<
 *                         (b"%n", b"^`KL`^")]
 * 
 */
  __pyx_tuple__41 = PyTuple_Pack(2, __pyx_kp_b_u, __pyx_kp_b_IJ); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "pandas/src/period.pyx":344
 *                         (b"%l", b"^`GH`^"),
 *                         (b"%u", b"^`IJ`^"),
 *                         (b"%n", b"^`KL`^")]             # <<<<<<<<<<<<<<
 * 
 * cdef list str_extra_fmts = ["^`AB`^", "^`CD`^", "^`EF`^",
 */
  __pyx_tuple__42 = PyTuple_Pack(2, __pyx_kp_b_n_2, __pyx_kp_b_KL); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "pandas/src/period.pyx":406
 * 
 * 
 * def get_period_field(int code, int64_t value, int freq):             # <<<<<<<<<<<<<<
 *     cdef accessor f = _get_accessor_func(code)
 *     if f is NULL:
 */
  __pyx_tuple__43 = PyTuple_Pack(4, __pyx_n_s_code, __pyx_n_s_value, __pyx_n_s_freq, __pyx_n_s_f_2); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);
  __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_get_period_field, 406, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 406, __pyx_L1_error)

  /* "pandas/src/period.pyx":415
 * 
 * 
 * def get_period_field_arr(int code, ndarray[int64_t] arr, int freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, sz
 */
  __pyx_tuple__45 = PyTuple_Pack(7, __pyx_n_s_code, __pyx_n_s_arr, __pyx_n_s_freq, __pyx_n_s_i, __pyx_n_s_sz, __pyx_n_s_out, __pyx_n_s_f_2); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);
  __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_get_period_field_arr, 415, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 415, __pyx_L1_error)

  /* "pandas/src/period.pyx":465
 * 
 * 
 * def extract_ordinals(ndarray[object] values, freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */
  __pyx_tuple__47 = PyTuple_Pack(8, __pyx_n_s_values, __pyx_n_s_freq, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_ordinals, __pyx_n_s_p, __pyx_n_s_freqstr, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
  __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_extract_ordinals, 465, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 465, __pyx_L1_error)

  /* "pandas/src/period.pyx":497
 * 
 * 
 * def extract_freq(ndarray[object] values):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */
  __pyx_tuple__49 = PyTuple_Pack(4, __pyx_n_s_values, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_p); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
  __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_extract_freq, 497, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 497, __pyx_L1_error)

  /* "pandas/src/period.pyx":1140
 *     """
 * 
 *     def __new__(cls, value=None, freq=None, ordinal=None,             # <<<<<<<<<<<<<<
 *                 year=None, month=None, quarter=None, day=None,
 *                 hour=None, minute=None, second=None):
 */
  __pyx_tuple__52 = PyTuple_Pack(20, __pyx_n_s_cls, __pyx_n_s_value, __pyx_n_s_freq, __pyx_n_s_ordinal, __pyx_n_s_year, __pyx_n_s_month, __pyx_n_s_quarter, __pyx_n_s_day, __pyx_n_s_hour, __pyx_n_s_minute, __pyx_n_s_second, __pyx_n_s_self, __pyx_n_s_other, __pyx_n_s_converted, __pyx_n_s_dt, __pyx_n_s__51, __pyx_n_s_reso, __pyx_n_s_msg, __pyx_n_s_base, __pyx_n_s_mult); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 1140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);
  __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(11, 0, 20, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_new, 1140, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 1140, __pyx_L1_error)
  __pyx_tuple__54 = PyTuple_Pack(10, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 1140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "pandas/src/period.pyx":1233
 * 
 * 
 * def _ordinal_from_fields(year, month, quarter, day,             # <<<<<<<<<<<<<<
 *                          hour, minute, second, freq):
 *     base, mult = frequencies.get_freq_code(freq)
 */
  __pyx_tuple__55 = PyTuple_Pack(10, __pyx_n_s_year, __pyx_n_s_month, __pyx_n_s_quarter, __pyx_n_s_day, __pyx_n_s_hour, __pyx_n_s_minute, __pyx_n_s_second, __pyx_n_s_freq, __pyx_n_s_base, __pyx_n_s_mult); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);
  __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(8, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_ordinal_from_fields, 1233, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 1233, __pyx_L1_error)

  /* "pandas/src/period.pyx":1243
 * 
 * 
 * def _quarter_to_myear(year, quarter, freq):             # <<<<<<<<<<<<<<
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:
 */
  __pyx_tuple__57 = PyTuple_Pack(5, __pyx_n_s_year, __pyx_n_s_quarter, __pyx_n_s_freq, __pyx_n_s_mnum, __pyx_n_s_month); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);
  __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_quarter_to_myear, 1243, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 1243, __pyx_L1_error)

  /* "pandas/src/period.pyx":1257
 * 
 * 
 * def _validate_end_alias(how):             # <<<<<<<<<<<<<<
 *     how_dict = {'S': 'S', 'E': 'E',
 *                 'START': 'S', 'FINISH': 'E',
 */
  __pyx_tuple__59 = PyTuple_Pack(2, __pyx_n_s_how, __pyx_n_s_how_dict); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 1257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);
  __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_joris_scipy_pandas_pandas, __pyx_n_s_validate_end_alias, 1257, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 1257, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_9 = PyInt_FromLong(9); if (unlikely(!__pyx_int_9)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_11 = PyInt_FromLong(11); if (unlikely(!__pyx_int_11)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_6000 = PyInt_FromLong(6000); if (unlikely(!__pyx_int_6000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1000000000 = PyInt_FromLong(1000000000L); if (unlikely(!__pyx_int_1000000000)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_period(void); /*proto*/
PyMODINIT_FUNC init_period(void)
#else
PyMODINIT_FUNC PyInit__period(void); /*proto*/
PyMODINIT_FUNC PyInit__period(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__period(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("_period", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_pandas___period) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "pandas._period")) {
      if (unlikely(PyDict_SetItemString(modules, "pandas._period", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global init code ---*/
  __pyx_v_6pandas_7_period_extra_fmts = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6pandas_7_period_str_extra_fmts = ((PyObject*)Py_None); Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_6pandas_7_period__Period = &__pyx_vtable_6pandas_7_period__Period;
  __pyx_vtable_6pandas_7_period__Period._field = (PyObject *(*)(struct __pyx_obj_6pandas_7_period__Period *, PyObject *))__pyx_f_6pandas_7_period_7_Period__field;
  if (PyType_Ready(&__pyx_type_6pandas_7_period__Period) < 0) __PYX_ERR(0, 690, __pyx_L1_error)
  __pyx_type_6pandas_7_period__Period.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6pandas_7_period__Period.tp_dict, __pyx_vtabptr_6pandas_7_period__Period) < 0) __PYX_ERR(0, 690, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "_Period", (PyObject *)&__pyx_type_6pandas_7_period__Period) < 0) __PYX_ERR(0, 690, __pyx_L1_error)
  __pyx_ptype_6pandas_7_period__Period = &__pyx_type_6pandas_7_period__Period;
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(4, 9, __pyx_L1_error)
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(5, 8, __pyx_L1_error)
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(6, 15, __pyx_L1_error)
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(3, 157, __pyx_L1_error)
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(3, 167, __pyx_L1_error)
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(3, 171, __pyx_L1_error)
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(3, 180, __pyx_L1_error)
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(3, 865, __pyx_L1_error)
  __pyx_ptype_8datetime_date = __Pyx_ImportType("datetime", "date", sizeof(PyDateTime_Date), 0); if (unlikely(!__pyx_ptype_8datetime_date)) __PYX_ERR(2, 16, __pyx_L1_error)
  __pyx_ptype_8datetime_datetime = __Pyx_ImportType("datetime", "datetime", sizeof(PyDateTime_DateTime), 0); if (unlikely(!__pyx_ptype_8datetime_datetime)) __PYX_ERR(2, 19, __pyx_L1_error)
  __pyx_ptype_8datetime_timedelta = __Pyx_ImportType("datetime", "timedelta", sizeof(PyDateTime_Delta), 0); if (unlikely(!__pyx_ptype_8datetime_timedelta)) __PYX_ERR(2, 22, __pyx_L1_error)
  /*--- Variable import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("pandas.tslib"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_nat_scalar_rules", (void **)&__pyx_vp_6pandas_5tslib__nat_scalar_rules, "int [6]") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*--- Function import code ---*/
  __pyx_t_2 = __Pyx_ImportModule("pandas.lib"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "is_null_datetimelike", (void (**)(void))&__pyx_f_6pandas_3lib_is_null_datetimelike, "int (PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "is_period", (void (**)(void))&__pyx_f_6pandas_3lib_is_period, "int (PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_ImportModule("pandas.tslib"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "maybe_get_tz", (void (**)(void))&__pyx_f_6pandas_5tslib_maybe_get_tz, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "_is_utc", (void (**)(void))&__pyx_f_6pandas_5tslib__is_utc, "int (PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "_is_tzlocal", (void (**)(void))&__pyx_f_6pandas_5tslib__is_tzlocal, "int (PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "_get_dst_info", (void (**)(void))&__pyx_f_6pandas_5tslib__get_dst_info, "PyObject *(PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "pandas/src/period.pyx":1
 * from datetime import datetime, date, timedelta             # <<<<<<<<<<<<<<
 * import operator
 * 
 */
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_datetime);
  __Pyx_GIVEREF(__pyx_n_s_datetime);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_datetime);
  __Pyx_INCREF(__pyx_n_s_date);
  __Pyx_GIVEREF(__pyx_n_s_date);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_date);
  __Pyx_INCREF(__pyx_n_s_timedelta);
  __Pyx_GIVEREF(__pyx_n_s_timedelta);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_s_timedelta);
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_datetime, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":2
 * from datetime import datetime, date, timedelta
 * import operator             # <<<<<<<<<<<<<<
 * 
 * from cpython cimport (
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_operator, 0, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_operator, __pyx_t_5) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":11
 * from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray,
 *                     NPY_INT64, NPY_DATETIME, NPY_TIMEDELTA)
 * import numpy as np             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "datetime_helper.h":
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_5) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":18
 * from libc.stdlib cimport free
 * 
 * from pandas import compat             # <<<<<<<<<<<<<<
 * 
 * from pandas.tseries import offsets
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_s_compat);
  __Pyx_GIVEREF(__pyx_n_s_compat);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_compat);
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_pandas, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_compat); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compat, __pyx_t_5) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":20
 * from pandas import compat
 * 
 * from pandas.tseries import offsets             # <<<<<<<<<<<<<<
 * from pandas.tseries.tools import parse_time_string
 * 
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_offsets);
  __Pyx_GIVEREF(__pyx_n_s_offsets);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_offsets);
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_pandas_tseries, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_offsets); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_offsets, __pyx_t_4) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":21
 * 
 * from pandas.tseries import offsets
 * from pandas.tseries.tools import parse_time_string             # <<<<<<<<<<<<<<
 * 
 * cimport cython
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_s_parse_time_string);
  __Pyx_GIVEREF(__pyx_n_s_parse_time_string);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_parse_time_string);
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_pandas_tseries_tools, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_parse_time_string); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_time_string, __pyx_t_5) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":28
 * cimport lib
 * from lib cimport is_null_datetimelike, is_period
 * import lib             # <<<<<<<<<<<<<<
 * from pandas import tslib
 * from tslib import Timedelta, Timestamp, iNaT, NaT
 */
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_lib, 0, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_lib, __pyx_t_4) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":29
 * from lib cimport is_null_datetimelike, is_period
 * import lib
 * from pandas import tslib             # <<<<<<<<<<<<<<
 * from tslib import Timedelta, Timestamp, iNaT, NaT
 * from tslib import have_pytz, _get_utcoffset
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_tslib);
  __Pyx_GIVEREF(__pyx_n_s_tslib);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_tslib);
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_pandas, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_tslib); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_tslib, __pyx_t_4) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":30
 * import lib
 * from pandas import tslib
 * from tslib import Timedelta, Timestamp, iNaT, NaT             # <<<<<<<<<<<<<<
 * from tslib import have_pytz, _get_utcoffset
 * from tslib cimport (
 */
  __pyx_t_5 = PyList_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_s_Timedelta);
  __Pyx_GIVEREF(__pyx_n_s_Timedelta);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_Timedelta);
  __Pyx_INCREF(__pyx_n_s_Timestamp);
  __Pyx_GIVEREF(__pyx_n_s_Timestamp);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_Timestamp);
  __Pyx_INCREF(__pyx_n_s_iNaT);
  __Pyx_GIVEREF(__pyx_n_s_iNaT);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_n_s_iNaT);
  __Pyx_INCREF(__pyx_n_s_NaT);
  __Pyx_GIVEREF(__pyx_n_s_NaT);
  PyList_SET_ITEM(__pyx_t_5, 3, __pyx_n_s_NaT);
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_tslib, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Timedelta); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timedelta, __pyx_t_5) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Timestamp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timestamp, __pyx_t_5) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_iNaT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iNaT, __pyx_t_5) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_NaT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_NaT, __pyx_t_5) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":31
 * from pandas import tslib
 * from tslib import Timedelta, Timestamp, iNaT, NaT
 * from tslib import have_pytz, _get_utcoffset             # <<<<<<<<<<<<<<
 * from tslib cimport (
 *     maybe_get_tz,
 */
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_have_pytz);
  __Pyx_GIVEREF(__pyx_n_s_have_pytz);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_have_pytz);
  __Pyx_INCREF(__pyx_n_s_get_utcoffset);
  __Pyx_GIVEREF(__pyx_n_s_get_utcoffset);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_get_utcoffset);
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_tslib, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_have_pytz); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_have_pytz, __pyx_t_4) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_get_utcoffset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_utcoffset, __pyx_t_4) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":40
 * )
 * 
 * from pandas.tseries import frequencies             # <<<<<<<<<<<<<<
 * 
 * from sys import version_info
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_s_frequencies);
  __Pyx_GIVEREF(__pyx_n_s_frequencies);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_frequencies);
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_pandas_tseries, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_frequencies, __pyx_t_5) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":42
 * from pandas.tseries import frequencies
 * 
 * from sys import version_info             # <<<<<<<<<<<<<<
 * 
 * cdef bint PY2 = version_info[0] == 2
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_version_info);
  __Pyx_GIVEREF(__pyx_n_s_version_info);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_version_info);
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_sys, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_version_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_version_info, __pyx_t_4) < 0) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":44
 * from sys import version_info
 * 
 * cdef bint PY2 = version_info[0] == 2             # <<<<<<<<<<<<<<
 * 
 * cdef int64_t NPY_NAT = util.get_nat()
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_6pandas_7_period_PY2 = __pyx_t_6;

  /* "pandas/src/period.pyx":46
 * cdef bint PY2 = version_info[0] == 2
 * 
 * cdef int64_t NPY_NAT = util.get_nat()             # <<<<<<<<<<<<<<
 * 
 * cdef int US_RESO = frequencies.US_RESO
 */
  __pyx_v_6pandas_7_period_NPY_NAT = get_nat();

  /* "pandas/src/period.pyx":48
 * cdef int64_t NPY_NAT = util.get_nat()
 * 
 * cdef int US_RESO = frequencies.US_RESO             # <<<<<<<<<<<<<<
 * cdef int MS_RESO = frequencies.MS_RESO
 * cdef int S_RESO = frequencies.S_RESO
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_US_RESO); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_6pandas_7_period_US_RESO = __pyx_t_7;

  /* "pandas/src/period.pyx":49
 * 
 * cdef int US_RESO = frequencies.US_RESO
 * cdef int MS_RESO = frequencies.MS_RESO             # <<<<<<<<<<<<<<
 * cdef int S_RESO = frequencies.S_RESO
 * cdef int T_RESO = frequencies.T_RESO
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_MS_RESO); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_6pandas_7_period_MS_RESO = __pyx_t_7;

  /* "pandas/src/period.pyx":50
 * cdef int US_RESO = frequencies.US_RESO
 * cdef int MS_RESO = frequencies.MS_RESO
 * cdef int S_RESO = frequencies.S_RESO             # <<<<<<<<<<<<<<
 * cdef int T_RESO = frequencies.T_RESO
 * cdef int H_RESO = frequencies.H_RESO
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_S_RESO); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_6pandas_7_period_S_RESO = __pyx_t_7;

  /* "pandas/src/period.pyx":51
 * cdef int MS_RESO = frequencies.MS_RESO
 * cdef int S_RESO = frequencies.S_RESO
 * cdef int T_RESO = frequencies.T_RESO             # <<<<<<<<<<<<<<
 * cdef int H_RESO = frequencies.H_RESO
 * cdef int D_RESO = frequencies.D_RESO
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_T_RESO); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_6pandas_7_period_T_RESO = __pyx_t_7;

  /* "pandas/src/period.pyx":52
 * cdef int S_RESO = frequencies.S_RESO
 * cdef int T_RESO = frequencies.T_RESO
 * cdef int H_RESO = frequencies.H_RESO             # <<<<<<<<<<<<<<
 * cdef int D_RESO = frequencies.D_RESO
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_H_RESO); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_6pandas_7_period_H_RESO = __pyx_t_7;

  /* "pandas/src/period.pyx":53
 * cdef int T_RESO = frequencies.T_RESO
 * cdef int H_RESO = frequencies.H_RESO
 * cdef int D_RESO = frequencies.D_RESO             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "period_helper.h":
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_frequencies); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_D_RESO); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_6pandas_7_period_D_RESO = __pyx_t_7;

  /* "pandas/src/period.pyx":116
 *     int get_yq(int64_t ordinal, int freq, int *quarter, int *year)
 * 
 * initialize_daytime_conversion_factor_matrix()             # <<<<<<<<<<<<<<
 * 
 * # Period logic
 */
  initialize_daytime_conversion_factor_matrix();

  /* "pandas/src/period.pyx":144
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def dt64arr_to_periodarr(ndarray[int64_t] dtarr, int freq, tz=None):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array of datetime64 values (passed in as 'i8' dtype) to a set of
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_1dt64arr_to_periodarr, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_dt64arr_to_periodarr, __pyx_t_5) < 0) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":175
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def periodarr_to_dt64arr(ndarray[int64_t] periodarr, int freq):             # <<<<<<<<<<<<<<
 *     """
 *     Convert array to datetime64 values from a set of ordinals corresponding to
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_3periodarr_to_dt64arr, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_periodarr_to_dt64arr, __pyx_t_5) < 0) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":197
 *     return out
 * 
 * cdef char START = 'S'             # <<<<<<<<<<<<<<
 * cdef char END = 'E'
 * 
 */
  __pyx_v_6pandas_7_period_START = 'S';

  /* "pandas/src/period.pyx":198
 * 
 * cdef char START = 'S'
 * cdef char END = 'E'             # <<<<<<<<<<<<<<
 * 
 * cpdef int64_t period_asfreq(int64_t period_ordinal, int freq1, int freq2,
 */
  __pyx_v_6pandas_7_period_END = 'E';

  /* "pandas/src/period.pyx":223
 * 
 * 
 * def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end):             # <<<<<<<<<<<<<<
 *     """
 *     Convert int64-array of period ordinals from one frequency to another, and
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_7period_asfreq_arr, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_period_asfreq_arr, __pyx_t_5) < 0) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":266
 * 
 * 
 * def period_ordinal(int y, int m, int d, int h, int min,             # <<<<<<<<<<<<<<
 *                    int s, int us, int ps, int freq):
 *     cdef:
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_9period_ordinal, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_period_ordinal, __pyx_t_5) < 0) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":298
 * 
 * 
 * def period_format(int64_t value, int freq, object fmt=None):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int freq_group
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_13period_format, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_period_format, __pyx_t_5) < 0) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":339
 * 
 * 
 * cdef list extra_fmts = [(b"%q", b"^`AB`^"),             # <<<<<<<<<<<<<<
 *                         (b"%f", b"^`CD`^"),
 *                         (b"%F", b"^`EF`^"),
 */
  __pyx_t_5 = PyList_New(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_tuple__37);
  __Pyx_INCREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_tuple__38);
  __Pyx_INCREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_tuple__39);
  __Pyx_INCREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);
  PyList_SET_ITEM(__pyx_t_5, 3, __pyx_tuple__40);
  __Pyx_INCREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  PyList_SET_ITEM(__pyx_t_5, 4, __pyx_tuple__41);
  __Pyx_INCREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);
  PyList_SET_ITEM(__pyx_t_5, 5, __pyx_tuple__42);
  __Pyx_XGOTREF(__pyx_v_6pandas_7_period_extra_fmts);
  __Pyx_DECREF_SET(__pyx_v_6pandas_7_period_extra_fmts, ((PyObject*)__pyx_t_5));
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":346
 *                         (b"%n", b"^`KL`^")]
 * 
 * cdef list str_extra_fmts = ["^`AB`^", "^`CD`^", "^`EF`^",             # <<<<<<<<<<<<<<
 *                             "^`GH`^", "^`IJ`^", "^`KL`^"]
 * 
 */
  __pyx_t_5 = PyList_New(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_kp_s_AB);
  __Pyx_GIVEREF(__pyx_kp_s_AB);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_kp_s_AB);
  __Pyx_INCREF(__pyx_kp_s_CD);
  __Pyx_GIVEREF(__pyx_kp_s_CD);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_kp_s_CD);
  __Pyx_INCREF(__pyx_kp_s_EF);
  __Pyx_GIVEREF(__pyx_kp_s_EF);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_kp_s_EF);
  __Pyx_INCREF(__pyx_kp_s_GH);
  __Pyx_GIVEREF(__pyx_kp_s_GH);
  PyList_SET_ITEM(__pyx_t_5, 3, __pyx_kp_s_GH);
  __Pyx_INCREF(__pyx_kp_s_IJ);
  __Pyx_GIVEREF(__pyx_kp_s_IJ);
  PyList_SET_ITEM(__pyx_t_5, 4, __pyx_kp_s_IJ);
  __Pyx_INCREF(__pyx_kp_s_KL);
  __Pyx_GIVEREF(__pyx_kp_s_KL);
  PyList_SET_ITEM(__pyx_t_5, 5, __pyx_kp_s_KL);
  __Pyx_XGOTREF(__pyx_v_6pandas_7_period_str_extra_fmts);
  __Pyx_DECREF_SET(__pyx_v_6pandas_7_period_str_extra_fmts, ((PyObject*)__pyx_t_5));
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":406
 * 
 * 
 * def get_period_field(int code, int64_t value, int freq):             # <<<<<<<<<<<<<<
 *     cdef accessor f = _get_accessor_func(code)
 *     if f is NULL:
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_15get_period_field, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_period_field, __pyx_t_5) < 0) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":415
 * 
 * 
 * def get_period_field_arr(int code, ndarray[int64_t] arr, int freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, sz
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_17get_period_field_arr, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_period_field_arr, __pyx_t_5) < 0) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":465
 * 
 * 
 * def extract_ordinals(ndarray[object] values, freq):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_19extract_ordinals, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_extract_ordinals, __pyx_t_5) < 0) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":497
 * 
 * 
 * def extract_freq(ndarray[object] values):             # <<<<<<<<<<<<<<
 *     cdef:
 *         Py_ssize_t i, n = len(values)
 */
  __pyx_t_5 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_21extract_freq, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_extract_freq, __pyx_t_5) < 0) __PYX_ERR(0, 497, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":681
 * 
 * 
 * _DIFFERENT_FREQ = "Input has different freq={1} from Period(freq={0})"             # <<<<<<<<<<<<<<
 * _DIFFERENT_FREQ_INDEX = ("Input has different freq={1} "
 *                          "from PeriodIndex(freq={0})")
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DIFFERENT_FREQ, __pyx_kp_s_Input_has_different_freq_1_from) < 0) __PYX_ERR(0, 681, __pyx_L1_error)

  /* "pandas/src/period.pyx":682
 * 
 * _DIFFERENT_FREQ = "Input has different freq={1} from Period(freq={0})"
 * _DIFFERENT_FREQ_INDEX = ("Input has different freq={1} "             # <<<<<<<<<<<<<<
 *                          "from PeriodIndex(freq={0})")
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DIFFERENT_FREQ_INDEX, __pyx_kp_s_Input_has_different_freq_1_from_2) < 0) __PYX_ERR(0, 682, __pyx_L1_error)

  /* "pandas/src/period.pyx":686
 * 
 * 
 * class IncompatibleFrequency(ValueError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_builtin_ValueError);
  __Pyx_GIVEREF(__pyx_builtin_ValueError);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_builtin_ValueError);
  __pyx_t_4 = __Pyx_CalculateMetaclass(NULL, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = __Pyx_Py3MetaclassPrepare(__pyx_t_4, __pyx_t_5, __pyx_n_s_IncompatibleFrequency, __pyx_n_s_IncompatibleFrequency, (PyObject *) NULL, __pyx_n_s_pandas__period, (PyObject *) NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_4, __pyx_n_s_IncompatibleFrequency, __pyx_t_5, __pyx_t_8, NULL, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_IncompatibleFrequency, __pyx_t_9) < 0) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pandas/src/period.pyx":696
 *         object freq
 * 
 *     _comparables = ['name', 'freqstr']             # <<<<<<<<<<<<<<
 *     _typ = 'period'
 * 
 */
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_s_name_2);
  __Pyx_GIVEREF(__pyx_n_s_name_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_name_2);
  __Pyx_INCREF(__pyx_n_s_freqstr);
  __Pyx_GIVEREF(__pyx_n_s_freqstr);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_freqstr);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6pandas_7_period__Period->tp_dict, __pyx_n_s_comparables, __pyx_t_5) < 0) __PYX_ERR(0, 696, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_6pandas_7_period__Period);

  /* "pandas/src/period.pyx":697
 * 
 *     _comparables = ['name', 'freqstr']
 *     _typ = 'period'             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6pandas_7_period__Period->tp_dict, __pyx_n_s_typ, __pyx_n_s_period) < 0) __PYX_ERR(0, 697, __pyx_L1_error)
  PyType_Modified(__pyx_ptype_6pandas_7_period__Period);

  /* "pandas/src/period.pyx":700
 * 
 *     @classmethod
 *     def _maybe_convert_freq(cls, object freq):             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(freq, (int, tuple)):
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6pandas_7_period__Period, __pyx_n_s_maybe_convert_freq); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 700, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "pandas/src/period.pyx":699
 *     _typ = 'period'
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def _maybe_convert_freq(cls, object freq):
 * 
 */
  __pyx_t_4 = __Pyx_Method_ClassMethod(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6pandas_7_period__Period->tp_dict, __pyx_n_s_maybe_convert_freq, __pyx_t_4) < 0) __PYX_ERR(0, 700, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_6pandas_7_period__Period);

  /* "pandas/src/period.pyx":715
 * 
 *     @classmethod
 *     def _from_ordinal(cls, ordinal, freq):             # <<<<<<<<<<<<<<
 *         """
 *         Fast creation from an ordinal and freq that are already validated!
 */
  __pyx_t_4 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6pandas_7_period__Period, __pyx_n_s_from_ordinal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "pandas/src/period.pyx":714
 *         return freq
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def _from_ordinal(cls, ordinal, freq):
 *         """
 */
  __pyx_t_5 = __Pyx_Method_ClassMethod(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6pandas_7_period__Period->tp_dict, __pyx_n_s_from_ordinal, __pyx_t_5) < 0) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_6pandas_7_period__Period);

  /* "pandas/src/period.pyx":944
 * 
 *     @classmethod
 *     def now(cls, freq=None):             # <<<<<<<<<<<<<<
 *         return Period(datetime.now(), freq=freq)
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6pandas_7_period__Period, __pyx_n_s_now); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "pandas/src/period.pyx":943
 *             return bool(is_leapyear(self._field(0)))
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def now(cls, freq=None):
 *         return Period(datetime.now(), freq=freq)
 */
  __pyx_t_4 = __Pyx_Method_ClassMethod(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 943, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_6pandas_7_period__Period->tp_dict, __pyx_n_s_now, __pyx_t_4) < 0) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_6pandas_7_period__Period);

  /* "pandas/src/period.pyx":1121
 * 
 * 
 * class Period(_Period):             # <<<<<<<<<<<<<<
 *     """
 *     Represents an period of time
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_6pandas_7_period__Period));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_6pandas_7_period__Period));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_ptype_6pandas_7_period__Period));
  __pyx_t_5 = __Pyx_CalculateMetaclass(NULL, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __Pyx_Py3MetaclassPrepare(__pyx_t_5, __pyx_t_4, __pyx_n_s_Period, __pyx_n_s_Period, (PyObject *) NULL, __pyx_n_s_pandas__period, __pyx_kp_s_Represents_an_period_of_time_Pa); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "pandas/src/period.pyx":1140
 *     """
 * 
 *     def __new__(cls, value=None, freq=None, ordinal=None,             # <<<<<<<<<<<<<<
 *                 year=None, month=None, quarter=None, day=None,
 *                 hour=None, minute=None, second=None):
 */
  __pyx_t_9 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6pandas_7_period_6Period_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_Period___new, NULL, __pyx_n_s_pandas__period, __pyx_d, ((PyObject *)__pyx_codeobj__53)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_9, __pyx_tuple__54);
  if (PyObject_SetItem(__pyx_t_8, __pyx_n_s_new, __pyx_t_9) < 0) __PYX_ERR(0, 1140, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "pandas/src/period.pyx":1121
 * 
 * 
 * class Period(_Period):             # <<<<<<<<<<<<<<
 *     """
 *     Represents an period of time
 */
  __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_5, __pyx_n_s_Period, __pyx_t_4, __pyx_t_8, NULL, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Period, __pyx_t_9) < 0) __PYX_ERR(0, 1121, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":1233
 * 
 * 
 * def _ordinal_from_fields(year, month, quarter, day,             # <<<<<<<<<<<<<<
 *                          hour, minute, second, freq):
 *     base, mult = frequencies.get_freq_code(freq)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_25_ordinal_from_fields, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ordinal_from_fields, __pyx_t_4) < 0) __PYX_ERR(0, 1233, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":1243
 * 
 * 
 * def _quarter_to_myear(year, quarter, freq):             # <<<<<<<<<<<<<<
 *     if quarter is not None:
 *         if quarter <= 0 or quarter > 4:
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_27_quarter_to_myear, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_quarter_to_myear, __pyx_t_4) < 0) __PYX_ERR(0, 1243, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":1257
 * 
 * 
 * def _validate_end_alias(how):             # <<<<<<<<<<<<<<
 *     how_dict = {'S': 'S', 'E': 'E',
 *                 'START': 'S', 'FINISH': 'E',
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_6pandas_7_period_29_validate_end_alias, NULL, __pyx_n_s_pandas__period); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_end_alias, __pyx_t_4) < 0) __PYX_ERR(0, 1257, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pandas/src/period.pyx":1
 * from datetime import datetime, date, timedelta             # <<<<<<<<<<<<<<
 * import operator
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_kp_u_Period_strftime_line_980, __pyx_kp_u_Returns_the_string_representati) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "numpy.pxd":980
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init pandas._period", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init pandas._period");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* None */
static CYTHON_INLINE __pyx_t_5numpy_int64_t __Pyx_div___pyx_t_5numpy_int64_t(__pyx_t_5numpy_int64_t a, __pyx_t_5numpy_int64_t b) {
    __pyx_t_5numpy_int64_t q = a / b;
    __pyx_t_5numpy_int64_t r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* PyErrFetchRestore */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* ArgTypeTest */
static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

/* BufferFormatCheck */
static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
  unsigned int n = 1;
  return *(unsigned char*)(&n) != 0;
}
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1)
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'c': return "'char'";
    case 'b': return "'signed char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c':
        return 'H';
    case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
      } else {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
      }
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count;
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break;
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue;
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static CYTHON_INLINE PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number;
    int ndim = ctx->head->field->type->ndim;
;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    while (*ts && *ts != ')') {
        switch (*ts) {
            case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
            default:  break;
        }
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        return ts;
      case ' ':
      case '\r':
      case '\n':
        ++ts;
        break;
      case '<':
        if (!__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T':
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}':
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
          ctx->new_count = 1;
          got_Z = 0;
          ++ts;
          break;
        }
      case 's':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->enc_count = ctx->new_count;
        ctx->enc_packmode = ctx->new_packmode;
        ctx->enc_type = *ts;
        ctx->is_complex = got_Z;
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  if (obj == Py_None || obj == NULL) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if ((unsigned)buf->itemsize != dtype->size) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

/* GetModuleGlobalName */
  static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

/* PyObjectCall */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* ExtTypeTest */
    static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* BufferFallbackError */
    static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_SetString(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}

/* RaiseException */
    #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* PyObjectCallMethO */
      #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
      #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCallNoArg */
        #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* BufferIndexError */
          static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}

/* None */
          static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* Import */
          static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* GetItemInt */
          static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* SetItemInt */
          static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* None */
            static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
    long r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

/* None */
            static CYTHON_INLINE __pyx_t_5numpy_int64_t __Pyx_mod___pyx_t_5numpy_int64_t(__pyx_t_5numpy_int64_t a, __pyx_t_5numpy_int64_t b) {
    __pyx_t_5numpy_int64_t r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

/* None */
            static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* SaveResetException */
            #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
            #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    return PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
            #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
#endif
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* PyIntFromDouble */
              #if PY_MAJOR_VERSION < 3
static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value) {
    if (value >= (double)LONG_MIN && value <= (double)LONG_MAX) {
        return PyInt_FromLong((long)value);
    }
    return PyLong_FromDouble(value);
}
#endif

/* RaiseTooManyValuesToUnpack */
              static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
              static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
              static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
              static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* PyIntBinop */
              #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* BytesEquals */
              static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
              static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* PyIntBinop */
              #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
                default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
                #else
                default: Py_RETURN_FALSE;
                #endif
            }
        }
            if (a == b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            if ((double)a == (double)b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    return PyObject_RichCompare(op1, op2, Py_EQ);
}
#endif

/* GetAttr */
              static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
              static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            goto bad;
        PyErr_Clear();
        r = d;
        Py_INCREF(d);
    }
    return r;
bad:
    return NULL;
}

/* PyIntBinop */
              #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* PyIntBinop */
              #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = a % b;
            x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_remainder(op1, op2);
            }
        }
                x = a % b;
                x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla % llb;
                llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    return (inplace ? PyNumber_InPlaceRemainder : PyNumber_Remainder)(op1, op2);
}
#endif

/* dict_getitem_default */
              static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        if (default_value == Py_None)
            default_value = NULL;
        value = PyObject_CallMethodObjArgs(
            d, __pyx_n_s_get, key, default_value, NULL);
    }
#endif
    return value;
}

/* RaiseNoneIterError */
              static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* SetVTable */
              static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* ImportFrom */
              static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* CalculateMetaclass */
              static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* Py3ClassCreate */
              static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* GetNameInClass */
              static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result)
        result = __Pyx_GetModuleGlobalName(name);
    return result;
}

/* FetchCommonType */
              static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunction */
              static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_COMPILING_IN_CPYTHON
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    PyObject *self = f->m_self;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0 = PySequence_ITEM(arg, 0);
                if (unlikely(!arg0)) return NULL;
                result = (*meth)(self, arg0);
                Py_DECREF(arg0);
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
	return PyCFunction_Call(func, arg, kw);
}
#endif
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_Call,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
#if !CYTHON_COMPILING_IN_PYPY
    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (__pyx_CyFunctionType == NULL) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* CodeObjectCache */
                  static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
                  #include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
    PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
    return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    if (!obj) return;
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
    Py_DECREF(obj);
    view->obj = NULL;
}
#endif


                  /* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPyVerify */
                  #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int64(npy_int64 value) {
    const npy_int64 neg_one = (npy_int64) -1, const_zero = (npy_int64) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(npy_int64) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(npy_int64) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(npy_int64) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(npy_int64) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(npy_int64) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(npy_int64),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int32(npy_int32 value) {
    const npy_int32 neg_one = (npy_int32) -1, const_zero = (npy_int32) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(npy_int32) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(npy_int32) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(npy_int32) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(npy_int32) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(npy_int32) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(npy_int32),
                                     little, !is_unsigned);
    }
}

/* ClassMethod */
                  static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY
    if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
        return PyClassMethod_New(method);
    }
#else
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    if (PyObject_TypeCheck(method, methoddescr_type)) {
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
#endif
    else if (PyMethod_Check(method)) {
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else if (PyCFunction_Check(method)) {
        return PyClassMethod_New(method);
    }
#ifdef __Pyx_CyFunction_USED
    else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) {
        return PyClassMethod_New(method);
    }
#endif
    PyErr_SetString(PyExc_TypeError,
                   "Class-level classmethod() can only be called on "
                   "a method_descriptor or instance method.");
    return NULL;
}

/* None */
                  #if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* None */
                  #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        float denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(a, a);
                    case 3:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, a);
                    case 4:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_absf(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

/* None */
                  #if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* None */
                  #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        double denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(a, a);
                    case 3:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, a);
                    case 4:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_abs(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ptrdiff_t(ptrdiff_t value) {
    const ptrdiff_t neg_one = (ptrdiff_t) -1, const_zero = (ptrdiff_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(ptrdiff_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(ptrdiff_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(ptrdiff_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(ptrdiff_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(ptrdiff_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(ptrdiff_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) {
    const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum NPY_TYPES) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(enum NPY_TYPES) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
                  static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
                  static CYTHON_INLINE npy_int64 __Pyx_PyInt_As_npy_int64(PyObject *x) {
    const npy_int64 neg_one = (npy_int64) -1, const_zero = (npy_int64) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(npy_int64) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(npy_int64, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (npy_int64) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (npy_int64) 0;
                case  1: __PYX_VERIFY_RETURN_INT(npy_int64, digit, digits[0])
                case 2:
                    if (8 * sizeof(npy_int64) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) >= 2 * PyLong_SHIFT) {
                            return (npy_int64) (((((npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(npy_int64) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) >= 3 * PyLong_SHIFT) {
                            return (npy_int64) (((((((npy_int64)digits[2]) << PyLong_SHIFT) | (npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(npy_int64) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) >= 4 * PyLong_SHIFT) {
                            return (npy_int64) (((((((((npy_int64)digits[3]) << PyLong_SHIFT) | (npy_int64)digits[2]) << PyLong_SHIFT) | (npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (npy_int64) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(npy_int64) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int64, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(npy_int64) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int64, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (npy_int64) 0;
                case -1: __PYX_VERIFY_RETURN_INT(npy_int64, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(npy_int64,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(npy_int64) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) - 1 > 2 * PyLong_SHIFT) {
                            return (npy_int64) (((npy_int64)-1)*(((((npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(npy_int64) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) - 1 > 2 * PyLong_SHIFT) {
                            return (npy_int64) ((((((npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(npy_int64) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) - 1 > 3 * PyLong_SHIFT) {
                            return (npy_int64) (((npy_int64)-1)*(((((((npy_int64)digits[2]) << PyLong_SHIFT) | (npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(npy_int64) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) - 1 > 3 * PyLong_SHIFT) {
                            return (npy_int64) ((((((((npy_int64)digits[2]) << PyLong_SHIFT) | (npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(npy_int64) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) - 1 > 4 * PyLong_SHIFT) {
                            return (npy_int64) (((npy_int64)-1)*(((((((((npy_int64)digits[3]) << PyLong_SHIFT) | (npy_int64)digits[2]) << PyLong_SHIFT) | (npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(npy_int64) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int64, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int64) - 1 > 4 * PyLong_SHIFT) {
                            return (npy_int64) ((((((((((npy_int64)digits[3]) << PyLong_SHIFT) | (npy_int64)digits[2]) << PyLong_SHIFT) | (npy_int64)digits[1]) << PyLong_SHIFT) | (npy_int64)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(npy_int64) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int64, long, PyLong_AsLong(x))
            } else if (sizeof(npy_int64) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int64, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            npy_int64 val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (npy_int64) -1;
        }
    } else {
        npy_int64 val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (npy_int64) -1;
        val = __Pyx_PyInt_As_npy_int64(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to npy_int64");
    return (npy_int64) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to npy_int64");
    return (npy_int64) -1;
}

/* CIntFromPy */
                  static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *x) {
    const npy_int32 neg_one = (npy_int32) -1, const_zero = (npy_int32) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(npy_int32) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(npy_int32, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (npy_int32) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (npy_int32) 0;
                case  1: __PYX_VERIFY_RETURN_INT(npy_int32, digit, digits[0])
                case 2:
                    if (8 * sizeof(npy_int32) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) >= 2 * PyLong_SHIFT) {
                            return (npy_int32) (((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(npy_int32) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) >= 3 * PyLong_SHIFT) {
                            return (npy_int32) (((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(npy_int32) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) >= 4 * PyLong_SHIFT) {
                            return (npy_int32) (((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (npy_int32) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(npy_int32) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(npy_int32) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (npy_int32) 0;
                case -1: __PYX_VERIFY_RETURN_INT(npy_int32, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(npy_int32,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(npy_int32) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
                            return (npy_int32) (((npy_int32)-1)*(((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(npy_int32) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
                            return (npy_int32) ((((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
                            return (npy_int32) (((npy_int32)-1)*(((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(npy_int32) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
                            return (npy_int32) ((((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 4 * PyLong_SHIFT) {
                            return (npy_int32) (((npy_int32)-1)*(((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(npy_int32) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 4 * PyLong_SHIFT) {
                            return (npy_int32) ((((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(npy_int32) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, long, PyLong_AsLong(x))
            } else if (sizeof(npy_int32) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            npy_int32 val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (npy_int32) -1;
        }
    } else {
        npy_int32 val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (npy_int32) -1;
        val = __Pyx_PyInt_As_npy_int32(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to npy_int32");
    return (npy_int32) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to npy_int32");
    return (npy_int32) -1;
}

/* CIntFromPy */
                  static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CheckBinaryVersion */
                  static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* ModuleImport */
                  #ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

/* TypeImport */
                  #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

/* VoidPtrImport */
                  #ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C variable %.200s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* FunctionImport */
                  #ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
                  static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return __Pyx_NewRef(x);
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
