/* Generated by Cython 0.27 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [], 
        "name": "pyteomics.cmass", 
        "sources": [
            "pyteomics/cmass.pyx"
        ]
    }, 
    "module_name": "pyteomics.cmass"
}
END: Cython Metadata */

#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 < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_27"
#define CYTHON_FUTURE_DIVISION 0
#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
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#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_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#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 < 0x030700A0 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03050200
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_Get()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #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
#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_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #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_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #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 PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #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_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #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_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #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
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#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_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
#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
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#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
#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_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #ifdef __cplusplus
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__))
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif 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; \
}

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

#define __PYX_HAVE__pyteomics__cmass
#define __PYX_HAVE_API__pyteomics__cmass
#include <string.h>
#include <stdio.h>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#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)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_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 const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const 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_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const 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)
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);
}
#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);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#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 CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime;
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;


static const char *__pyx_f[] = {
  "pyteomics\\cmass.pyx",
  "type.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_9pyteomics_5cmass_CComposition;
struct __pyx_opt_args_9pyteomics_7cparser_parse;
struct __pyx_opt_args_9pyteomics_7cparser_amino_acid_composition;
struct __pyx_opt_args_9pyteomics_7cparser_tostring;

/* "pyteomics/cparser.pxd":16
 * 
 * 
 * cpdef list parse(str sequence, bint show_unmodified_termini=*, bint split=*,             # <<<<<<<<<<<<<<
 *                  bint allow_unknown_modifications=*, object  labels=*)
 * 
 */
struct __pyx_opt_args_9pyteomics_7cparser_parse {
  int __pyx_n;
  int show_unmodified_termini;
  int split;
  int allow_unknown_modifications;
  PyObject *labels;
};

/* "pyteomics/cparser.pxd":19
 *                  bint allow_unknown_modifications=*, object  labels=*)
 * 
 * cpdef dict amino_acid_composition(object sequence, bint show_unmodified_termini=*, bint term_aa=*,             # <<<<<<<<<<<<<<
 *                                   bint allow_unknown_modifications=*, object labels=*)
 * 
 */
struct __pyx_opt_args_9pyteomics_7cparser_amino_acid_composition {
  int __pyx_n;
  int show_unmodified_termini;
  int term_aa;
  int allow_unknown_modifications;
  PyObject *labels;
};

/* "pyteomics/cparser.pxd":24
 * cpdef tuple _split_label(str label)
 * 
 * cdef str tostring(object parsed_sequence, bint show_unmodified_termini=*)             # <<<<<<<<<<<<<<
 */
struct __pyx_opt_args_9pyteomics_7cparser_tostring {
  int __pyx_n;
  int show_unmodified_termini;
};
struct __pyx_opt_args_9pyteomics_5cmass_fast_mass;
struct __pyx_opt_args_9pyteomics_5cmass_fast_mass2;
struct __pyx_opt_args_9pyteomics_5cmass_12CComposition_mass;
struct __pyx_opt_args_9pyteomics_5cmass__calculate_mass;

/* "pyteomics/cmass.pxd":15
 * #   limitations under the License.
 * 
 * cpdef double fast_mass(str sequence, str ion_type=*, int charge=*,             # <<<<<<<<<<<<<<
 *                        dict mass_data=*, dict aa_mass=*,
 *                        dict ion_comp=*)
 */
struct __pyx_opt_args_9pyteomics_5cmass_fast_mass {
  int __pyx_n;
  PyObject *ion_type;
  int charge;
  PyObject *mass_data;
  PyObject *aa_mass;
  PyObject *ion_comp;
};

/* "pyteomics/cmass.pxd":19
 *                        dict ion_comp=*)
 * 
 * cpdef double fast_mass2(str sequence, str ion_type=*, int charge=*,             # <<<<<<<<<<<<<<
 *                         dict mass_data=*, dict aa_mass=*,
 *                         dict ion_comp=*)
 */
struct __pyx_opt_args_9pyteomics_5cmass_fast_mass2 {
  int __pyx_n;
  PyObject *ion_type;
  int charge;
  PyObject *mass_data;
  PyObject *aa_mass;
  PyObject *ion_comp;
};

/* "pyteomics/cmass.pxd":27
 *     cdef tuple _mass_args
 *     cpdef CComposition clone(self)
 *     cpdef double mass(self, int average=?, charge=?, dict mass_data=?, ion_type=?) except -1             # <<<<<<<<<<<<<<
 *     cpdef _from_formula(self, str formula, dict mass_data)
 *     cpdef _from_dict(self, comp)
 */
struct __pyx_opt_args_9pyteomics_5cmass_12CComposition_mass {
  int __pyx_n;
  int average;
  PyObject *charge;
  PyObject *mass_data;
  PyObject *ion_type;
};

/* "pyteomics/cmass.pxd":41
 *     object formula_pattern
 * 
 *     cdef double _calculate_mass(CComposition composition,             # <<<<<<<<<<<<<<
 *                                 int average=*, charge=*, mass_data=*,
 *                                 ion_type=*) except -1
 */
struct __pyx_opt_args_9pyteomics_5cmass__calculate_mass {
  int __pyx_n;
  int average;
  PyObject *charge;
  PyObject *mass_data;
  PyObject *ion_type;
};

/* "pyteomics/cmass.pxd":23
 *                         dict ion_comp=*)
 * 
 * cdef class CComposition(dict):             # <<<<<<<<<<<<<<
 *     cdef object _mass
 *     cdef tuple _mass_args
 */
struct __pyx_obj_9pyteomics_5cmass_CComposition {
  PyDictObject __pyx_base;
  struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *__pyx_vtab;
  PyObject *_mass;
  PyObject *_mass_args;
};



/* "pyteomics/cmass.pyx":320
 * 
 * 
 * cdef class CComposition(dict):             # <<<<<<<<<<<<<<
 *     """
 *     A Composition object stores a chemical composition of a
 */

struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition {
  struct __pyx_obj_9pyteomics_5cmass_CComposition *(*clone)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, int __pyx_skip_dispatch);
  double (*mass)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_12CComposition_mass *__pyx_optional_args);
  PyObject *(*_from_formula)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_from_dict)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *, int __pyx_skip_dispatch);
  long (*getitem)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *);
  void (*setitem)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *, long);
};
static struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *__pyx_vtabptr_9pyteomics_5cmass_CComposition;
static long __pyx_f_9pyteomics_5cmass_12CComposition_getitem(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *);
static void __pyx_f_9pyteomics_5cmass_12CComposition_setitem(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *, long);

/* --- 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_USE_TYPE_SLOTS
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);

/* Profile.proto */
#ifndef CYTHON_PROFILE
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  #define CYTHON_PROFILE 0
#else
  #define CYTHON_PROFILE 1
#endif
#endif
#ifndef CYTHON_TRACE_NOGIL
  #define CYTHON_TRACE_NOGIL 0
#else
  #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
    #define CYTHON_TRACE 1
  #endif
#endif
#ifndef CYTHON_TRACE
  #define CYTHON_TRACE 0
#endif
#if CYTHON_TRACE
  #undef CYTHON_PROFILE_REUSE_FRAME
#endif
#ifndef CYTHON_PROFILE_REUSE_FRAME
  #define CYTHON_PROFILE_REUSE_FRAME 0
#endif
#if CYTHON_PROFILE || CYTHON_TRACE
  #include "compile.h"
  #include "frameobject.h"
  #include "traceback.h"
  #if CYTHON_PROFILE_REUSE_FRAME
    #define CYTHON_FRAME_MODIFIER static
    #define CYTHON_FRAME_DEL(frame)
  #else
    #define CYTHON_FRAME_MODIFIER
    #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
  #endif
  #define __Pyx_TraceDeclarations\
  static PyCodeObject *__pyx_frame_code = NULL;\
  CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;\
  int __Pyx_use_tracing = 0;
  #define __Pyx_TraceFrameInit(codeobj)\
  if (codeobj) __pyx_frame_code = (PyCodeObject*) codeobj;
  #ifdef WITH_THREAD
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  if (nogil) {\
      if (CYTHON_TRACE_NOGIL) {\
          PyThreadState *tstate;\
          PyGILState_STATE state = PyGILState_Ensure();\
          tstate = __Pyx_PyThreadState_Current;\
          if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
                  (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
              __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          }\
          PyGILState_Release(state);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  } else {\
      PyThreadState* tstate = PyThreadState_GET();\
      if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
              (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
          __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  }
  #else
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  {   PyThreadState* tstate = PyThreadState_GET();\
      if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
              (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
          __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  }
  #endif
  #define __Pyx_TraceException()\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (tstate->use_tracing &&\
              (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
          tstate->tracing++;\
          tstate->use_tracing = 0;\
          PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
          if (exc_info) {\
              if (CYTHON_TRACE && tstate->c_tracefunc)\
                  tstate->c_tracefunc(\
                      tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
              tstate->c_profilefunc(\
                  tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
              Py_DECREF(exc_info);\
          }\
          tstate->use_tracing = 1;\
          tstate->tracing--;\
      }\
  }
  static void __Pyx_call_return_trace_func(PyThreadState *tstate, PyFrameObject *frame, PyObject *result) {
      PyObject *type, *value, *traceback;
      PyErr_Fetch(&type, &value, &traceback);
      tstate->tracing++;
      tstate->use_tracing = 0;
      if (CYTHON_TRACE && tstate->c_tracefunc)
          tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_RETURN, result);
      if (tstate->c_profilefunc)
          tstate->c_profilefunc(tstate->c_profileobj, frame, PyTrace_RETURN, result);
      CYTHON_FRAME_DEL(frame);
      tstate->use_tracing = 1;
      tstate->tracing--;
      PyErr_Restore(type, value, traceback);
  }
  #ifdef WITH_THREAD
  #define __Pyx_TraceReturn(result, nogil)\
  if (likely(!__Pyx_use_tracing)); else {\
      if (nogil) {\
          if (CYTHON_TRACE_NOGIL) {\
              PyThreadState *tstate;\
              PyGILState_STATE state = PyGILState_Ensure();\
              tstate = __Pyx_PyThreadState_Current;\
              if (tstate->use_tracing) {\
                  __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
              }\
              PyGILState_Release(state);\
          }\
      } else {\
          PyThreadState* tstate = __Pyx_PyThreadState_Current;\
          if (tstate->use_tracing) {\
              __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
          }\
      }\
  }
  #else
  #define __Pyx_TraceReturn(result, nogil)\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (tstate->use_tracing) {\
          __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
      }\
  }
  #endif
  static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno);
  static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, PyThreadState* tstate, const char *funcname, const char *srcfile, int firstlineno);
#else
  #define __Pyx_TraceDeclarations
  #define __Pyx_TraceFrameInit(codeobj)
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)   if ((1)); else goto_error;
  #define __Pyx_TraceException()
  #define __Pyx_TraceReturn(result, nogil)
#endif
#if CYTHON_TRACE
  static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) {
      int ret;
      PyObject *type, *value, *traceback;
      PyErr_Fetch(&type, &value, &traceback);
      __Pyx_PyFrame_SetLineNumber(frame, lineno);
      tstate->tracing++;
      tstate->use_tracing = 0;
      ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL);
      tstate->use_tracing = 1;
      tstate->tracing--;
      if (likely(!ret)) {
          PyErr_Restore(type, value, traceback);
      } else {
          Py_XDECREF(type);
          Py_XDECREF(value);
          Py_XDECREF(traceback);
      }
      return ret;
  }
  #ifdef WITH_THREAD
  #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  if (likely(!__Pyx_use_tracing)); else {\
      if (nogil) {\
          if (CYTHON_TRACE_NOGIL) {\
              int ret = 0;\
              PyThreadState *tstate;\
              PyGILState_STATE state = PyGILState_Ensure();\
              tstate = __Pyx_PyThreadState_Current;\
              if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
                  ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
              }\
              PyGILState_Release(state);\
              if (unlikely(ret)) goto_error;\
          }\
      } else {\
          PyThreadState* tstate = __Pyx_PyThreadState_Current;\
          if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
              int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
              if (unlikely(ret)) goto_error;\
          }\
      }\
  }
  #else
  #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
          int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
          if (unlikely(ret)) goto_error;\
      }\
  }
  #endif
#else
  #define __Pyx_TraceLine(lineno, nogil, goto_error)   if ((1)); else goto_error;
#endif

/* 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

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#if PY_VERSION_HEX >= 0x03050000
  #define __Pyx_PyThreadState_assign  __pyx_tstate = _PyThreadState_UncheckedGet();
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_Get();
#elif PY_VERSION_HEX >= 0x02070000
  #define __Pyx_PyThreadState_assign  __pyx_tstate = _PyThreadState_Current;
#else
  #define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_Get();
#endif
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#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);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#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

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

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

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

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#endif

/* 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);

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

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

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#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_FAST_THREAD_STATE
#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_FAST_THREAD_STATE
#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

/* 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);

/* 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);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* StringJoin.proto */
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
#endif

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* 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 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);

/* 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

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* 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

/* 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));
}

/* 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);

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
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

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* KeywordStringCheck.proto */
static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
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

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
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

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

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

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

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

/* UnpackTupleError.proto */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

/* UnpackTuple2.proto */
#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
    (likely(is_tuple || PyTuple_Check(tuple)) ?\
        (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
            __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
            (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
        __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
    PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
static int __Pyx_unpack_tuple2_generic(
    PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);

/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

/* MergeKeywords.proto */
static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping);

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

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

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

/* CLineInTraceback.proto */
static int __Pyx_CLineForTraceback(int c_line);

/* 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);

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

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

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

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

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif

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

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#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

/* VoidPtrExport.proto */
static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);

/* FunctionExport.proto */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);

/* 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);

/* 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 long __pyx_f_9pyteomics_5cmass_12CComposition_getitem(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_elem); /* proto*/
static void __pyx_f_9pyteomics_5cmass_12CComposition_setitem(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_elem, long __pyx_v_val); /* proto*/
static struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_f_9pyteomics_5cmass_12CComposition_clone(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_9pyteomics_5cmass_12CComposition__from_formula(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_formula, PyObject *__pyx_v_mass_data, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_9pyteomics_5cmass_12CComposition__from_dict(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_comp, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_9pyteomics_5cmass_12CComposition_mass(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_12CComposition_mass *__pyx_optional_args); /* proto*/

/* Module declarations from 'cython' */

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

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

/* Module declarations from '__builtin__' */

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

/* Module declarations from 'cpython' */

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

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

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

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

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

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

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

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

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

/* Module declarations from 'pyteomics.cparser' */
static PyObject *(*__pyx_f_9pyteomics_7cparser_parse)(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_7cparser_parse *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_9pyteomics_7cparser_amino_acid_composition)(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_7cparser_amino_acid_composition *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_9pyteomics_7cparser__split_label)(PyObject *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'pyteomics.cmass' */
static PyTypeObject *__pyx_ptype_9pyteomics_5cmass_CComposition = 0;
static PyObject *__pyx_v_9pyteomics_5cmass__atom = 0;
static PyObject *__pyx_v_9pyteomics_5cmass__formula = 0;
static PyObject *__pyx_v_9pyteomics_5cmass__isotope_string = 0;
static PyObject *__pyx_v_9pyteomics_5cmass_isotope_pattern = 0;
static PyObject *__pyx_v_9pyteomics_5cmass_formula_pattern = 0;
static PyObject *__pyx_v_9pyteomics_5cmass_nist_mass = 0;
static PyObject *__pyx_v_9pyteomics_5cmass_std_aa_mass = 0;
static PyObject *__pyx_v_9pyteomics_5cmass_std_ion_comp = 0;
static PyObject *__pyx_v_9pyteomics_5cmass_std_aa_comp = 0;
static PyObject *__pyx_7genexpr__pyx_v_9pyteomics_5cmass_k;
static PyObject *__pyx_7genexpr__pyx_v_9pyteomics_5cmass_v;
static PyObject *__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k;
static PyObject *__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v;
static double __pyx_f_9pyteomics_5cmass_fast_mass(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_fast_mass *__pyx_optional_args); /*proto*/
static double __pyx_f_9pyteomics_5cmass_fast_mass2(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_fast_mass2 *__pyx_optional_args); /*proto*/
static double __pyx_f_9pyteomics_5cmass__calculate_mass(struct __pyx_obj_9pyteomics_5cmass_CComposition *, struct __pyx_opt_args_9pyteomics_5cmass__calculate_mass *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_9pyteomics_5cmass__parse_isotope_string(PyObject *, int *); /*proto*/
static PyObject *__pyx_f_9pyteomics_5cmass__make_isotope_string(PyObject *, int); /*proto*/
static CYTHON_INLINE double __pyx_f_9pyteomics_5cmass_get_mass(PyObject *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "pyteomics.cmass"
int __pyx_module_is_main_pyteomics__cmass = 0;

/* Implementation of 'pyteomics.cmass' */
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_round;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_sorted;
static PyObject *__pyx_builtin_id;
static const char __pyx_k_H[] = "H";
static const char __pyx_k_O[] = "O";
static const char __pyx_k_OH[] = "-OH";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_re[] = "re";
static const char __pyx_k_H_2[] = "H+";
static const char __pyx_k_H_3[] = "H-";
static const char __pyx_k__11[] = ", ";
static const char __pyx_k__13[] = "]";
static const char __pyx_k__14[] = "[";
static const char __pyx_k__15[] = "";
static const char __pyx_k__17[] = "(";
static const char __pyx_k__18[] = ")";
static const char __pyx_k__19[] = "-";
static const char __pyx_k__25[] = "^({})*$";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_len[] = "len";
static const char __pyx_k_s_d[] = "%s[%d]";
static const char __pyx_k_atom[] = "_atom";
static const char __pyx_k_from[] = "_from_";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mass[] = "mass";
static const char __pyx_k_repr[] = "__repr__";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_chain[] = "chain";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_clear[] = "clear";
static const char __pyx_k_clone[] = "clone";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_match[] = "match";
static const char __pyx_k_parse[] = "parse";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_rfind[] = "rfind";
static const char __pyx_k_round[] = "round";
static const char __pyx_k_state[] = "state";
static const char __pyx_k_charge[] = "charge";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_labels[] = "labels";
static const char __pyx_k_sorted[] = "sorted";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_aa_comp[] = "aa_comp";
static const char __pyx_k_aa_mass[] = "aa_mass";
static const char __pyx_k_average[] = "average";
static const char __pyx_k_compile[] = "compile";
static const char __pyx_k_cparser[] = "cparser";
static const char __pyx_k_findall[] = "findall";
static const char __pyx_k_formula[] = "formula";
static const char __pyx_k_isdigit[] = "isdigit";
static const char __pyx_k_reverse[] = "reverse";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_endswith[] = "endswith";
static const char __pyx_k_ion_comp[] = "ion_comp";
static const char __pyx_k_ion_type[] = "ion_type";
static const char __pyx_k_pyx_capi[] = "__pyx_capi__";
static const char __pyx_k_sequence[] = "sequence";
static const char __pyx_k_tostring[] = "tostring";
static const char __pyx_k_A_Z_a_z_d[] = "^([A-Z][a-z+]*)(?:\\[(\\d+)\\])?$";
static const char __pyx_k_formula_2[] = "_formula";
static const char __pyx_k_from_dict[] = "_from_dict";
static const char __pyx_k_itertools[] = "itertools";
static const char __pyx_k_mass_data[] = "mass_data";
static const char __pyx_k_nist_mass[] = "_nist_mass";
static const char __pyx_k_pyteomics[] = "pyteomics";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_difference[] = "difference";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_A_Z_a_z_d_d[] = "([A-Z][a-z+]*)(?:\\[(\\d+)\\])?([+-]?\\d+)?";
static const char __pyx_k_Composition[] = "Composition({})";
static const char __pyx_k_collections[] = "collections";
static const char __pyx_k_composition[] = "composition";
static const char __pyx_k_defaultdict[] = "defaultdict";
static const char __pyx_k_split_label[] = "_split_label";
static const char __pyx_k_std_aa_comp[] = "std_aa_comp";
static const char __pyx_k_std_aa_mass[] = "std_aa_mass";
static const char __pyx_k_from_formula[] = "_from_formula";
static const char __pyx_k_intersection[] = "intersection";
static const char __pyx_k_std_ion_comp[] = "std_ion_comp";
static const char __pyx_k_Composition_2[] = "Composition";
static const char __pyx_k_from_sequence[] = "_from_sequence";
static const char __pyx_k_get_constants[] = "__get_constants";
static const char __pyx_k_std_aa_comp_2[] = "_std_aa_comp";
static const char __pyx_k_std_aa_mass_2[] = "_std_aa_mass";
static const char __pyx_k_NotImplemented[] = "NotImplemented";
static const char __pyx_k_PyteomicsError[] = "PyteomicsError";
static const char __pyx_k_calculate_mass[] = "calculate_mass";
static const char __pyx_k_isotope_string[] = "_isotope_string";
static const char __pyx_k_pyteomics_mass[] = "pyteomics.mass";
static const char __pyx_k_split_sequence[] = "split_sequence";
static const char __pyx_k_std_ion_comp_2[] = "_std_ion_comp";
static const char __pyx_k_Invalid_formula[] = "Invalid formula: ";
static const char __pyx_k_formula_pattern[] = "formula_pattern";
static const char __pyx_k_isotope_pattern[] = "isotope_pattern";
static const char __pyx_k_parsed_sequence[] = "parsed_sequence";
static const char __pyx_k_pyteomics_cmass[] = "pyteomics.cmass";
static const char __pyx_k_Unknown_ion_type[] = "Unknown ion type: {}";
static const char __pyx_k_Unknown_ion_type_2[] = "Unknown ion_type: {}";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_from_formula_parens[] = "_from_formula_parens";
static const char __pyx_k_pyteomics_auxiliary[] = "pyteomics.auxiliary";
static const char __pyx_k_pyteomics_cmass_pyx[] = "pyteomics\\cmass.pyx";
static const char __pyx_k_from_parsed_sequence[] = "_from_parsed_sequence";
static const char __pyx_k_marshal_ccomposition[] = "marshal_ccomposition";
static const char __pyx_k_amino_acid_composition[] = "amino_acid_composition";
static const char __pyx_k_show_unmodified_termini[] = "show_unmodified_termini";
static const char __pyx_k_Unknown_chemical_element[] = "Unknown chemical element: ";
static const char __pyx_k_No_mass_data_for_residue_r[] = "No mass data for residue: %r";
static const char __pyx_k_allow_unknown_modifications[] = "allow_unknown_modifications";
static const char __pyx_k_Badly_formed_isotope_number_s[] = "Badly-formed isotope number: %s";
static const char __pyx_k_Badly_formed_number_of_atoms_s[] = "Badly-formed number of atoms: %s";
static const char __pyx_k_Mass_not_specified_for_label_s[] = "Mass not specified for label(s): {}";
static const char __pyx_k_An_error_occurred_in_cmass_fast[] = "An error occurred in cmass.fast_mass";
static const char __pyx_k_Charge_is_specified_both_by_the[] = "Charge is specified both by the number of protons and parameters";
static const char __pyx_k_No_information_for_s_in_aa_comp[] = "No information for %s in `aa_comp`";
static const char __pyx_k_Unknown_chemical_element_in_the[] = "Unknown chemical element in the formula: %s";
static const char __pyx_k_Cannot_multiply_Composition_by_n[] = "Cannot multiply Composition by non-integer";
static const char __pyx_k_Could_not_create_a_Composition_o[] = "Could not create a Composition object from string: \"{}\": not a valid sequence or formula";
static const char __pyx_k_Invalid_group_starting_from_posi[] = "Invalid group starting from position %d: %s";
static const char __pyx_k_Only_one_of_can_be_specified_Giv[] = "Only one of {} can be specified!\nGiven: {}";
static const char __pyx_k_An_error_occurred_in_cmass_fast_2[] = "An error occurred in cmass.fast_mass: %s not found in aa_mass";
static const char __pyx_k_Could_not_create_a_Composition_o_2[] = "Could not create a Composition object from `{}`. A Composition object must be specified by sequence, parsed or split sequence, formula or dict.";
static PyObject *__pyx_kp_s_A_Z_a_z_d;
static PyObject *__pyx_kp_s_A_Z_a_z_d_d;
static PyObject *__pyx_kp_s_An_error_occurred_in_cmass_fast;
static PyObject *__pyx_kp_s_An_error_occurred_in_cmass_fast_2;
static PyObject *__pyx_kp_s_Badly_formed_isotope_number_s;
static PyObject *__pyx_kp_s_Badly_formed_number_of_atoms_s;
static PyObject *__pyx_kp_s_Cannot_multiply_Composition_by_n;
static PyObject *__pyx_kp_s_Charge_is_specified_both_by_the;
static PyObject *__pyx_kp_s_Composition;
static PyObject *__pyx_n_s_Composition_2;
static PyObject *__pyx_kp_s_Could_not_create_a_Composition_o;
static PyObject *__pyx_kp_s_Could_not_create_a_Composition_o_2;
static PyObject *__pyx_n_s_H;
static PyObject *__pyx_kp_s_H_2;
static PyObject *__pyx_kp_s_H_3;
static PyObject *__pyx_kp_s_Invalid_formula;
static PyObject *__pyx_kp_s_Invalid_group_starting_from_posi;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_kp_s_Mass_not_specified_for_label_s;
static PyObject *__pyx_kp_s_No_information_for_s_in_aa_comp;
static PyObject *__pyx_kp_s_No_mass_data_for_residue_r;
static PyObject *__pyx_n_s_NotImplemented;
static PyObject *__pyx_n_s_O;
static PyObject *__pyx_kp_s_OH;
static PyObject *__pyx_kp_s_Only_one_of_can_be_specified_Giv;
static PyObject *__pyx_n_s_PyteomicsError;
static PyObject *__pyx_kp_s_Unknown_chemical_element;
static PyObject *__pyx_kp_s_Unknown_chemical_element_in_the;
static PyObject *__pyx_kp_s_Unknown_ion_type;
static PyObject *__pyx_kp_s_Unknown_ion_type_2;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s__11;
static PyObject *__pyx_kp_s__13;
static PyObject *__pyx_kp_s__14;
static PyObject *__pyx_kp_s__15;
static PyObject *__pyx_kp_s__17;
static PyObject *__pyx_kp_s__18;
static PyObject *__pyx_kp_s__19;
static PyObject *__pyx_kp_s__25;
static PyObject *__pyx_n_s_aa_comp;
static PyObject *__pyx_n_s_aa_mass;
static PyObject *__pyx_n_s_allow_unknown_modifications;
static PyObject *__pyx_n_s_amino_acid_composition;
static PyObject *__pyx_n_s_atom;
static PyObject *__pyx_n_s_average;
static PyObject *__pyx_n_s_calculate_mass;
static PyObject *__pyx_n_s_chain;
static PyObject *__pyx_n_s_charge;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_clear;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_clone;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_compile;
static PyObject *__pyx_n_s_composition;
static PyObject *__pyx_n_s_cparser;
static PyObject *__pyx_n_s_defaultdict;
static PyObject *__pyx_n_s_difference;
static PyObject *__pyx_n_s_endswith;
static PyObject *__pyx_n_s_findall;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_formula;
static PyObject *__pyx_n_s_formula_2;
static PyObject *__pyx_n_s_formula_pattern;
static PyObject *__pyx_n_s_from;
static PyObject *__pyx_n_s_from_dict;
static PyObject *__pyx_n_s_from_formula;
static PyObject *__pyx_n_s_from_formula_parens;
static PyObject *__pyx_n_s_from_parsed_sequence;
static PyObject *__pyx_n_s_from_sequence;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_constants;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_intersection;
static PyObject *__pyx_n_s_ion_comp;
static PyObject *__pyx_n_s_ion_type;
static PyObject *__pyx_n_s_isdigit;
static PyObject *__pyx_n_s_isotope_pattern;
static PyObject *__pyx_n_s_isotope_string;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_itertools;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_labels;
static PyObject *__pyx_n_s_len;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_marshal_ccomposition;
static PyObject *__pyx_n_s_mass;
static PyObject *__pyx_n_s_mass_data;
static PyObject *__pyx_n_s_match;
static PyObject *__pyx_n_s_nist_mass;
static PyObject *__pyx_n_s_parse;
static PyObject *__pyx_n_s_parsed_sequence;
static PyObject *__pyx_n_s_pyteomics;
static PyObject *__pyx_n_s_pyteomics_auxiliary;
static PyObject *__pyx_n_s_pyteomics_cmass;
static PyObject *__pyx_kp_s_pyteomics_cmass_pyx;
static PyObject *__pyx_n_s_pyteomics_mass;
static PyObject *__pyx_n_s_pyx_capi;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_re;
static PyObject *__pyx_n_s_repr;
static PyObject *__pyx_n_s_reverse;
static PyObject *__pyx_n_s_rfind;
static PyObject *__pyx_n_s_round;
static PyObject *__pyx_kp_s_s_d;
static PyObject *__pyx_n_s_sequence;
static PyObject *__pyx_n_s_show_unmodified_termini;
static PyObject *__pyx_n_s_sorted;
static PyObject *__pyx_n_s_split_label;
static PyObject *__pyx_n_s_split_sequence;
static PyObject *__pyx_n_s_state;
static PyObject *__pyx_n_s_std_aa_comp;
static PyObject *__pyx_n_s_std_aa_comp_2;
static PyObject *__pyx_n_s_std_aa_mass;
static PyObject *__pyx_n_s_std_aa_mass_2;
static PyObject *__pyx_n_s_std_ion_comp;
static PyObject *__pyx_n_s_std_ion_comp_2;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_tostring;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_pf_9pyteomics_5cmass___get_constants(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_2fast_mass(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence, PyObject *__pyx_v_ion_type, int __pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_aa_mass, PyObject *__pyx_v_ion_comp); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_4fast_mass2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence, PyObject *__pyx_v_ion_type, int __pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_aa_mass, PyObject *__pyx_v_ion_comp); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_6marshal_ccomposition(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition__from_parsed_sequence(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_parsed_sequence, PyObject *__pyx_v_aa_comp); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_2_from_split_sequence(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_split_sequence, PyObject *__pyx_v_aa_comp); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_4_from_sequence(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_sequence, PyObject *__pyx_v_aa_comp); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_6__str__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_8__repr__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_10__iadd__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_12__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_14__isub__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_16__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_18__reduce__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_20__getstate__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_22__setstate__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_d); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_24__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_26__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_code); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_28__neg__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_30__missing__(CYTHON_UNUSED struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_9pyteomics_5cmass_12CComposition_32__setitem__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_34copy(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_36clone(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_38update(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_40_from_formula(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_formula, PyObject *__pyx_v_mass_data); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_42_from_formula_parens(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_formula, PyObject *__pyx_v_mass_data); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_44_from_dict(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_comp); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_46mass(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, int __pyx_v_average, PyObject *__pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_ion_type); /* proto */
static int __pyx_pf_9pyteomics_5cmass_12CComposition_48__init__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9pyteomics_5cmass_8calculate_mass(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_composition, PyObject *__pyx_v_average, PyObject *__pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_ion_type, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_tp_new_9pyteomics_5cmass_CComposition(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_k__3;
static PyObject *__pyx_k__4;
static PyObject *__pyx_k__5;
static PyObject *__pyx_k__8;
static PyObject *__pyx_k__9;
static PyObject *__pyx_k__10;
static PyObject *__pyx_k__22;
static PyObject *__pyx_codeobj_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_slice__20;
static PyObject *__pyx_slice__21;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_codeobj__16;
static PyObject *__pyx_codeobj__23;

/* "pyteomics/cmass.pyx":49
 * 
 * 
 * def __get_constants():             # <<<<<<<<<<<<<<
 *     return nist_mass, std_aa_mass, std_ion_comp, std_aa_comp
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_1__get_constants(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyteomics_5cmass___get_constants[] = "__get_constants()";
static PyMethodDef __pyx_mdef_9pyteomics_5cmass_1__get_constants = {"__get_constants", (PyCFunction)__pyx_pw_9pyteomics_5cmass_1__get_constants, METH_NOARGS, __pyx_doc_9pyteomics_5cmass___get_constants};
static PyObject *__pyx_pw_9pyteomics_5cmass_1__get_constants(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get_constants (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass___get_constants(__pyx_self);

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

static PyObject *__pyx_pf_9pyteomics_5cmass___get_constants(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_TraceFrameInit(__pyx_codeobj_)
  __Pyx_RefNannySetupContext("__get_constants", 0);
  __Pyx_TraceCall("__get_constants", __pyx_f[0], 49, 0, __PYX_ERR(0, 49, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":50
 * 
 * def __get_constants():
 *     return nist_mass, std_aa_mass, std_ion_comp, std_aa_comp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_9pyteomics_5cmass_std_aa_mass);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_9pyteomics_5cmass_std_ion_comp);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_aa_comp);
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_aa_comp);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_9pyteomics_5cmass_std_aa_comp);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":49
 * 
 * 
 * def __get_constants():             # <<<<<<<<<<<<<<
 *     return nist_mass, std_aa_mass, std_ion_comp, std_aa_comp
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyteomics.cmass.__get_constants", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":53
 * 
 * 
 * cdef inline double get_mass(dict mass_data, object key):             # <<<<<<<<<<<<<<
 *     '''
 *     Internal method to do neutral monoisotopic mass look ups
 */

static CYTHON_INLINE double __pyx_f_9pyteomics_5cmass_get_mass(PyObject *__pyx_v_mass_data, PyObject *__pyx_v_key) {
  double __pyx_v_mass;
  PyObject *__pyx_v_interim;
  double __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4;
  double __pyx_t_5;
  __Pyx_RefNannySetupContext("get_mass", 0);
  __Pyx_TraceCall("get_mass", __pyx_f[0], 53, 0, __PYX_ERR(0, 53, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":68
 *         double mass
 * 
 *     interim = PyDict_GetItem(mass_data, key)             # <<<<<<<<<<<<<<
 *     if interim == NULL:
 *         raise KeyError(key)
 */
  __pyx_v_interim = PyDict_GetItem(__pyx_v_mass_data, __pyx_v_key);

  /* "pyteomics/cmass.pyx":69
 * 
 *     interim = PyDict_GetItem(mass_data, key)
 *     if interim == NULL:             # <<<<<<<<<<<<<<
 *         raise KeyError(key)
 *     interim = PyDict_GetItem(<dict>interim, 0)
 */
  __pyx_t_1 = ((__pyx_v_interim == NULL) != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":70
 *     interim = PyDict_GetItem(mass_data, key)
 *     if interim == NULL:
 *         raise KeyError(key)             # <<<<<<<<<<<<<<
 *     interim = PyDict_GetItem(<dict>interim, 0)
 *     if interim == NULL:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __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, 70, __pyx_L1_error)

    /* "pyteomics/cmass.pyx":69
 * 
 *     interim = PyDict_GetItem(mass_data, key)
 *     if interim == NULL:             # <<<<<<<<<<<<<<
 *         raise KeyError(key)
 *     interim = PyDict_GetItem(<dict>interim, 0)
 */
  }

  /* "pyteomics/cmass.pyx":71
 *     if interim == NULL:
 *         raise KeyError(key)
 *     interim = PyDict_GetItem(<dict>interim, 0)             # <<<<<<<<<<<<<<
 *     if interim == NULL:
 *         raise KeyError(0)
 */
  __pyx_v_interim = PyDict_GetItem(((PyObject *)__pyx_v_interim), __pyx_int_0);

  /* "pyteomics/cmass.pyx":72
 *         raise KeyError(key)
 *     interim = PyDict_GetItem(<dict>interim, 0)
 *     if interim == NULL:             # <<<<<<<<<<<<<<
 *         raise KeyError(0)
 *     mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 */
  __pyx_t_1 = ((__pyx_v_interim == NULL) != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":73
 *     interim = PyDict_GetItem(<dict>interim, 0)
 *     if interim == NULL:
 *         raise KeyError(0)             # <<<<<<<<<<<<<<
 *     mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 *     return mass
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __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, 73, __pyx_L1_error)

    /* "pyteomics/cmass.pyx":72
 *         raise KeyError(key)
 *     interim = PyDict_GetItem(<dict>interim, 0)
 *     if interim == NULL:             # <<<<<<<<<<<<<<
 *         raise KeyError(0)
 *     mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 */
  }

  /* "pyteomics/cmass.pyx":74
 *     if interim == NULL:
 *         raise KeyError(0)
 *     mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))             # <<<<<<<<<<<<<<
 *     return mass
 * 
 */
  __pyx_t_4 = PyTuple_GetItem(((PyObject *)__pyx_v_interim), 0); if (unlikely(__pyx_t_4 == NULL)) __PYX_ERR(0, 74, __pyx_L1_error)
  __pyx_t_5 = PyFloat_AsDouble(((PyObject *)__pyx_t_4)); if (unlikely(__pyx_t_5 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L1_error)
  __pyx_v_mass = __pyx_t_5;

  /* "pyteomics/cmass.pyx":75
 *         raise KeyError(0)
 *     mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 *     return mass             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_mass;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":53
 * 
 * 
 * cdef inline double get_mass(dict mass_data, object key):             # <<<<<<<<<<<<<<
 *     '''
 *     Internal method to do neutral monoisotopic mass look ups
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("pyteomics.cmass.get_mass", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":78
 * 
 * 
 * cpdef double fast_mass(str sequence, str ion_type=None, int charge=0,             # <<<<<<<<<<<<<<
 *                        dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                        dict ion_comp=std_ion_comp):
 */

static PyObject *__pyx_pw_9pyteomics_5cmass_3fast_mass(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_9pyteomics_5cmass_fast_mass(PyObject *__pyx_v_sequence, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_fast_mass *__pyx_optional_args) {
  PyObject *__pyx_v_ion_type = ((PyObject*)Py_None);
  int __pyx_v_charge = ((int)0);
  PyObject *__pyx_v_mass_data = __pyx_k__3;
  PyObject *__pyx_v_aa_mass = __pyx_k__4;
  PyObject *__pyx_v_ion_comp = __pyx_k__5;
  struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_icomp = 0;
  double __pyx_v_mass;
  int __pyx_v_i;
  Py_ssize_t __pyx_v_pos;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_pkey;
  PyObject *__pyx_v_pvalue;
  double __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  double __pyx_t_9;
  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;
  __Pyx_RefNannySetupContext("fast_mass", 0);
  __Pyx_TraceCall("fast_mass", __pyx_f[0], 78, 0, __PYX_ERR(0, 78, __pyx_L1_error));
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_ion_type = __pyx_optional_args->ion_type;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_charge = __pyx_optional_args->charge;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_mass_data = __pyx_optional_args->mass_data;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_aa_mass = __pyx_optional_args->aa_mass;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_ion_comp = __pyx_optional_args->ion_comp;
            }
          }
        }
      }
    }
  }

  /* "pyteomics/cmass.pyx":114
 *     cdef:
 *         CComposition icomp
 *         double mass = 0             # <<<<<<<<<<<<<<
 *         int i, num
 *         Py_ssize_t pos
 */
  __pyx_v_mass = 0.0;

  /* "pyteomics/cmass.pyx":121
 *         PyObject* pvalue
 * 
 *     for i in range(len(sequence)):             # <<<<<<<<<<<<<<
 *         a = PySequence_GetItem(sequence, i)
 *         pvalue = PyDict_GetItem(aa_mass, a)
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_sequence); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 121, __pyx_L1_error)
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "pyteomics/cmass.pyx":122
 * 
 *     for i in range(len(sequence)):
 *         a = PySequence_GetItem(sequence, i)             # <<<<<<<<<<<<<<
 *         pvalue = PyDict_GetItem(aa_mass, a)
 *         if pvalue == NULL:
 */
    __pyx_t_3 = PySequence_GetItem(__pyx_v_sequence, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pyteomics/cmass.pyx":123
 *     for i in range(len(sequence)):
 *         a = PySequence_GetItem(sequence, i)
 *         pvalue = PyDict_GetItem(aa_mass, a)             # <<<<<<<<<<<<<<
 *         if pvalue == NULL:
 *             raise PyteomicsError('No mass data for residue: %r' % (a,))
 */
    __pyx_v_pvalue = PyDict_GetItem(__pyx_v_aa_mass, __pyx_v_a);

    /* "pyteomics/cmass.pyx":124
 *         a = PySequence_GetItem(sequence, i)
 *         pvalue = PyDict_GetItem(aa_mass, a)
 *         if pvalue == NULL:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('No mass data for residue: %r' % (a,))
 *         mass += PyFloat_AsDouble(<object>pvalue)
 */
    __pyx_t_4 = ((__pyx_v_pvalue == NULL) != 0);
    if (__pyx_t_4) {

      /* "pyteomics/cmass.pyx":125
 *         pvalue = PyDict_GetItem(aa_mass, a)
 *         if pvalue == NULL:
 *             raise PyteomicsError('No mass data for residue: %r' % (a,))             # <<<<<<<<<<<<<<
 *         mass += PyFloat_AsDouble(<object>pvalue)
 *     pvalue = PyErr_Occurred()
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 125, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_a);
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_No_mass_data_for_residue_r, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 125, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_7};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_7};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 125, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_7);
          __pyx_t_7 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 125, __pyx_L1_error)

      /* "pyteomics/cmass.pyx":124
 *         a = PySequence_GetItem(sequence, i)
 *         pvalue = PyDict_GetItem(aa_mass, a)
 *         if pvalue == NULL:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('No mass data for residue: %r' % (a,))
 *         mass += PyFloat_AsDouble(<object>pvalue)
 */
    }

    /* "pyteomics/cmass.pyx":126
 *         if pvalue == NULL:
 *             raise PyteomicsError('No mass data for residue: %r' % (a,))
 *         mass += PyFloat_AsDouble(<object>pvalue)             # <<<<<<<<<<<<<<
 *     pvalue = PyErr_Occurred()
 *     if pvalue != NULL:
 */
    __pyx_t_9 = PyFloat_AsDouble(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_9 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L1_error)
    __pyx_v_mass = (__pyx_v_mass + __pyx_t_9);
  }

  /* "pyteomics/cmass.pyx":127
 *             raise PyteomicsError('No mass data for residue: %r' % (a,))
 *         mass += PyFloat_AsDouble(<object>pvalue)
 *     pvalue = PyErr_Occurred()             # <<<<<<<<<<<<<<
 *     if pvalue != NULL:
 *         raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 */
  __pyx_v_pvalue = PyErr_Occurred();

  /* "pyteomics/cmass.pyx":128
 *         mass += PyFloat_AsDouble(<object>pvalue)
 *     pvalue = PyErr_Occurred()
 *     if pvalue != NULL:             # <<<<<<<<<<<<<<
 *         raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 *     mass += get_mass(mass_data, 'H') * 2 + get_mass(mass_data, 'O')
 */
  __pyx_t_4 = ((__pyx_v_pvalue != NULL) != 0);
  if (__pyx_t_4) {

    /* "pyteomics/cmass.pyx":129
 *     pvalue = PyErr_Occurred()
 *     if pvalue != NULL:
 *         raise (<object>pvalue)("An error occurred in cmass.fast_mass")             # <<<<<<<<<<<<<<
 *     mass += get_mass(mass_data, 'H') * 2 + get_mass(mass_data, 'O')
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_pvalue), __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __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, 129, __pyx_L1_error)

    /* "pyteomics/cmass.pyx":128
 *         mass += PyFloat_AsDouble(<object>pvalue)
 *     pvalue = PyErr_Occurred()
 *     if pvalue != NULL:             # <<<<<<<<<<<<<<
 *         raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 *     mass += get_mass(mass_data, 'H') * 2 + get_mass(mass_data, 'O')
 */
  }

  /* "pyteomics/cmass.pyx":130
 *     if pvalue != NULL:
 *         raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 *     mass += get_mass(mass_data, 'H') * 2 + get_mass(mass_data, 'O')             # <<<<<<<<<<<<<<
 * 
 *     if ion_type:
 */
  __pyx_v_mass = (__pyx_v_mass + ((__pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, __pyx_n_s_H) * 2.0) + __pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, __pyx_n_s_O)));

  /* "pyteomics/cmass.pyx":132
 *     mass += get_mass(mass_data, 'H') * 2 + get_mass(mass_data, 'O')
 * 
 *     if ion_type:             # <<<<<<<<<<<<<<
 *         try:
 *             icomp = ion_comp[ion_type]
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_ion_type); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 132, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "pyteomics/cmass.pyx":133
 * 
 *     if ion_type:
 *         try:             # <<<<<<<<<<<<<<
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      /*try:*/ {

        /* "pyteomics/cmass.pyx":134
 *     if ion_type:
 *         try:
 *             icomp = ion_comp[ion_type]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))
 */
        if (unlikely(__pyx_v_ion_comp == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 134, __pyx_L8_error)
        }
        __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_ion_comp, __pyx_v_ion_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_9pyteomics_5cmass_CComposition))))) __PYX_ERR(0, 134, __pyx_L8_error)
        __pyx_v_icomp = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "pyteomics/cmass.pyx":133
 * 
 *     if ion_type:
 *         try:             # <<<<<<<<<<<<<<
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 */
      }
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L13_try_end;
      __pyx_L8_error:;
      __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;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyteomics/cmass.pyx":135
 *         try:
 *             icomp = ion_comp[ion_type]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))
 *         pos = 0
 */
      __pyx_t_2 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_2) {
        __Pyx_AddTraceback("pyteomics.cmass.fast_mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_8) < 0) __PYX_ERR(0, 135, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_t_8);

        /* "pyteomics/cmass.pyx":136
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))             # <<<<<<<<<<<<<<
 *         pos = 0
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 136, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_ion_type, __pyx_n_s_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 136, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
          if (likely(__pyx_t_15)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_14, function);
          }
        }
        if (!__pyx_t_15) {
          __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_v_ion_type); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 136, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_13);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_14)) {
            PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_ion_type};
            __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_13);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
            PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_ion_type};
            __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_13);
          } else
          #endif
          {
            __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
            __Pyx_INCREF(__pyx_v_ion_type);
            __Pyx_GIVEREF(__pyx_v_ion_type);
            PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_v_ion_type);
            __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_16, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_14) {
          __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L10_except_error)
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          } else
          #endif
          {
            __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __pyx_t_14 = NULL;
            __Pyx_GIVEREF(__pyx_t_13);
            PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_13);
            __pyx_t_13 = 0;
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_16, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L10_except_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 136, __pyx_L10_except_error)
      }
      goto __pyx_L10_except_error;
      __pyx_L10_except_error:;

      /* "pyteomics/cmass.pyx":133
 * 
 *     if ion_type:
 *         try:             # <<<<<<<<<<<<<<
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 */
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      goto __pyx_L1_error;
      __pyx_L13_try_end:;
    }

    /* "pyteomics/cmass.pyx":137
 *         except KeyError:
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))
 *         pos = 0             # <<<<<<<<<<<<<<
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 */
    __pyx_v_pos = 0;

    /* "pyteomics/cmass.pyx":138
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))
 *         pos = 0
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):             # <<<<<<<<<<<<<<
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()
 */
    while (1) {
      __pyx_t_4 = (PyDict_Next(((PyObject *)__pyx_v_icomp), (&__pyx_v_pos), (&__pyx_v_pkey), (&__pyx_v_pvalue)) != 0);
      if (!__pyx_t_4) break;

      /* "pyteomics/cmass.pyx":139
 *         pos = 0
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)             # <<<<<<<<<<<<<<
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:
 */
      __pyx_t_9 = PyFloat_AsDouble(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_9 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 139, __pyx_L1_error)
      __pyx_v_mass = (__pyx_v_mass + (__pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, ((PyObject *)__pyx_v_pkey)) * __pyx_t_9));
    }

    /* "pyteomics/cmass.pyx":140
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()             # <<<<<<<<<<<<<<
 *         if pvalue != NULL:
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 */
    __pyx_v_pvalue = PyErr_Occurred();

    /* "pyteomics/cmass.pyx":141
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:             # <<<<<<<<<<<<<<
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 */
    __pyx_t_4 = ((__pyx_v_pvalue != NULL) != 0);
    if (__pyx_t_4) {

      /* "pyteomics/cmass.pyx":142
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")             # <<<<<<<<<<<<<<
 * 
 *     if charge:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_pvalue), __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 142, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 142, __pyx_L1_error)

      /* "pyteomics/cmass.pyx":141
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:             # <<<<<<<<<<<<<<
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 */
    }

    /* "pyteomics/cmass.pyx":132
 *     mass += get_mass(mass_data, 'H') * 2 + get_mass(mass_data, 'O')
 * 
 *     if ion_type:             # <<<<<<<<<<<<<<
 *         try:
 *             icomp = ion_comp[ion_type]
 */
  }

  /* "pyteomics/cmass.pyx":144
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 *     if charge:             # <<<<<<<<<<<<<<
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge
 * 
 */
  __pyx_t_4 = (__pyx_v_charge != 0);
  if (__pyx_t_4) {

    /* "pyteomics/cmass.pyx":145
 * 
 *     if charge:
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge             # <<<<<<<<<<<<<<
 * 
 *     return mass
 */
    __pyx_t_9 = (__pyx_v_mass + (__pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, __pyx_kp_s_H_2) * __pyx_v_charge));
    if (unlikely(__pyx_v_charge == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 145, __pyx_L1_error)
    }
    __pyx_v_mass = (__pyx_t_9 / __pyx_v_charge);

    /* "pyteomics/cmass.pyx":144
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 *     if charge:             # <<<<<<<<<<<<<<
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge
 * 
 */
  }

  /* "pyteomics/cmass.pyx":147
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge
 * 
 *     return mass             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_mass;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":78
 * 
 * 
 * cpdef double fast_mass(str sequence, str ion_type=None, int charge=0,             # <<<<<<<<<<<<<<
 *                        dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                        dict ion_comp=std_ion_comp):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_WriteUnraisable("pyteomics.cmass.fast_mass", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_icomp);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_3fast_mass(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_2fast_mass[] = "fast_mass(str sequence, str ion_type=None, int charge=0, dict mass_data=nist_mass, dict aa_mass=std_aa_mass, dict ion_comp=std_ion_comp) -> double\nCalculate monoisotopic mass of an ion using the fast\n    algorithm. May be used only if amino acid residues are presented in\n    one-letter code.\n\n    Parameters\n    ----------\n    sequence : str\n        A polypeptide sequence string.\n    ion_type : str, optional\n        If specified, then the polypeptide is considered to be\n        in a form of corresponding ion. Do not forget to\n        specify the charge state!\n    charge : int, optional\n        If not 0 then m/z is calculated: the mass is increased\n        by the corresponding number of proton masses and divided\n        by z.\n    mass_data : dict, optional\n        A dict with the masses of chemical elements (the default\n        value is :py:data:`nist_mass`).\n    aa_mass : dict, optional\n        A dict with the monoisotopic mass of amino acid residues\n        (default is std_aa_mass);\n    ion_comp : dict, optional\n        A dict with the relative elemental compositions of peptide ion\n        fragments (default is :py:data:`std_ion_comp`).\n\n    Returns\n    -------\n    mass : float\n        Monoisotopic mass or m/z of a peptide molecule/ion.\n    ";
static PyObject *__pyx_pw_9pyteomics_5cmass_3fast_mass(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence = 0;
  PyObject *__pyx_v_ion_type = 0;
  int __pyx_v_charge;
  PyObject *__pyx_v_mass_data = 0;
  PyObject *__pyx_v_aa_mass = 0;
  PyObject *__pyx_v_ion_comp = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fast_mass (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence,&__pyx_n_s_ion_type,&__pyx_n_s_charge,&__pyx_n_s_mass_data,&__pyx_n_s_aa_mass,&__pyx_n_s_ion_comp,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject*)Py_None);
    values[3] = __pyx_k__3;
    values[4] = __pyx_k__4;
    values[5] = __pyx_k__5;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_sequence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ion_type);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_charge);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mass_data);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_aa_mass);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ion_comp);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fast_mass") < 0)) __PYX_ERR(0, 78, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sequence = ((PyObject*)values[0]);
    __pyx_v_ion_type = ((PyObject*)values[1]);
    if (values[2]) {
      __pyx_v_charge = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_charge == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 78, __pyx_L3_error)
    } else {
      __pyx_v_charge = ((int)0);
    }
    __pyx_v_mass_data = ((PyObject*)values[3]);
    __pyx_v_aa_mass = ((PyObject*)values[4]);
    __pyx_v_ion_comp = ((PyObject*)values[5]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fast_mass", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 78, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.fast_mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sequence), (&PyString_Type), 1, "sequence", 1))) __PYX_ERR(0, 78, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ion_type), (&PyString_Type), 1, "ion_type", 1))) __PYX_ERR(0, 78, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mass_data), (&PyDict_Type), 1, "mass_data", 1))) __PYX_ERR(0, 79, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_aa_mass), (&PyDict_Type), 1, "aa_mass", 1))) __PYX_ERR(0, 79, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ion_comp), (&PyDict_Type), 1, "ion_comp", 1))) __PYX_ERR(0, 80, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyteomics_5cmass_2fast_mass(__pyx_self, __pyx_v_sequence, __pyx_v_ion_type, __pyx_v_charge, __pyx_v_mass_data, __pyx_v_aa_mass, __pyx_v_ion_comp);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_2fast_mass(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence, PyObject *__pyx_v_ion_type, int __pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_aa_mass, PyObject *__pyx_v_ion_comp) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  struct __pyx_opt_args_9pyteomics_5cmass_fast_mass __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("fast_mass", 0);
  __Pyx_TraceCall("fast_mass (wrapper)", __pyx_f[0], 78, 0, __PYX_ERR(0, 78, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.ion_type = __pyx_v_ion_type;
  __pyx_t_2.charge = __pyx_v_charge;
  __pyx_t_2.mass_data = __pyx_v_mass_data;
  __pyx_t_2.aa_mass = __pyx_v_aa_mass;
  __pyx_t_2.ion_comp = __pyx_v_ion_comp;
  __pyx_t_1 = __pyx_f_9pyteomics_5cmass_fast_mass(__pyx_v_sequence, 0, &__pyx_t_2); 
  __pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyteomics.cmass.fast_mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":150
 * 
 * 
 * cpdef double fast_mass2(str sequence, str ion_type=None, int charge=0,             # <<<<<<<<<<<<<<
 *                         dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                         dict ion_comp=std_ion_comp):
 */

static PyObject *__pyx_pw_9pyteomics_5cmass_5fast_mass2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_9pyteomics_5cmass_fast_mass2(PyObject *__pyx_v_sequence, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_fast_mass2 *__pyx_optional_args) {
  PyObject *__pyx_v_ion_type = ((PyObject*)Py_None);
  int __pyx_v_charge = ((int)0);
  PyObject *__pyx_v_mass_data = __pyx_k__8;
  PyObject *__pyx_v_aa_mass = __pyx_k__9;
  PyObject *__pyx_v_ion_comp = __pyx_k__10;
  PyObject *__pyx_v_comp = 0;
  PyObject *__pyx_v_aa = 0;
  PyObject *__pyx_v_mod = 0;
  PyObject *__pyx_v_X = 0;
  int __pyx_v_num;
  double __pyx_v_mass;
  double __pyx_v_interim;
  PyObject *__pyx_v_temp = 0;
  struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_icomp = 0;
  Py_ssize_t __pyx_v_pos;
  PyObject *__pyx_v_pkey;
  PyObject *__pyx_v_pvalue;
  PyObject *__pyx_v_ptemp;
  double __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  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 = NULL;
  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;
  PyObject *__pyx_t_17 = NULL;
  long __pyx_t_18;
  int __pyx_t_19;
  double __pyx_t_20;
  PyObject *__pyx_t_21;
  __Pyx_RefNannySetupContext("fast_mass2", 0);
  __Pyx_TraceCall("fast_mass2", __pyx_f[0], 150, 0, __PYX_ERR(0, 150, __pyx_L1_error));
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_ion_type = __pyx_optional_args->ion_type;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_charge = __pyx_optional_args->charge;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_mass_data = __pyx_optional_args->mass_data;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_aa_mass = __pyx_optional_args->aa_mass;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_ion_comp = __pyx_optional_args->ion_comp;
            }
          }
        }
      }
    }
  }

  /* "pyteomics/cmass.pyx":195
 *         PyObject* ptemp
 * 
 *     ptemp = PyDict_GetItem(aa_mass, 'H-')             # <<<<<<<<<<<<<<
 *     if ptemp == NULL:
 *         PyDict_SetItem(aa_mass, 'H-', get_mass(mass_data, "H"))
 */
  __pyx_v_ptemp = PyDict_GetItem(__pyx_v_aa_mass, __pyx_kp_s_H_3);

  /* "pyteomics/cmass.pyx":196
 * 
 *     ptemp = PyDict_GetItem(aa_mass, 'H-')
 *     if ptemp == NULL:             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(aa_mass, 'H-', get_mass(mass_data, "H"))
 *     ptemp = PyDict_GetItem(aa_mass, '-OH')
 */
  __pyx_t_1 = ((__pyx_v_ptemp == NULL) != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":197
 *     ptemp = PyDict_GetItem(aa_mass, 'H-')
 *     if ptemp == NULL:
 *         PyDict_SetItem(aa_mass, 'H-', get_mass(mass_data, "H"))             # <<<<<<<<<<<<<<
 *     ptemp = PyDict_GetItem(aa_mass, '-OH')
 *     if ptemp == NULL:
 */
    __pyx_t_2 = PyFloat_FromDouble(__pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, __pyx_n_s_H)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyDict_SetItem(__pyx_v_aa_mass, __pyx_kp_s_H_3, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 197, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":196
 * 
 *     ptemp = PyDict_GetItem(aa_mass, 'H-')
 *     if ptemp == NULL:             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(aa_mass, 'H-', get_mass(mass_data, "H"))
 *     ptemp = PyDict_GetItem(aa_mass, '-OH')
 */
  }

  /* "pyteomics/cmass.pyx":198
 *     if ptemp == NULL:
 *         PyDict_SetItem(aa_mass, 'H-', get_mass(mass_data, "H"))
 *     ptemp = PyDict_GetItem(aa_mass, '-OH')             # <<<<<<<<<<<<<<
 *     if ptemp == NULL:
 *         PyDict_SetItem(aa_mass, '-OH', get_mass(mass_data, "H") + get_mass(mass_data, "O"))
 */
  __pyx_v_ptemp = PyDict_GetItem(__pyx_v_aa_mass, __pyx_kp_s_OH);

  /* "pyteomics/cmass.pyx":199
 *         PyDict_SetItem(aa_mass, 'H-', get_mass(mass_data, "H"))
 *     ptemp = PyDict_GetItem(aa_mass, '-OH')
 *     if ptemp == NULL:             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(aa_mass, '-OH', get_mass(mass_data, "H") + get_mass(mass_data, "O"))
 * 
 */
  __pyx_t_1 = ((__pyx_v_ptemp == NULL) != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":200
 *     ptemp = PyDict_GetItem(aa_mass, '-OH')
 *     if ptemp == NULL:
 *         PyDict_SetItem(aa_mass, '-OH', get_mass(mass_data, "H") + get_mass(mass_data, "O"))             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
    __pyx_t_2 = PyFloat_FromDouble((__pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, __pyx_n_s_H) + __pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, __pyx_n_s_O))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyDict_SetItem(__pyx_v_aa_mass, __pyx_kp_s_OH, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":199
 *         PyDict_SetItem(aa_mass, 'H-', get_mass(mass_data, "H"))
 *     ptemp = PyDict_GetItem(aa_mass, '-OH')
 *     if ptemp == NULL:             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(aa_mass, '-OH', get_mass(mass_data, "H") + get_mass(mass_data, "O"))
 * 
 */
  }

  /* "pyteomics/cmass.pyx":202
 *         PyDict_SetItem(aa_mass, '-OH', get_mass(mass_data, "H") + get_mass(mass_data, "O"))
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         comp = cparser.amino_acid_composition(sequence,
 *                 show_unmodified_termini=1,
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "pyteomics/cmass.pyx":203
 * 
 *     try:
 *         comp = cparser.amino_acid_composition(sequence,             # <<<<<<<<<<<<<<
 *                 show_unmodified_termini=1,
 *                 allow_unknown_modifications=1,
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cparser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_amino_acid_composition); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 203, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_sequence);
      __Pyx_GIVEREF(__pyx_v_sequence);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_sequence);

      /* "pyteomics/cmass.pyx":204
 *     try:
 *         comp = cparser.amino_acid_composition(sequence,
 *                 show_unmodified_termini=1,             # <<<<<<<<<<<<<<
 *                 allow_unknown_modifications=1,
 *                 labels=list(aa_mass))
 */
      __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 204, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_show_unmodified_termini, __pyx_int_1) < 0) __PYX_ERR(0, 204, __pyx_L5_error)
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_allow_unknown_modifications, __pyx_int_1) < 0) __PYX_ERR(0, 204, __pyx_L5_error)

      /* "pyteomics/cmass.pyx":206
 *                 show_unmodified_termini=1,
 *                 allow_unknown_modifications=1,
 *                 labels=list(aa_mass))             # <<<<<<<<<<<<<<
 *     except PyteomicsError:
 *         raise PyteomicsError('Mass not specified for label(s): {}'.format(
 */
      __pyx_t_9 = PySequence_List(__pyx_v_aa_mass); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 206, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_labels, __pyx_t_9) < 0) __PYX_ERR(0, 204, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "pyteomics/cmass.pyx":203
 * 
 *     try:
 *         comp = cparser.amino_acid_composition(sequence,             # <<<<<<<<<<<<<<
 *                 show_unmodified_termini=1,
 *                 allow_unknown_modifications=1,
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 203, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (!(likely(PyDict_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_9)->tp_name), 0))) __PYX_ERR(0, 203, __pyx_L5_error)
      __pyx_v_comp = ((PyObject*)__pyx_t_9);
      __pyx_t_9 = 0;

      /* "pyteomics/cmass.pyx":202
 *         PyDict_SetItem(aa_mass, '-OH', get_mass(mass_data, "H") + get_mass(mass_data, "O"))
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         comp = cparser.amino_acid_composition(sequence,
 *                 show_unmodified_termini=1,
 */
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L10_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pyteomics/cmass.pyx":207
 *                 allow_unknown_modifications=1,
 *                 labels=list(aa_mass))
 *     except PyteomicsError:             # <<<<<<<<<<<<<<
 *         raise PyteomicsError('Mass not specified for label(s): {}'.format(
 *             ', '.join(set(cparser.parse(sequence)).difference(aa_mass))))
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 207, __pyx_L7_except_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_3 = __Pyx_PyErr_ExceptionMatches(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_3) {
      __Pyx_AddTraceback("pyteomics.cmass.fast_mass2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_2) < 0) __PYX_ERR(0, 207, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_2);

      /* "pyteomics/cmass.pyx":208
 *                 labels=list(aa_mass))
 *     except PyteomicsError:
 *         raise PyteomicsError('Mass not specified for label(s): {}'.format(             # <<<<<<<<<<<<<<
 *             ', '.join(set(cparser.parse(sequence)).difference(aa_mass))))
 * 
 */
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 208, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Mass_not_specified_for_label_s, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 208, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "pyteomics/cmass.pyx":209
 *     except PyteomicsError:
 *         raise PyteomicsError('Mass not specified for label(s): {}'.format(
 *             ', '.join(set(cparser.parse(sequence)).difference(aa_mass))))             # <<<<<<<<<<<<<<
 * 
 *     mass = 0.
 */
      __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_cparser); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 209, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_parse); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 209, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_16, function);
        }
      }
      if (!__pyx_t_15) {
        __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_v_sequence); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L7_except_error)
        __Pyx_GOTREF(__pyx_t_14);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_sequence};
          __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_14);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_sequence};
          __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_14);
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
          __Pyx_INCREF(__pyx_v_sequence);
          __Pyx_GIVEREF(__pyx_v_sequence);
          PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_v_sequence);
          __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_17, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = PySet_New(__pyx_t_14); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 209, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_difference); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      if (!__pyx_t_16) {
        __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_v_aa_mass); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L7_except_error)
        __Pyx_GOTREF(__pyx_t_13);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_aa_mass};
          __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_GOTREF(__pyx_t_13);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_aa_mass};
          __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_GOTREF(__pyx_t_13);
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16); __pyx_t_16 = NULL;
          __Pyx_INCREF(__pyx_v_aa_mass);
          __Pyx_GIVEREF(__pyx_v_aa_mass);
          PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_v_aa_mass);
          __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_17, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyString_Join(__pyx_kp_s__11, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 209, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_13) {
        __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 208, __pyx_L7_except_error)
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_11);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_14};
          __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_14};
          __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_13); __pyx_t_13 = NULL;
          __Pyx_GIVEREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_14);
          __pyx_t_14 = 0;
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_17, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (!__pyx_t_12) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 208, __pyx_L7_except_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12); __pyx_t_12 = NULL;
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_11);
          __pyx_t_11 = 0;
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_17, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 208, __pyx_L7_except_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(0, 208, __pyx_L7_except_error)
    }
    goto __pyx_L7_except_error;
    __pyx_L7_except_error:;

    /* "pyteomics/cmass.pyx":202
 *         PyDict_SetItem(aa_mass, '-OH', get_mass(mass_data, "H") + get_mass(mass_data, "O"))
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         comp = cparser.amino_acid_composition(sequence,
 *                 show_unmodified_termini=1,
 */
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L10_try_end:;
  }

  /* "pyteomics/cmass.pyx":211
 *             ', '.join(set(cparser.parse(sequence)).difference(aa_mass))))
 * 
 *     mass = 0.             # <<<<<<<<<<<<<<
 *     pos = 0
 *     while(PyDict_Next(comp, &pos, &pkey, &pvalue)):
 */
  __pyx_v_mass = 0.;

  /* "pyteomics/cmass.pyx":212
 * 
 *     mass = 0.
 *     pos = 0             # <<<<<<<<<<<<<<
 *     while(PyDict_Next(comp, &pos, &pkey, &pvalue)):
 *         aa = <str>pkey
 */
  __pyx_v_pos = 0;

  /* "pyteomics/cmass.pyx":213
 *     mass = 0.
 *     pos = 0
 *     while(PyDict_Next(comp, &pos, &pkey, &pvalue)):             # <<<<<<<<<<<<<<
 *         aa = <str>pkey
 *         num = PyInt_AsLong(<object>pvalue)
 */
  while (1) {
    __pyx_t_1 = (PyDict_Next(__pyx_v_comp, (&__pyx_v_pos), (&__pyx_v_pkey), (&__pyx_v_pvalue)) != 0);
    if (!__pyx_t_1) break;

    /* "pyteomics/cmass.pyx":214
 *     pos = 0
 *     while(PyDict_Next(comp, &pos, &pkey, &pvalue)):
 *         aa = <str>pkey             # <<<<<<<<<<<<<<
 *         num = PyInt_AsLong(<object>pvalue)
 *         if aa in aa_mass:
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_pkey);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_aa, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":215
 *     while(PyDict_Next(comp, &pos, &pkey, &pvalue)):
 *         aa = <str>pkey
 *         num = PyInt_AsLong(<object>pvalue)             # <<<<<<<<<<<<<<
 *         if aa in aa_mass:
 *             ptemp = PyDict_GetItem(aa_mass, aa)
 */
    __pyx_t_18 = PyInt_AsLong(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_18 == -1L && PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L1_error)
    __pyx_v_num = __pyx_t_18;

    /* "pyteomics/cmass.pyx":216
 *         aa = <str>pkey
 *         num = PyInt_AsLong(<object>pvalue)
 *         if aa in aa_mass:             # <<<<<<<<<<<<<<
 *             ptemp = PyDict_GetItem(aa_mass, aa)
 *             mass += PyFloat_AsDouble(<object>ptemp) * num
 */
    if (unlikely(__pyx_v_aa_mass == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 216, __pyx_L1_error)
    }
    __pyx_t_1 = (__Pyx_PyDict_ContainsTF(__pyx_v_aa, __pyx_v_aa_mass, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 216, __pyx_L1_error)
    __pyx_t_19 = (__pyx_t_1 != 0);
    if (__pyx_t_19) {

      /* "pyteomics/cmass.pyx":217
 *         num = PyInt_AsLong(<object>pvalue)
 *         if aa in aa_mass:
 *             ptemp = PyDict_GetItem(aa_mass, aa)             # <<<<<<<<<<<<<<
 *             mass += PyFloat_AsDouble(<object>ptemp) * num
 *         else:
 */
      __pyx_v_ptemp = PyDict_GetItem(__pyx_v_aa_mass, __pyx_v_aa);

      /* "pyteomics/cmass.pyx":218
 *         if aa in aa_mass:
 *             ptemp = PyDict_GetItem(aa_mass, aa)
 *             mass += PyFloat_AsDouble(<object>ptemp) * num             # <<<<<<<<<<<<<<
 *         else:
 *             temp = _split_label(aa)
 */
      __pyx_t_20 = PyFloat_AsDouble(((PyObject *)__pyx_v_ptemp)); if (unlikely(__pyx_t_20 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L1_error)
      __pyx_v_mass = (__pyx_v_mass + (__pyx_t_20 * __pyx_v_num));

      /* "pyteomics/cmass.pyx":216
 *         aa = <str>pkey
 *         num = PyInt_AsLong(<object>pvalue)
 *         if aa in aa_mass:             # <<<<<<<<<<<<<<
 *             ptemp = PyDict_GetItem(aa_mass, aa)
 *             mass += PyFloat_AsDouble(<object>ptemp) * num
 */
      goto __pyx_L15;
    }

    /* "pyteomics/cmass.pyx":220
 *             mass += PyFloat_AsDouble(<object>ptemp) * num
 *         else:
 *             temp = _split_label(aa)             # <<<<<<<<<<<<<<
 *             mod = <str>PyTuple_GET_ITEM(temp, 0)
 *             X = <str>PyTuple_GET_ITEM(temp, 1)
 */
    /*else*/ {
      __pyx_t_2 = __pyx_f_9pyteomics_7cparser__split_label(__pyx_v_aa, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_XDECREF_SET(__pyx_v_temp, ((PyObject*)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "pyteomics/cmass.pyx":221
 *         else:
 *             temp = _split_label(aa)
 *             mod = <str>PyTuple_GET_ITEM(temp, 0)             # <<<<<<<<<<<<<<
 *             X = <str>PyTuple_GET_ITEM(temp, 1)
 *             ptemp = PyDict_GetItem(aa_mass, mod)
 */
      __pyx_t_21 = PyTuple_GET_ITEM(__pyx_v_temp, 0);
      __pyx_t_2 = ((PyObject *)__pyx_t_21);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_XDECREF_SET(__pyx_v_mod, ((PyObject*)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "pyteomics/cmass.pyx":222
 *             temp = _split_label(aa)
 *             mod = <str>PyTuple_GET_ITEM(temp, 0)
 *             X = <str>PyTuple_GET_ITEM(temp, 1)             # <<<<<<<<<<<<<<
 *             ptemp = PyDict_GetItem(aa_mass, mod)
 *             if ptemp is NULL:
 */
      __pyx_t_21 = PyTuple_GET_ITEM(__pyx_v_temp, 1);
      __pyx_t_2 = ((PyObject *)__pyx_t_21);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_XDECREF_SET(__pyx_v_X, ((PyObject*)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "pyteomics/cmass.pyx":223
 *             mod = <str>PyTuple_GET_ITEM(temp, 0)
 *             X = <str>PyTuple_GET_ITEM(temp, 1)
 *             ptemp = PyDict_GetItem(aa_mass, mod)             # <<<<<<<<<<<<<<
 *             if ptemp is NULL:
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % mod)
 */
      __pyx_v_ptemp = PyDict_GetItem(__pyx_v_aa_mass, __pyx_v_mod);

      /* "pyteomics/cmass.pyx":224
 *             X = <str>PyTuple_GET_ITEM(temp, 1)
 *             ptemp = PyDict_GetItem(aa_mass, mod)
 *             if ptemp is NULL:             # <<<<<<<<<<<<<<
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % mod)
 *             interim = PyFloat_AsDouble(<object>ptemp)
 */
      __pyx_t_19 = ((__pyx_v_ptemp == NULL) != 0);
      if (__pyx_t_19) {

        /* "pyteomics/cmass.pyx":225
 *             ptemp = PyDict_GetItem(aa_mass, mod)
 *             if ptemp is NULL:
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % mod)             # <<<<<<<<<<<<<<
 *             interim = PyFloat_AsDouble(<object>ptemp)
 *             ptemp = PyDict_GetItem(aa_mass, X)
 */
        __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_An_error_occurred_in_cmass_fast_2, __pyx_v_mod); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 225, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_INCREF(((PyObject *)__pyx_v_ptemp));
        __pyx_t_9 = ((PyObject *)__pyx_v_ptemp); __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
          }
        }
        if (!__pyx_t_7) {
          __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          } else
          #endif
          {
            __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 225, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
            __Pyx_GIVEREF(__pyx_t_8);
            PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8);
            __pyx_t_8 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 225, __pyx_L1_error)

        /* "pyteomics/cmass.pyx":224
 *             X = <str>PyTuple_GET_ITEM(temp, 1)
 *             ptemp = PyDict_GetItem(aa_mass, mod)
 *             if ptemp is NULL:             # <<<<<<<<<<<<<<
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % mod)
 *             interim = PyFloat_AsDouble(<object>ptemp)
 */
      }

      /* "pyteomics/cmass.pyx":226
 *             if ptemp is NULL:
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % mod)
 *             interim = PyFloat_AsDouble(<object>ptemp)             # <<<<<<<<<<<<<<
 *             ptemp = PyDict_GetItem(aa_mass, X)
 *             if ptemp is NULL:
 */
      __pyx_t_20 = PyFloat_AsDouble(((PyObject *)__pyx_v_ptemp)); if (unlikely(__pyx_t_20 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 226, __pyx_L1_error)
      __pyx_v_interim = __pyx_t_20;

      /* "pyteomics/cmass.pyx":227
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % mod)
 *             interim = PyFloat_AsDouble(<object>ptemp)
 *             ptemp = PyDict_GetItem(aa_mass, X)             # <<<<<<<<<<<<<<
 *             if ptemp is NULL:
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % X)
 */
      __pyx_v_ptemp = PyDict_GetItem(__pyx_v_aa_mass, __pyx_v_X);

      /* "pyteomics/cmass.pyx":228
 *             interim = PyFloat_AsDouble(<object>ptemp)
 *             ptemp = PyDict_GetItem(aa_mass, X)
 *             if ptemp is NULL:             # <<<<<<<<<<<<<<
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % X)
 *             interim += PyFloat_AsDouble(<object>ptemp)
 */
      __pyx_t_19 = ((__pyx_v_ptemp == NULL) != 0);
      if (__pyx_t_19) {

        /* "pyteomics/cmass.pyx":229
 *             ptemp = PyDict_GetItem(aa_mass, X)
 *             if ptemp is NULL:
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % X)             # <<<<<<<<<<<<<<
 *             interim += PyFloat_AsDouble(<object>ptemp)
 *             mass += interim * num
 */
        __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_An_error_occurred_in_cmass_fast_2, __pyx_v_X); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 229, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(((PyObject *)__pyx_v_ptemp));
        __pyx_t_10 = ((PyObject *)__pyx_v_ptemp); __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
          }
        }
        if (!__pyx_t_8) {
          __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_10)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
            PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          {
            __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 229, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
            __Pyx_GIVEREF(__pyx_t_9);
            PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_9);
            __pyx_t_9 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 229, __pyx_L1_error)

        /* "pyteomics/cmass.pyx":228
 *             interim = PyFloat_AsDouble(<object>ptemp)
 *             ptemp = PyDict_GetItem(aa_mass, X)
 *             if ptemp is NULL:             # <<<<<<<<<<<<<<
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % X)
 *             interim += PyFloat_AsDouble(<object>ptemp)
 */
      }

      /* "pyteomics/cmass.pyx":230
 *             if ptemp is NULL:
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % X)
 *             interim += PyFloat_AsDouble(<object>ptemp)             # <<<<<<<<<<<<<<
 *             mass += interim * num
 * 
 */
      __pyx_t_20 = PyFloat_AsDouble(((PyObject *)__pyx_v_ptemp)); if (unlikely(__pyx_t_20 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 230, __pyx_L1_error)
      __pyx_v_interim = (__pyx_v_interim + __pyx_t_20);

      /* "pyteomics/cmass.pyx":231
 *                 raise (<object>ptemp)("An error occurred in cmass.fast_mass: %s not found in aa_mass" % X)
 *             interim += PyFloat_AsDouble(<object>ptemp)
 *             mass += interim * num             # <<<<<<<<<<<<<<
 * 
 *     if ion_type:
 */
      __pyx_v_mass = (__pyx_v_mass + (__pyx_v_interim * __pyx_v_num));
    }
    __pyx_L15:;
  }

  /* "pyteomics/cmass.pyx":233
 *             mass += interim * num
 * 
 *     if ion_type:             # <<<<<<<<<<<<<<
 *         try:
 *             icomp = ion_comp[ion_type]
 */
  __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_v_ion_type); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 233, __pyx_L1_error)
  if (__pyx_t_19) {

    /* "pyteomics/cmass.pyx":234
 * 
 *     if ion_type:
 *         try:             # <<<<<<<<<<<<<<
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_4);
      /*try:*/ {

        /* "pyteomics/cmass.pyx":235
 *     if ion_type:
 *         try:
 *             icomp = ion_comp[ion_type]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))
 */
        if (unlikely(__pyx_v_ion_comp == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 235, __pyx_L19_error)
        }
        __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_ion_comp, __pyx_v_ion_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyteomics_5cmass_CComposition))))) __PYX_ERR(0, 235, __pyx_L19_error)
        __pyx_v_icomp = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "pyteomics/cmass.pyx":234
 * 
 *     if ion_type:
 *         try:             # <<<<<<<<<<<<<<
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 */
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L24_try_end;
      __pyx_L19_error:;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyteomics/cmass.pyx":236
 *         try:
 *             icomp = ion_comp[ion_type]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))
 * 
 */
      __pyx_t_3 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_3) {
        __Pyx_AddTraceback("pyteomics.cmass.fast_mass2", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_10, &__pyx_t_7) < 0) __PYX_ERR(0, 236, __pyx_L21_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GOTREF(__pyx_t_7);

        /* "pyteomics/cmass.pyx":237
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))             # <<<<<<<<<<<<<<
 * 
 *         pos = 0
 */
        __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 237, __pyx_L21_except_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_ion_type, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 237, __pyx_L21_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_ion_type); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 237, __pyx_L21_except_error)
          __Pyx_GOTREF(__pyx_t_17);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_ion_type};
            __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_17);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_ion_type};
            __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_17);
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
            __Pyx_INCREF(__pyx_v_ion_type);
            __Pyx_GIVEREF(__pyx_v_ion_type);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_ion_type);
            __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_14, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        if (!__pyx_t_11) {
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 237, __pyx_L21_except_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_17};
            __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_17};
            __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_11); __pyx_t_11 = NULL;
            __Pyx_GIVEREF(__pyx_t_17);
            PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_17);
            __pyx_t_17 = 0;
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 237, __pyx_L21_except_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(0, 237, __pyx_L21_except_error)
      }
      goto __pyx_L21_except_error;
      __pyx_L21_except_error:;

      /* "pyteomics/cmass.pyx":234
 * 
 *     if ion_type:
 *         try:             # <<<<<<<<<<<<<<
 *             icomp = ion_comp[ion_type]
 *         except KeyError:
 */
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4);
      goto __pyx_L1_error;
      __pyx_L24_try_end:;
    }

    /* "pyteomics/cmass.pyx":239
 *             raise PyteomicsError('Unknown ion type: {}'.format(ion_type))
 * 
 *         pos = 0             # <<<<<<<<<<<<<<
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 */
    __pyx_v_pos = 0;

    /* "pyteomics/cmass.pyx":240
 * 
 *         pos = 0
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):             # <<<<<<<<<<<<<<
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()
 */
    while (1) {
      __pyx_t_19 = (PyDict_Next(((PyObject *)__pyx_v_icomp), (&__pyx_v_pos), (&__pyx_v_pkey), (&__pyx_v_pvalue)) != 0);
      if (!__pyx_t_19) break;

      /* "pyteomics/cmass.pyx":241
 *         pos = 0
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)             # <<<<<<<<<<<<<<
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:
 */
      __pyx_t_20 = PyFloat_AsDouble(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_20 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 241, __pyx_L1_error)
      __pyx_v_mass = (__pyx_v_mass + (__pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, ((PyObject *)__pyx_v_pkey)) * __pyx_t_20));
    }

    /* "pyteomics/cmass.pyx":242
 *         while(PyDict_Next(icomp, &pos, &pkey, &pvalue)):
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()             # <<<<<<<<<<<<<<
 *         if pvalue != NULL:
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 */
    __pyx_v_pvalue = PyErr_Occurred();

    /* "pyteomics/cmass.pyx":243
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:             # <<<<<<<<<<<<<<
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 */
    __pyx_t_19 = ((__pyx_v_pvalue != NULL) != 0);
    if (__pyx_t_19) {

      /* "pyteomics/cmass.pyx":244
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")             # <<<<<<<<<<<<<<
 * 
 *     if charge:
 */
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_pvalue), __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 244, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __PYX_ERR(0, 244, __pyx_L1_error)

      /* "pyteomics/cmass.pyx":243
 *             mass += get_mass(mass_data, <object>pkey) * PyFloat_AsDouble(<object>pvalue)
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:             # <<<<<<<<<<<<<<
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 */
    }

    /* "pyteomics/cmass.pyx":233
 *             mass += interim * num
 * 
 *     if ion_type:             # <<<<<<<<<<<<<<
 *         try:
 *             icomp = ion_comp[ion_type]
 */
  }

  /* "pyteomics/cmass.pyx":246
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 *     if charge:             # <<<<<<<<<<<<<<
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge
 * 
 */
  __pyx_t_19 = (__pyx_v_charge != 0);
  if (__pyx_t_19) {

    /* "pyteomics/cmass.pyx":247
 * 
 *     if charge:
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge             # <<<<<<<<<<<<<<
 * 
 *     return mass
 */
    __pyx_t_20 = (__pyx_v_mass + (__pyx_f_9pyteomics_5cmass_get_mass(__pyx_v_mass_data, __pyx_kp_s_H_2) * __pyx_v_charge));
    if (unlikely(__pyx_v_charge == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 247, __pyx_L1_error)
    }
    __pyx_v_mass = (__pyx_t_20 / __pyx_v_charge);

    /* "pyteomics/cmass.pyx":246
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")
 * 
 *     if charge:             # <<<<<<<<<<<<<<
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge
 * 
 */
  }

  /* "pyteomics/cmass.pyx":249
 *         mass = (mass + get_mass(mass_data, 'H+') * charge) / charge
 * 
 *     return mass             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_mass;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":150
 * 
 * 
 * cpdef double fast_mass2(str sequence, str ion_type=None, int charge=0,             # <<<<<<<<<<<<<<
 *                         dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                         dict ion_comp=std_ion_comp):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __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);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_WriteUnraisable("pyteomics.cmass.fast_mass2", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_comp);
  __Pyx_XDECREF(__pyx_v_aa);
  __Pyx_XDECREF(__pyx_v_mod);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XDECREF(__pyx_v_temp);
  __Pyx_XDECREF((PyObject *)__pyx_v_icomp);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_5fast_mass2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_4fast_mass2[] = "fast_mass2(str sequence, str ion_type=None, int charge=0, dict mass_data=nist_mass, dict aa_mass=std_aa_mass, dict ion_comp=std_ion_comp) -> double\nCalculate monoisotopic mass of an ion using the fast\n    algorithm. *modX* notation is fully supported.\n\n    Parameters\n    ----------\n    sequence : str\n        A polypeptide sequence string.\n    ion_type : str, optional\n        If specified, then the polypeptide is considered to be\n        in a form of corresponding ion. Do not forget to\n        specify the charge state!\n    charge : int, optional\n        If not 0 then m/z is calculated: the mass is increased\n        by the corresponding number of proton masses and divided\n        by z.\n    mass_data : dict, optional\n        A dict with the masses of chemical elements (the default\n        value is :py:data:`nist_mass`).\n    aa_mass : dict, optional\n        A dict with the monoisotopic mass of amino acid residues\n        (default is std_aa_mass);\n    ion_comp : dict, optional\n        A dict with the relative elemental compositions of peptide ion\n        fragments (default is :py:data:`std_ion_comp`).\n\n    Returns\n    -------\n    mass : float\n        Monoisotopic mass or m/z of a peptide molecule/ion.\n    ";
static PyObject *__pyx_pw_9pyteomics_5cmass_5fast_mass2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence = 0;
  PyObject *__pyx_v_ion_type = 0;
  int __pyx_v_charge;
  PyObject *__pyx_v_mass_data = 0;
  PyObject *__pyx_v_aa_mass = 0;
  PyObject *__pyx_v_ion_comp = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fast_mass2 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence,&__pyx_n_s_ion_type,&__pyx_n_s_charge,&__pyx_n_s_mass_data,&__pyx_n_s_aa_mass,&__pyx_n_s_ion_comp,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject*)Py_None);
    values[3] = __pyx_k__8;
    values[4] = __pyx_k__9;
    values[5] = __pyx_k__10;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_sequence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ion_type);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_charge);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mass_data);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_aa_mass);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ion_comp);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fast_mass2") < 0)) __PYX_ERR(0, 150, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sequence = ((PyObject*)values[0]);
    __pyx_v_ion_type = ((PyObject*)values[1]);
    if (values[2]) {
      __pyx_v_charge = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_charge == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L3_error)
    } else {
      __pyx_v_charge = ((int)0);
    }
    __pyx_v_mass_data = ((PyObject*)values[3]);
    __pyx_v_aa_mass = ((PyObject*)values[4]);
    __pyx_v_ion_comp = ((PyObject*)values[5]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fast_mass2", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 150, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.fast_mass2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sequence), (&PyString_Type), 1, "sequence", 1))) __PYX_ERR(0, 150, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ion_type), (&PyString_Type), 1, "ion_type", 1))) __PYX_ERR(0, 150, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mass_data), (&PyDict_Type), 1, "mass_data", 1))) __PYX_ERR(0, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_aa_mass), (&PyDict_Type), 1, "aa_mass", 1))) __PYX_ERR(0, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ion_comp), (&PyDict_Type), 1, "ion_comp", 1))) __PYX_ERR(0, 152, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyteomics_5cmass_4fast_mass2(__pyx_self, __pyx_v_sequence, __pyx_v_ion_type, __pyx_v_charge, __pyx_v_mass_data, __pyx_v_aa_mass, __pyx_v_ion_comp);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_4fast_mass2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence, PyObject *__pyx_v_ion_type, int __pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_aa_mass, PyObject *__pyx_v_ion_comp) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  struct __pyx_opt_args_9pyteomics_5cmass_fast_mass2 __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("fast_mass2", 0);
  __Pyx_TraceCall("fast_mass2 (wrapper)", __pyx_f[0], 150, 0, __PYX_ERR(0, 150, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.ion_type = __pyx_v_ion_type;
  __pyx_t_2.charge = __pyx_v_charge;
  __pyx_t_2.mass_data = __pyx_v_mass_data;
  __pyx_t_2.aa_mass = __pyx_v_aa_mass;
  __pyx_t_2.ion_comp = __pyx_v_ion_comp;
  __pyx_t_1 = __pyx_f_9pyteomics_5cmass_fast_mass2(__pyx_v_sequence, 0, &__pyx_t_2); 
  __pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyteomics.cmass.fast_mass2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":263
 * 
 * @cython.boundscheck(False)
 * cdef str _parse_isotope_string(str label, int* isotope_num):             # <<<<<<<<<<<<<<
 *     '''Parses an isotope string and extracts the element name and isotope number.
 *     The element name is returned, but the isotope number is returned by indirection.
 */

static PyObject *__pyx_f_9pyteomics_5cmass__parse_isotope_string(PyObject *__pyx_v_label, int *__pyx_v_isotope_num) {
  int __pyx_v_i;
  int __pyx_v_in_bracket;
  PyObject *__pyx_v_current = 0;
  PyObject *__pyx_v_name_parts = 0;
  PyObject *__pyx_v_num_parts = 0;
  PyObject *__pyx_v_element_name = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_parse_isotope_string", 0);
  __Pyx_TraceCall("_parse_isotope_string", __pyx_f[0], 263, 0, __PYX_ERR(0, 263, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":280
 *     cdef:
 *         # int isotope_num = 0
 *         int i = 0             # <<<<<<<<<<<<<<
 *         int in_bracket = False
 *         # str element_name
 */
  __pyx_v_i = 0;

  /* "pyteomics/cmass.pyx":281
 *         # int isotope_num = 0
 *         int i = 0
 *         int in_bracket = False             # <<<<<<<<<<<<<<
 *         # str element_name
 *         str current
 */
  __pyx_v_in_bracket = 0;

  /* "pyteomics/cmass.pyx":284
 *         # str element_name
 *         str current
 *         list name_parts = []             # <<<<<<<<<<<<<<
 *         list num_parts = []
 *         #Isotope result
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_name_parts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":285
 *         str current
 *         list name_parts = []
 *         list num_parts = []             # <<<<<<<<<<<<<<
 *         #Isotope result
 *     for i in range(len(label)):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_num_parts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":287
 *         list num_parts = []
 *         #Isotope result
 *     for i in range(len(label)):             # <<<<<<<<<<<<<<
 *         current = label[i]
 *         if in_bracket:
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_label); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 287, __pyx_L1_error)
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "pyteomics/cmass.pyx":288
 *         #Isotope result
 *     for i in range(len(label)):
 *         current = label[i]             # <<<<<<<<<<<<<<
 *         if in_bracket:
 *             if current == "]":
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_label, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 288, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_current, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "pyteomics/cmass.pyx":289
 *     for i in range(len(label)):
 *         current = label[i]
 *         if in_bracket:             # <<<<<<<<<<<<<<
 *             if current == "]":
 *                 break
 */
    __pyx_t_4 = (__pyx_v_in_bracket != 0);
    if (__pyx_t_4) {

      /* "pyteomics/cmass.pyx":290
 *         current = label[i]
 *         if in_bracket:
 *             if current == "]":             # <<<<<<<<<<<<<<
 *                 break
 *             num_parts.append(current)
 */
      __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_current, __pyx_kp_s__13, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 290, __pyx_L1_error)
      __pyx_t_5 = (__pyx_t_4 != 0);
      if (__pyx_t_5) {

        /* "pyteomics/cmass.pyx":291
 *         if in_bracket:
 *             if current == "]":
 *                 break             # <<<<<<<<<<<<<<
 *             num_parts.append(current)
 *         elif current == "[":
 */
        goto __pyx_L4_break;

        /* "pyteomics/cmass.pyx":290
 *         current = label[i]
 *         if in_bracket:
 *             if current == "]":             # <<<<<<<<<<<<<<
 *                 break
 *             num_parts.append(current)
 */
      }

      /* "pyteomics/cmass.pyx":292
 *             if current == "]":
 *                 break
 *             num_parts.append(current)             # <<<<<<<<<<<<<<
 *         elif current == "[":
 *             in_bracket = True
 */
      __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_num_parts, __pyx_v_current); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 292, __pyx_L1_error)

      /* "pyteomics/cmass.pyx":289
 *     for i in range(len(label)):
 *         current = label[i]
 *         if in_bracket:             # <<<<<<<<<<<<<<
 *             if current == "]":
 *                 break
 */
      goto __pyx_L5;
    }

    /* "pyteomics/cmass.pyx":293
 *                 break
 *             num_parts.append(current)
 *         elif current == "[":             # <<<<<<<<<<<<<<
 *             in_bracket = True
 *         else:
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_current, __pyx_kp_s__14, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 293, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_5 != 0);
    if (__pyx_t_4) {

      /* "pyteomics/cmass.pyx":294
 *             num_parts.append(current)
 *         elif current == "[":
 *             in_bracket = True             # <<<<<<<<<<<<<<
 *         else:
 *             name_parts.append(current)
 */
      __pyx_v_in_bracket = 1;

      /* "pyteomics/cmass.pyx":293
 *                 break
 *             num_parts.append(current)
 *         elif current == "[":             # <<<<<<<<<<<<<<
 *             in_bracket = True
 *         else:
 */
      goto __pyx_L5;
    }

    /* "pyteomics/cmass.pyx":296
 *             in_bracket = True
 *         else:
 *             name_parts.append(current)             # <<<<<<<<<<<<<<
 *     element_name = (''.join(name_parts))
 *     if len(num_parts) > 0:
 */
    /*else*/ {
      __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_name_parts, __pyx_v_current); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 296, __pyx_L1_error)
    }
    __pyx_L5:;
  }
  __pyx_L4_break:;

  /* "pyteomics/cmass.pyx":297
 *         else:
 *             name_parts.append(current)
 *     element_name = (''.join(name_parts))             # <<<<<<<<<<<<<<
 *     if len(num_parts) > 0:
 *         isotope_num[0] = (int(''.join(num_parts)))
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__15, __pyx_v_name_parts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_element_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":298
 *             name_parts.append(current)
 *     element_name = (''.join(name_parts))
 *     if len(num_parts) > 0:             # <<<<<<<<<<<<<<
 *         isotope_num[0] = (int(''.join(num_parts)))
 *     else:
 */
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_num_parts); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 298, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_2 > 0) != 0);
  if (__pyx_t_4) {

    /* "pyteomics/cmass.pyx":299
 *     element_name = (''.join(name_parts))
 *     if len(num_parts) > 0:
 *         isotope_num[0] = (int(''.join(num_parts)))             # <<<<<<<<<<<<<<
 *     else:
 *         isotope_num[0] = 0
 */
    __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__15, __pyx_v_num_parts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    (__pyx_v_isotope_num[0]) = __pyx_t_3;

    /* "pyteomics/cmass.pyx":298
 *             name_parts.append(current)
 *     element_name = (''.join(name_parts))
 *     if len(num_parts) > 0:             # <<<<<<<<<<<<<<
 *         isotope_num[0] = (int(''.join(num_parts)))
 *     else:
 */
    goto __pyx_L7;
  }

  /* "pyteomics/cmass.pyx":301
 *         isotope_num[0] = (int(''.join(num_parts)))
 *     else:
 *         isotope_num[0] = 0             # <<<<<<<<<<<<<<
 *     return element_name
 * 
 */
  /*else*/ {
    (__pyx_v_isotope_num[0]) = 0;
  }
  __pyx_L7:;

  /* "pyteomics/cmass.pyx":302
 *     else:
 *         isotope_num[0] = 0
 *     return element_name             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_element_name))||((__pyx_v_element_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_element_name)->tp_name), 0))) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_element_name);
  __pyx_r = ((PyObject*)__pyx_v_element_name);
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":263
 * 
 * @cython.boundscheck(False)
 * cdef str _parse_isotope_string(str label, int* isotope_num):             # <<<<<<<<<<<<<<
 *     '''Parses an isotope string and extracts the element name and isotope number.
 *     The element name is returned, but the isotope number is returned by indirection.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pyteomics.cmass._parse_isotope_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_current);
  __Pyx_XDECREF(__pyx_v_name_parts);
  __Pyx_XDECREF(__pyx_v_num_parts);
  __Pyx_XDECREF(__pyx_v_element_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":305
 * 
 * 
 * cdef str _make_isotope_string(str element_name, int isotope_num):             # <<<<<<<<<<<<<<
 *     """Form a string label for an isotope."""
 *     cdef:
 */

static PyObject *__pyx_f_9pyteomics_5cmass__make_isotope_string(PyObject *__pyx_v_element_name, int __pyx_v_isotope_num) {
  PyObject *__pyx_v_parts = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_make_isotope_string", 0);
  __Pyx_TraceCall("_make_isotope_string", __pyx_f[0], 305, 0, __PYX_ERR(0, 305, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":309
 *     cdef:
 *         tuple parts
 *     if isotope_num == 0:             # <<<<<<<<<<<<<<
 *         return element_name
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_isotope_num == 0) != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":310
 *         tuple parts
 *     if isotope_num == 0:
 *         return element_name             # <<<<<<<<<<<<<<
 *     else:
 *         parts = (element_name, isotope_num)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_element_name);
    __pyx_r = __pyx_v_element_name;
    goto __pyx_L0;

    /* "pyteomics/cmass.pyx":309
 *     cdef:
 *         tuple parts
 *     if isotope_num == 0:             # <<<<<<<<<<<<<<
 *         return element_name
 *     else:
 */
  }

  /* "pyteomics/cmass.pyx":312
 *         return element_name
 *     else:
 *         parts = (element_name, isotope_num)             # <<<<<<<<<<<<<<
 *         return '%s[%d]' % parts
 * 
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_isotope_num); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_element_name);
    __Pyx_GIVEREF(__pyx_v_element_name);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_element_name);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_v_parts = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pyteomics/cmass.pyx":313
 *     else:
 *         parts = (element_name, isotope_num)
 *         return '%s[%d]' % parts             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_d, __pyx_v_parts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyString_CheckExact(__pyx_t_3))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 313, __pyx_L1_error)
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "pyteomics/cmass.pyx":305
 * 
 * 
 * cdef str _make_isotope_string(str element_name, int isotope_num):             # <<<<<<<<<<<<<<
 *     """Form a string label for an isotope."""
 *     cdef:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyteomics.cmass._make_isotope_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parts);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":316
 * 
 * 
 * def marshal_ccomposition(state):             # <<<<<<<<<<<<<<
 *     return CComposition(state)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_7marshal_ccomposition(PyObject *__pyx_self, PyObject *__pyx_v_state); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_6marshal_ccomposition[] = "marshal_ccomposition(state)";
static PyMethodDef __pyx_mdef_9pyteomics_5cmass_7marshal_ccomposition = {"marshal_ccomposition", (PyCFunction)__pyx_pw_9pyteomics_5cmass_7marshal_ccomposition, METH_O, __pyx_doc_9pyteomics_5cmass_6marshal_ccomposition};
static PyObject *__pyx_pw_9pyteomics_5cmass_7marshal_ccomposition(PyObject *__pyx_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("marshal_ccomposition (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_6marshal_ccomposition(__pyx_self, ((PyObject *)__pyx_v_state));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_6marshal_ccomposition(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_TraceFrameInit(__pyx_codeobj__16)
  __Pyx_RefNannySetupContext("marshal_ccomposition", 0);
  __Pyx_TraceCall("marshal_ccomposition", __pyx_f[0], 316, 0, __PYX_ERR(0, 316, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":317
 * 
 * def marshal_ccomposition(state):
 *     return CComposition(state)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_state);
  __Pyx_GIVEREF(__pyx_v_state);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_state);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __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;

  /* "pyteomics/cmass.pyx":316
 * 
 * 
 * def marshal_ccomposition(state):             # <<<<<<<<<<<<<<
 *     return CComposition(state)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyteomics.cmass.marshal_ccomposition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":345
 *     """
 * 
 *     def _from_parsed_sequence(self, parsed_sequence, aa_comp):             # <<<<<<<<<<<<<<
 *         self.clear()
 *         comp = defaultdict(int)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_1_from_parsed_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition__from_parsed_sequence[] = "CComposition._from_parsed_sequence(self, parsed_sequence, aa_comp)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_1_from_parsed_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_parsed_sequence = 0;
  PyObject *__pyx_v_aa_comp = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_from_parsed_sequence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_parsed_sequence,&__pyx_n_s_aa_comp,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_parsed_sequence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_aa_comp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_from_parsed_sequence", 1, 2, 2, 1); __PYX_ERR(0, 345, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_from_parsed_sequence") < 0)) __PYX_ERR(0, 345, __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_parsed_sequence = values[0];
    __pyx_v_aa_comp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_from_parsed_sequence", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 345, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_parsed_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition__from_parsed_sequence(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_parsed_sequence, __pyx_v_aa_comp);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition__from_parsed_sequence(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_parsed_sequence, PyObject *__pyx_v_aa_comp) {
  PyObject *__pyx_v_comp = NULL;
  PyObject *__pyx_v_aa = NULL;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_v_cnt = NULL;
  PyObject *__pyx_v_mod = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  __Pyx_RefNannySetupContext("_from_parsed_sequence", 0);
  __Pyx_TraceCall("_from_parsed_sequence", __pyx_f[0], 345, 0, __PYX_ERR(0, 345, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":346
 * 
 *     def _from_parsed_sequence(self, parsed_sequence, aa_comp):
 *         self.clear()             # <<<<<<<<<<<<<<
 *         comp = defaultdict(int)
 *         for aa in parsed_sequence:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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, 346, __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, 346, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":347
 *     def _from_parsed_sequence(self, parsed_sequence, aa_comp):
 *         self.clear()
 *         comp = defaultdict(int)             # <<<<<<<<<<<<<<
 *         for aa in parsed_sequence:
 *             if aa in aa_comp:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __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(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __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_v_comp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":348
 *         self.clear()
 *         comp = defaultdict(int)
 *         for aa in parsed_sequence:             # <<<<<<<<<<<<<<
 *             if aa in aa_comp:
 *                 for elem, cnt in aa_comp[aa].items():
 */
  if (likely(PyList_CheckExact(__pyx_v_parsed_sequence)) || PyTuple_CheckExact(__pyx_v_parsed_sequence)) {
    __pyx_t_1 = __pyx_v_parsed_sequence; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_parsed_sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 348, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 348, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 348, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 348, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_aa, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":349
 *         comp = defaultdict(int)
 *         for aa in parsed_sequence:
 *             if aa in aa_comp:             # <<<<<<<<<<<<<<
 *                 for elem, cnt in aa_comp[aa].items():
 *                     comp[elem] += cnt
 */
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_aa, __pyx_v_aa_comp, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 349, __pyx_L1_error)
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "pyteomics/cmass.pyx":350
 *         for aa in parsed_sequence:
 *             if aa in aa_comp:
 *                 for elem, cnt in aa_comp[aa].items():             # <<<<<<<<<<<<<<
 *                     comp[elem] += cnt
 *             else:
 */
      __pyx_t_4 = PyObject_GetItem(__pyx_v_aa_comp, __pyx_v_aa); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 350, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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, 350, __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, 350, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
        __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
      } else {
        __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 350, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      for (;;) {
        if (likely(!__pyx_t_10)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 350, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          } else {
            if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 350, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          }
        } else {
          __pyx_t_2 = __pyx_t_10(__pyx_t_3);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 350, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_2);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
          PyObject* sequence = __pyx_t_2;
          #if !CYTHON_COMPILING_IN_PYPY
          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, 350, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_11);
          #else
          __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          #endif
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_12 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
          index = 0; __pyx_t_4 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_11);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
          __pyx_t_13 = NULL;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L9_unpacking_done;
          __pyx_L8_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 350, __pyx_L1_error)
          __pyx_L9_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_4);
        __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_v_cnt, __pyx_t_11);
        __pyx_t_11 = 0;

        /* "pyteomics/cmass.pyx":351
 *             if aa in aa_comp:
 *                 for elem, cnt in aa_comp[aa].items():
 *                     comp[elem] += cnt             # <<<<<<<<<<<<<<
 *             else:
 *                 try:
 */
        __Pyx_INCREF(__pyx_v_elem);
        __pyx_t_2 = __pyx_v_elem;
        __pyx_t_11 = PyObject_GetItem(__pyx_v_comp, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 351, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_11, __pyx_v_cnt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (unlikely(PyObject_SetItem(__pyx_v_comp, __pyx_t_2, __pyx_t_4) < 0)) __PYX_ERR(0, 351, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyteomics/cmass.pyx":350
 *         for aa in parsed_sequence:
 *             if aa in aa_comp:
 *                 for elem, cnt in aa_comp[aa].items():             # <<<<<<<<<<<<<<
 *                     comp[elem] += cnt
 *             else:
 */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyteomics/cmass.pyx":349
 *         comp = defaultdict(int)
 *         for aa in parsed_sequence:
 *             if aa in aa_comp:             # <<<<<<<<<<<<<<
 *                 for elem, cnt in aa_comp[aa].items():
 *                     comp[elem] += cnt
 */
      goto __pyx_L5;
    }

    /* "pyteomics/cmass.pyx":353
 *                     comp[elem] += cnt
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     mod, aa = cparser._split_label(aa)
 *                     for elem, cnt in chain(
 */
    /*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:*/ {

          /* "pyteomics/cmass.pyx":354
 *             else:
 *                 try:
 *                     mod, aa = cparser._split_label(aa)             # <<<<<<<<<<<<<<
 *                     for elem, cnt in chain(
 *                             aa_comp[mod].items(), aa_comp[aa].items()):
 */
          __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cparser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split_label); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = NULL;
          if (CYTHON_UNPACK_METHODS && 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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_aa); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 354, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_3);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_4)) {
              PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_aa};
              __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 354, __pyx_L10_error)
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_GOTREF(__pyx_t_3);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
              PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_aa};
              __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 354, __pyx_L10_error)
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_GOTREF(__pyx_t_3);
            } else
            #endif
            {
              __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 354, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
              __Pyx_INCREF(__pyx_v_aa);
              __Pyx_GIVEREF(__pyx_v_aa);
              PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_aa);
              __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 354, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 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_PYPY
            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, 354, __pyx_L10_error)
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_11);
            #else
            __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 354, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_11);
            #endif
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          } else {
            Py_ssize_t index = -1;
            __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_13 = Py_TYPE(__pyx_t_2)->tp_iternext;
            index = 0; __pyx_t_4 = __pyx_t_13(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L18_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_4);
            index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_2); if (unlikely(!__pyx_t_11)) goto __pyx_L18_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_11);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_2), 2) < 0) __PYX_ERR(0, 354, __pyx_L10_error)
            __pyx_t_13 = NULL;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            goto __pyx_L19_unpacking_done;
            __pyx_L18_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_13 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            __PYX_ERR(0, 354, __pyx_L10_error)
            __pyx_L19_unpacking_done:;
          }
          __Pyx_XDECREF_SET(__pyx_v_mod, __pyx_t_4);
          __pyx_t_4 = 0;
          __Pyx_DECREF_SET(__pyx_v_aa, __pyx_t_11);
          __pyx_t_11 = 0;

          /* "pyteomics/cmass.pyx":355
 *                 try:
 *                     mod, aa = cparser._split_label(aa)
 *                     for elem, cnt in chain(             # <<<<<<<<<<<<<<
 *                             aa_comp[mod].items(), aa_comp[aa].items()):
 *                         comp[elem] += cnt
 */
          __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_chain); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 355, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_11);

          /* "pyteomics/cmass.pyx":356
 *                     mod, aa = cparser._split_label(aa)
 *                     for elem, cnt in chain(
 *                             aa_comp[mod].items(), aa_comp[aa].items()):             # <<<<<<<<<<<<<<
 *                         comp[elem] += cnt
 * 
 */
          __pyx_t_2 = PyObject_GetItem(__pyx_v_aa_comp, __pyx_v_mod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_items); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 356, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_12, function);
            }
          }
          if (__pyx_t_2) {
            __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 356, __pyx_L10_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else {
            __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 356, __pyx_L10_error)
          }
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_2 = PyObject_GetItem(__pyx_v_aa_comp, __pyx_v_aa); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_items); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 356, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_17);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_17, function);
            }
          }
          if (__pyx_t_2) {
            __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 356, __pyx_L10_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else {
            __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 356, __pyx_L10_error)
          }
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_17 = NULL;
          __pyx_t_18 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_17)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
              __pyx_t_18 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_t_4, __pyx_t_12};
            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L10_error)
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_t_4, __pyx_t_12};
            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L10_error)
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          #endif
          {
            __pyx_t_2 = PyTuple_New(2+__pyx_t_18); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_2);
            if (__pyx_t_17) {
              __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_17); __pyx_t_17 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_18, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_12);
            PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_18, __pyx_t_12);
            __pyx_t_4 = 0;
            __pyx_t_12 = 0;
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "pyteomics/cmass.pyx":355
 *                 try:
 *                     mod, aa = cparser._split_label(aa)
 *                     for elem, cnt in chain(             # <<<<<<<<<<<<<<
 *                             aa_comp[mod].items(), aa_comp[aa].items()):
 *                         comp[elem] += cnt
 */
          if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
            __pyx_t_11 = __pyx_t_3; __Pyx_INCREF(__pyx_t_11); __pyx_t_9 = 0;
            __pyx_t_10 = NULL;
          } else {
            __pyx_t_9 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 355, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_10 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 355, __pyx_L10_error)
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          for (;;) {
            if (likely(!__pyx_t_10)) {
              if (likely(PyList_CheckExact(__pyx_t_11))) {
                if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_11)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_3 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 355, __pyx_L10_error)
                #else
                __pyx_t_3 = PySequence_ITEM(__pyx_t_11, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L10_error)
                __Pyx_GOTREF(__pyx_t_3);
                #endif
              } else {
                if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 355, __pyx_L10_error)
                #else
                __pyx_t_3 = PySequence_ITEM(__pyx_t_11, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L10_error)
                __Pyx_GOTREF(__pyx_t_3);
                #endif
              }
            } else {
              __pyx_t_3 = __pyx_t_10(__pyx_t_11);
              if (unlikely(!__pyx_t_3)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 355, __pyx_L10_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_3);
            }
            if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
              PyObject* sequence = __pyx_t_3;
              #if !CYTHON_COMPILING_IN_PYPY
              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, 355, __pyx_L10_error)
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              if (likely(PyTuple_CheckExact(sequence))) {
                __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
                __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
              } else {
                __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
                __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
              }
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_12);
              #else
              __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 355, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_12);
              #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, 355, __pyx_L10_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext;
              index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L22_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_2);
              index = 1; __pyx_t_12 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_12)) goto __pyx_L22_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_12);
              if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_4), 2) < 0) __PYX_ERR(0, 355, __pyx_L10_error)
              __pyx_t_13 = NULL;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              goto __pyx_L23_unpacking_done;
              __pyx_L22_unpacking_failed:;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_13 = NULL;
              if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
              __PYX_ERR(0, 355, __pyx_L10_error)
              __pyx_L23_unpacking_done:;
            }
            __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_2);
            __pyx_t_2 = 0;
            __Pyx_XDECREF_SET(__pyx_v_cnt, __pyx_t_12);
            __pyx_t_12 = 0;

            /* "pyteomics/cmass.pyx":357
 *                     for elem, cnt in chain(
 *                             aa_comp[mod].items(), aa_comp[aa].items()):
 *                         comp[elem] += cnt             # <<<<<<<<<<<<<<
 * 
 *                 except (PyteomicsError, KeyError):
 */
            __Pyx_INCREF(__pyx_v_elem);
            __pyx_t_3 = __pyx_v_elem;
            __pyx_t_12 = PyObject_GetItem(__pyx_v_comp, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 357, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_12, __pyx_v_cnt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L10_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(PyObject_SetItem(__pyx_v_comp, __pyx_t_3, __pyx_t_2) < 0)) __PYX_ERR(0, 357, __pyx_L10_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "pyteomics/cmass.pyx":355
 *                 try:
 *                     mod, aa = cparser._split_label(aa)
 *                     for elem, cnt in chain(             # <<<<<<<<<<<<<<
 *                             aa_comp[mod].items(), aa_comp[aa].items()):
 *                         comp[elem] += cnt
 */
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "pyteomics/cmass.pyx":353
 *                     comp[elem] += cnt
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     mod, aa = cparser._split_label(aa)
 *                     for elem, cnt in chain(
 */
        }
        __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_L17_try_end;
        __pyx_L10_error:;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "pyteomics/cmass.pyx":359
 *                         comp[elem] += cnt
 * 
 *                 except (PyteomicsError, KeyError):             # <<<<<<<<<<<<<<
 *                     raise PyteomicsError(
 *                             'No information for %s in `aa_comp`' % aa)
 */
        __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 359, __pyx_L12_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(__pyx_t_11) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (__pyx_t_18) {
          __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_parsed_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 359, __pyx_L12_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_2);

          /* "pyteomics/cmass.pyx":360
 * 
 *                 except (PyteomicsError, KeyError):
 *                     raise PyteomicsError(             # <<<<<<<<<<<<<<
 *                             'No information for %s in `aa_comp`' % aa)
 *         self._from_dict(comp)
 */
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 360, __pyx_L12_except_error)
          __Pyx_GOTREF(__pyx_t_4);

          /* "pyteomics/cmass.pyx":361
 *                 except (PyteomicsError, KeyError):
 *                     raise PyteomicsError(
 *                             'No information for %s in `aa_comp`' % aa)             # <<<<<<<<<<<<<<
 *         self._from_dict(comp)
 * 
 */
          __pyx_t_17 = __Pyx_PyString_Format(__pyx_kp_s_No_information_for_s_in_aa_comp, __pyx_v_aa); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 361, __pyx_L12_except_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_19 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_19)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_19);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          if (!__pyx_t_19) {
            __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L12_except_error)
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_GOTREF(__pyx_t_12);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_4)) {
              PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_t_17};
              __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L12_except_error)
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
              PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_t_17};
              __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L12_except_error)
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            } else
            #endif
            {
              __pyx_t_20 = PyTuple_New(1+1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 360, __pyx_L12_except_error)
              __Pyx_GOTREF(__pyx_t_20);
              __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_19); __pyx_t_19 = NULL;
              __Pyx_GIVEREF(__pyx_t_17);
              PyTuple_SET_ITEM(__pyx_t_20, 0+1, __pyx_t_17);
              __pyx_t_17 = 0;
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_20, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L12_except_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_Raise(__pyx_t_12, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __PYX_ERR(0, 360, __pyx_L12_except_error)
        }
        goto __pyx_L12_except_error;
        __pyx_L12_except_error:;

        /* "pyteomics/cmass.pyx":353
 *                     comp[elem] += cnt
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     mod, aa = cparser._split_label(aa)
 *                     for elem, cnt in chain(
 */
        __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_L17_try_end:;
      }
    }
    __pyx_L5:;

    /* "pyteomics/cmass.pyx":348
 *         self.clear()
 *         comp = defaultdict(int)
 *         for aa in parsed_sequence:             # <<<<<<<<<<<<<<
 *             if aa in aa_comp:
 *                 for elem, cnt in aa_comp[aa].items():
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":362
 *                     raise PyteomicsError(
 *                             'No information for %s in `aa_comp`' % aa)
 *         self._from_dict(comp)             # <<<<<<<<<<<<<<
 * 
 *     def _from_split_sequence(self, split_sequence, aa_comp):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *)__pyx_v_self->__pyx_vtab)->_from_dict(__pyx_v_self, __pyx_v_comp, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":345
 *     """
 * 
 *     def _from_parsed_sequence(self, parsed_sequence, aa_comp):             # <<<<<<<<<<<<<<
 *         self.clear()
 *         comp = defaultdict(int)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_parsed_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_comp);
  __Pyx_XDECREF(__pyx_v_aa);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF(__pyx_v_cnt);
  __Pyx_XDECREF(__pyx_v_mod);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":364
 *         self._from_dict(comp)
 * 
 *     def _from_split_sequence(self, split_sequence, aa_comp):             # <<<<<<<<<<<<<<
 *         self.clear()
 *         comp = defaultdict(int)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_3_from_split_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_2_from_split_sequence[] = "CComposition._from_split_sequence(self, split_sequence, aa_comp)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_3_from_split_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_split_sequence = 0;
  PyObject *__pyx_v_aa_comp = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_from_split_sequence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_split_sequence,&__pyx_n_s_aa_comp,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_split_sequence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_aa_comp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_from_split_sequence", 1, 2, 2, 1); __PYX_ERR(0, 364, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_from_split_sequence") < 0)) __PYX_ERR(0, 364, __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_split_sequence = values[0];
    __pyx_v_aa_comp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_from_split_sequence", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 364, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_split_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_2_from_split_sequence(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_split_sequence, __pyx_v_aa_comp);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_2_from_split_sequence(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_split_sequence, PyObject *__pyx_v_aa_comp) {
  PyObject *__pyx_v_comp = NULL;
  PyObject *__pyx_v_group = NULL;
  PyObject *__pyx_v_i = NULL;
  Py_ssize_t __pyx_v_j;
  PyObject *__pyx_v_label = NULL;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_v_cnt = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *(*__pyx_t_17)(PyObject *);
  int __pyx_t_18;
  __Pyx_RefNannySetupContext("_from_split_sequence", 0);
  __Pyx_TraceCall("_from_split_sequence", __pyx_f[0], 364, 0, __PYX_ERR(0, 364, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":365
 * 
 *     def _from_split_sequence(self, split_sequence, aa_comp):
 *         self.clear()             # <<<<<<<<<<<<<<
 *         comp = defaultdict(int)
 *         for group in split_sequence:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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, 365, __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, 365, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":366
 *     def _from_split_sequence(self, split_sequence, aa_comp):
 *         self.clear()
 *         comp = defaultdict(int)             # <<<<<<<<<<<<<<
 *         for group in split_sequence:
 *             i = 0
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __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(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __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_v_comp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":367
 *         self.clear()
 *         comp = defaultdict(int)
 *         for group in split_sequence:             # <<<<<<<<<<<<<<
 *             i = 0
 *             while i < len(group):
 */
  if (likely(PyList_CheckExact(__pyx_v_split_sequence)) || PyTuple_CheckExact(__pyx_v_split_sequence)) {
    __pyx_t_1 = __pyx_v_split_sequence; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_split_sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 367, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 367, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 367, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_group, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":368
 *         comp = defaultdict(int)
 *         for group in split_sequence:
 *             i = 0             # <<<<<<<<<<<<<<
 *             while i < len(group):
 *                 for j in range(len(group)+1, -1, -1):
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_int_0);

    /* "pyteomics/cmass.pyx":369
 *         for group in split_sequence:
 *             i = 0
 *             while i < len(group):             # <<<<<<<<<<<<<<
 *                 for j in range(len(group)+1, -1, -1):
 *                     try:
 */
    while (1) {
      __pyx_t_7 = PyObject_Length(__pyx_v_group); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 369, __pyx_L1_error)
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_i, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_8) break;

      /* "pyteomics/cmass.pyx":370
 *             i = 0
 *             while i < len(group):
 *                 for j in range(len(group)+1, -1, -1):             # <<<<<<<<<<<<<<
 *                     try:
 *                         label = ''.join(group[i:j])
 */
      __pyx_t_7 = PyObject_Length(__pyx_v_group); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 370, __pyx_L1_error)
      for (__pyx_t_9 = (__pyx_t_7 + 1); __pyx_t_9 > -1L; __pyx_t_9-=1) {
        __pyx_v_j = __pyx_t_9;

        /* "pyteomics/cmass.pyx":371
 *             while i < len(group):
 *                 for j in range(len(group)+1, -1, -1):
 *                     try:             # <<<<<<<<<<<<<<
 *                         label = ''.join(group[i:j])
 *                         for elem, cnt in aa_comp[label].items():
 */
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {

            /* "pyteomics/cmass.pyx":372
 *                 for j in range(len(group)+1, -1, -1):
 *                     try:
 *                         label = ''.join(group[i:j])             # <<<<<<<<<<<<<<
 *                         for elem, cnt in aa_comp[label].items():
 *                             comp[elem] += cnt
 */
            __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_group, 0, __pyx_v_j, &__pyx_v_i, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 372, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__15, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF_SET(__pyx_v_label, ((PyObject*)__pyx_t_2));
            __pyx_t_2 = 0;

            /* "pyteomics/cmass.pyx":373
 *                     try:
 *                         label = ''.join(group[i:j])
 *                         for elem, cnt in aa_comp[label].items():             # <<<<<<<<<<<<<<
 *                             comp[elem] += cnt
 *                     except KeyError:
 */
            __pyx_t_4 = PyObject_GetItem(__pyx_v_aa_comp, __pyx_v_label); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = NULL;
            if (CYTHON_UNPACK_METHODS && 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, 373, __pyx_L9_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, 373, __pyx_L9_error)
            }
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
              __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_13 = 0;
              __pyx_t_14 = NULL;
            } else {
              __pyx_t_13 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 373, __pyx_L9_error)
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            for (;;) {
              if (likely(!__pyx_t_14)) {
                if (likely(PyList_CheckExact(__pyx_t_3))) {
                  if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_3)) break;
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_2); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 373, __pyx_L9_error)
                  #else
                  __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L9_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  #endif
                } else {
                  if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_2); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 373, __pyx_L9_error)
                  #else
                  __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L9_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  #endif
                }
              } else {
                __pyx_t_2 = __pyx_t_14(__pyx_t_3);
                if (unlikely(!__pyx_t_2)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                    else __PYX_ERR(0, 373, __pyx_L9_error)
                  }
                  break;
                }
                __Pyx_GOTREF(__pyx_t_2);
              }
              if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
                PyObject* sequence = __pyx_t_2;
                #if !CYTHON_COMPILING_IN_PYPY
                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, 373, __pyx_L9_error)
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                if (likely(PyTuple_CheckExact(sequence))) {
                  __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
                  __pyx_t_15 = PyTuple_GET_ITEM(sequence, 1); 
                } else {
                  __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
                  __pyx_t_15 = PyList_GET_ITEM(sequence, 1); 
                }
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_15);
                #else
                __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L9_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_15 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 373, __pyx_L9_error)
                __Pyx_GOTREF(__pyx_t_15);
                #endif
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              } else {
                Py_ssize_t index = -1;
                __pyx_t_16 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 373, __pyx_L9_error)
                __Pyx_GOTREF(__pyx_t_16);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_17 = Py_TYPE(__pyx_t_16)->tp_iternext;
                index = 0; __pyx_t_4 = __pyx_t_17(__pyx_t_16); if (unlikely(!__pyx_t_4)) goto __pyx_L19_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_4);
                index = 1; __pyx_t_15 = __pyx_t_17(__pyx_t_16); if (unlikely(!__pyx_t_15)) goto __pyx_L19_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_15);
                if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_16), 2) < 0) __PYX_ERR(0, 373, __pyx_L9_error)
                __pyx_t_17 = NULL;
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                goto __pyx_L20_unpacking_done;
                __pyx_L19_unpacking_failed:;
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                __pyx_t_17 = NULL;
                if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
                __PYX_ERR(0, 373, __pyx_L9_error)
                __pyx_L20_unpacking_done:;
              }
              __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_4);
              __pyx_t_4 = 0;
              __Pyx_XDECREF_SET(__pyx_v_cnt, __pyx_t_15);
              __pyx_t_15 = 0;

              /* "pyteomics/cmass.pyx":374
 *                         label = ''.join(group[i:j])
 *                         for elem, cnt in aa_comp[label].items():
 *                             comp[elem] += cnt             # <<<<<<<<<<<<<<
 *                     except KeyError:
 *                         continue
 */
              __Pyx_INCREF(__pyx_v_elem);
              __pyx_t_2 = __pyx_v_elem;
              __pyx_t_15 = PyObject_GetItem(__pyx_v_comp, __pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 374, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_15, __pyx_v_cnt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 374, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(PyObject_SetItem(__pyx_v_comp, __pyx_t_2, __pyx_t_4) < 0)) __PYX_ERR(0, 374, __pyx_L9_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

              /* "pyteomics/cmass.pyx":373
 *                     try:
 *                         label = ''.join(group[i:j])
 *                         for elem, cnt in aa_comp[label].items():             # <<<<<<<<<<<<<<
 *                             comp[elem] += cnt
 *                     except KeyError:
 */
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "pyteomics/cmass.pyx":371
 *             while i < len(group):
 *                 for j in range(len(group)+1, -1, -1):
 *                     try:             # <<<<<<<<<<<<<<
 *                         label = ''.join(group[i:j])
 *                         for elem, cnt in aa_comp[label].items():
 */
          }

          /* "pyteomics/cmass.pyx":378
 *                         continue
 *                     else:
 *                         i = j             # <<<<<<<<<<<<<<
 *                         break
 *                 if j == 0:
 */
          /*else:*/ {
            __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L11_except_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_3);
            __pyx_t_3 = 0;

            /* "pyteomics/cmass.pyx":379
 *                     else:
 *                         i = j
 *                         break             # <<<<<<<<<<<<<<
 *                 if j == 0:
 *                     raise PyteomicsError("Invalid group starting from "
 */
            goto __pyx_L14_try_break;
          }
          __pyx_L9_error:;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pyteomics/cmass.pyx":375
 *                         for elem, cnt in aa_comp[label].items():
 *                             comp[elem] += cnt
 *                     except KeyError:             # <<<<<<<<<<<<<<
 *                         continue
 *                     else:
 */
          __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
          if (__pyx_t_18) {
            __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_split_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 375, __pyx_L11_except_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_GOTREF(__pyx_t_4);

            /* "pyteomics/cmass.pyx":376
 *                             comp[elem] += cnt
 *                     except KeyError:
 *                         continue             # <<<<<<<<<<<<<<
 *                     else:
 *                         i = j
 */
            goto __pyx_L22_except_continue;
            __pyx_L22_except_continue:;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L15_try_continue;
          }
          goto __pyx_L11_except_error;
          __pyx_L11_except_error:;

          /* "pyteomics/cmass.pyx":371
 *             while i < len(group):
 *                 for j in range(len(group)+1, -1, -1):
 *                     try:             # <<<<<<<<<<<<<<
 *                         label = ''.join(group[i:j])
 *                         for elem, cnt in aa_comp[label].items():
 */
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L1_error;
          __pyx_L14_try_break:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L8_break;
          __pyx_L15_try_continue:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L7_continue;
        }
        __pyx_L7_continue:;
      }
      __pyx_L8_break:;

      /* "pyteomics/cmass.pyx":380
 *                         i = j
 *                         break
 *                 if j == 0:             # <<<<<<<<<<<<<<
 *                     raise PyteomicsError("Invalid group starting from "
 *                             "position %d: %s" % (i+1, group))
 */
      __pyx_t_8 = ((__pyx_v_j == 0) != 0);
      if (__pyx_t_8) {

        /* "pyteomics/cmass.pyx":381
 *                         break
 *                 if j == 0:
 *                     raise PyteomicsError("Invalid group starting from "             # <<<<<<<<<<<<<<
 *                             "position %d: %s" % (i+1, group))
 *         self._from_dict(comp)
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);

        /* "pyteomics/cmass.pyx":382
 *                 if j == 0:
 *                     raise PyteomicsError("Invalid group starting from "
 *                             "position %d: %s" % (i+1, group))             # <<<<<<<<<<<<<<
 *         self._from_dict(comp)
 * 
 */
        __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 382, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 382, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_group);
        __Pyx_GIVEREF(__pyx_v_group);
        PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_group);
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_group_starting_from_posi, __pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 382, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_15 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_15)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        if (!__pyx_t_15) {
          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_4);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_3};
            __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
            PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_3};
            __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          } else
          #endif
          {
            __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 381, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
            __Pyx_GIVEREF(__pyx_t_3);
            PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_3);
            __pyx_t_3 = 0;
            __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_16, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 381, __pyx_L1_error)

        /* "pyteomics/cmass.pyx":380
 *                         i = j
 *                         break
 *                 if j == 0:             # <<<<<<<<<<<<<<
 *                     raise PyteomicsError("Invalid group starting from "
 *                             "position %d: %s" % (i+1, group))
 */
      }
    }

    /* "pyteomics/cmass.pyx":367
 *         self.clear()
 *         comp = defaultdict(int)
 *         for group in split_sequence:             # <<<<<<<<<<<<<<
 *             i = 0
 *             while i < len(group):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":383
 *                     raise PyteomicsError("Invalid group starting from "
 *                             "position %d: %s" % (i+1, group))
 *         self._from_dict(comp)             # <<<<<<<<<<<<<<
 * 
 *     def _from_sequence(self, sequence, aa_comp):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *)__pyx_v_self->__pyx_vtab)->_from_dict(__pyx_v_self, __pyx_v_comp, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":364
 *         self._from_dict(comp)
 * 
 *     def _from_split_sequence(self, split_sequence, aa_comp):             # <<<<<<<<<<<<<<
 *         self.clear()
 *         comp = defaultdict(int)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_split_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_comp);
  __Pyx_XDECREF(__pyx_v_group);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_label);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF(__pyx_v_cnt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":385
 *         self._from_dict(comp)
 * 
 *     def _from_sequence(self, sequence, aa_comp):             # <<<<<<<<<<<<<<
 *         parsed_sequence = cparser.parse(
 *             sequence,
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_5_from_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_4_from_sequence[] = "CComposition._from_sequence(self, sequence, aa_comp)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_5_from_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence = 0;
  PyObject *__pyx_v_aa_comp = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_from_sequence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence,&__pyx_n_s_aa_comp,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_sequence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_aa_comp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_from_sequence", 1, 2, 2, 1); __PYX_ERR(0, 385, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_from_sequence") < 0)) __PYX_ERR(0, 385, __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_sequence = values[0];
    __pyx_v_aa_comp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_from_sequence", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 385, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_4_from_sequence(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_sequence, __pyx_v_aa_comp);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_4_from_sequence(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_sequence, PyObject *__pyx_v_aa_comp) {
  PyObject *__pyx_v_parsed_sequence = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("_from_sequence", 0);
  __Pyx_TraceCall("_from_sequence", __pyx_f[0], 385, 0, __PYX_ERR(0, 385, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":386
 * 
 *     def _from_sequence(self, sequence, aa_comp):
 *         parsed_sequence = cparser.parse(             # <<<<<<<<<<<<<<
 *             sequence,
 *             labels=aa_comp,
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cparser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_parse); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":387
 *     def _from_sequence(self, sequence, aa_comp):
 *         parsed_sequence = cparser.parse(
 *             sequence,             # <<<<<<<<<<<<<<
 *             labels=aa_comp,
 *             show_unmodified_termini=True)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_sequence);
  __Pyx_GIVEREF(__pyx_v_sequence);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sequence);

  /* "pyteomics/cmass.pyx":388
 *         parsed_sequence = cparser.parse(
 *             sequence,
 *             labels=aa_comp,             # <<<<<<<<<<<<<<
 *             show_unmodified_termini=True)
 *         self._from_parsed_sequence(parsed_sequence, aa_comp)
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_labels, __pyx_v_aa_comp) < 0) __PYX_ERR(0, 388, __pyx_L1_error)

  /* "pyteomics/cmass.pyx":389
 *             sequence,
 *             labels=aa_comp,
 *             show_unmodified_termini=True)             # <<<<<<<<<<<<<<
 *         self._from_parsed_sequence(parsed_sequence, aa_comp)
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_show_unmodified_termini, Py_True) < 0) __PYX_ERR(0, 388, __pyx_L1_error)

  /* "pyteomics/cmass.pyx":386
 * 
 *     def _from_sequence(self, sequence, aa_comp):
 *         parsed_sequence = cparser.parse(             # <<<<<<<<<<<<<<
 *             sequence,
 *             labels=aa_comp,
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_parsed_sequence = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pyteomics/cmass.pyx":390
 *             labels=aa_comp,
 *             show_unmodified_termini=True)
 *         self._from_parsed_sequence(parsed_sequence, aa_comp)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):   # pragma: no cover
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_parsed_sequence); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_parsed_sequence, __pyx_v_aa_comp};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_parsed_sequence, __pyx_v_aa_comp};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_parsed_sequence);
    __Pyx_GIVEREF(__pyx_v_parsed_sequence);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_5, __pyx_v_parsed_sequence);
    __Pyx_INCREF(__pyx_v_aa_comp);
    __Pyx_GIVEREF(__pyx_v_aa_comp);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_5, __pyx_v_aa_comp);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pyteomics/cmass.pyx":385
 *         self._from_dict(comp)
 * 
 *     def _from_sequence(self, sequence, aa_comp):             # <<<<<<<<<<<<<<
 *         parsed_sequence = cparser.parse(
 *             sequence,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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_AddTraceback("pyteomics.cmass.CComposition._from_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parsed_sequence);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":392
 *         self._from_parsed_sequence(parsed_sequence, aa_comp)
 * 
 *     def __str__(self):   # pragma: no cover             # <<<<<<<<<<<<<<
 *         return 'Composition({})'.format(dict.__repr__(self))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_7__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_7__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_6__str__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_6__str__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__str__", 0);
  __Pyx_TraceCall("__str__", __pyx_f[0], 392, 0, __PYX_ERR(0, 392, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":393
 * 
 *     def __str__(self):   # pragma: no cover
 *         return 'Composition({})'.format(dict.__repr__(self))             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):  # pragma: no cover
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Composition, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyDict_Type)), __pyx_n_s_repr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_self)};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, ((PyObject *)__pyx_v_self)};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_self));
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __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_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __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_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":392
 *         self._from_parsed_sequence(parsed_sequence, aa_comp)
 * 
 *     def __str__(self):   # pragma: no cover             # <<<<<<<<<<<<<<
 *         return 'Composition({})'.format(dict.__repr__(self))
 * 
 */

  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":395
 *         return 'Composition({})'.format(dict.__repr__(self))
 * 
 *     def __repr__(self):  # pragma: no cover             # <<<<<<<<<<<<<<
 *         return str(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_9__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_9__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_8__repr__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_8__repr__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);
  __Pyx_TraceCall("__repr__", __pyx_f[0], 395, 0, __PYX_ERR(0, 395, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":396
 * 
 *     def __repr__(self):  # pragma: no cover
 *         return str(self)             # <<<<<<<<<<<<<<
 * 
 *     def __iadd__(CComposition self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 396, __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;

  /* "pyteomics/cmass.pyx":395
 *         return 'Composition({})'.format(dict.__repr__(self))
 * 
 *     def __repr__(self):  # pragma: no cover             # <<<<<<<<<<<<<<
 *         return str(self)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":398
 *         return str(self)
 * 
 *     def __iadd__(CComposition self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_11__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_11__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_10__iadd__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_10__iadd__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_elem = 0;
  long __pyx_v_cnt;
  PyObject *__pyx_v_pkey;
  PyObject *__pyx_v_pvalue;
  Py_ssize_t __pyx_v_ppos;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  long __pyx_t_3;
  __Pyx_RefNannySetupContext("__iadd__", 0);
  __Pyx_TraceCall("__iadd__", __pyx_f[0], 398, 0, __PYX_ERR(0, 398, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":404
 *             PyObject *pkey
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0             # <<<<<<<<<<<<<<
 * 
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 */
  __pyx_v_ppos = 0;

  /* "pyteomics/cmass.pyx":406
 *             Py_ssize_t ppos = 0
 * 
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):             # <<<<<<<<<<<<<<
 *             elem = <str>pkey
 *             cnt = self.getitem(elem)
 */
  while (1) {
    __pyx_t_1 = (PyDict_Next(__pyx_v_other, (&__pyx_v_ppos), (&__pyx_v_pkey), (&__pyx_v_pvalue)) != 0);
    if (!__pyx_t_1) break;

    /* "pyteomics/cmass.pyx":407
 * 
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey             # <<<<<<<<<<<<<<
 *             cnt = self.getitem(elem)
 *             self.setitem(elem, cnt + PyInt_AsLong(<object>pvalue))
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_pkey);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_elem, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":408
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey
 *             cnt = self.getitem(elem)             # <<<<<<<<<<<<<<
 *             self.setitem(elem, cnt + PyInt_AsLong(<object>pvalue))
 * 
 */
    __pyx_v_cnt = __pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_self, __pyx_v_elem);

    /* "pyteomics/cmass.pyx":409
 *             elem = <str>pkey
 *             cnt = self.getitem(elem)
 *             self.setitem(elem, cnt + PyInt_AsLong(<object>pvalue))             # <<<<<<<<<<<<<<
 * 
 *         self._mass_args = None
 */
    __pyx_t_3 = PyInt_AsLong(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_3 == -1L && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L1_error)
    __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_self, __pyx_v_elem, (__pyx_v_cnt + __pyx_t_3));
  }

  /* "pyteomics/cmass.pyx":411
 *             self.setitem(elem, cnt + PyInt_AsLong(<object>pvalue))
 * 
 *         self._mass_args = None             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass_args);
  __Pyx_DECREF(__pyx_v_self->_mass_args);
  __pyx_v_self->_mass_args = ((PyObject*)Py_None);

  /* "pyteomics/cmass.pyx":412
 * 
 *         self._mass_args = None
 *         return self             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":398
 *         return str(self)
 * 
 *     def __iadd__(CComposition self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__iadd__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":415
 * 
 * 
 *     def __add__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_13__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_13__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_12__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_12__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_elem = 0;
  long __pyx_v_cnt;
  struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_result = 0;
  PyObject *__pyx_v_pkey;
  PyObject *__pyx_v_pvalue;
  Py_ssize_t __pyx_v_ppos;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  long __pyx_t_7;
  __Pyx_RefNannySetupContext("__add__", 0);
  __Pyx_TraceCall("__add__", __pyx_f[0], 415, 0, __PYX_ERR(0, 415, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_other);

  /* "pyteomics/cmass.pyx":422
 *             PyObject *pkey
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0             # <<<<<<<<<<<<<<
 *         if not isinstance(self, CComposition):
 *             other, self = self, other
 */
  __pyx_v_ppos = 0;

  /* "pyteomics/cmass.pyx":423
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0
 *         if not isinstance(self, CComposition):             # <<<<<<<<<<<<<<
 *             other, self = self, other
 *         result = CComposition(self)
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_self, __pyx_ptype_9pyteomics_5cmass_CComposition); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":424
 *             Py_ssize_t ppos = 0
 *         if not isinstance(self, CComposition):
 *             other, self = self, other             # <<<<<<<<<<<<<<
 *         result = CComposition(self)
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 */
    __pyx_t_3 = __pyx_v_self;
    __pyx_t_4 = __pyx_v_other;
    __pyx_v_other = __pyx_t_3;
    __pyx_t_3 = 0;
    __pyx_v_self = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "pyteomics/cmass.pyx":423
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0
 *         if not isinstance(self, CComposition):             # <<<<<<<<<<<<<<
 *             other, self = self, other
 *         result = CComposition(self)
 */
  }

  /* "pyteomics/cmass.pyx":425
 *         if not isinstance(self, CComposition):
 *             other, self = self, other
 *         result = CComposition(self)             # <<<<<<<<<<<<<<
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_result = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pyteomics/cmass.pyx":426
 *             other, self = self, other
 *         result = CComposition(self)
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):             # <<<<<<<<<<<<<<
 *             elem = <str>pkey
 *             cnt = result.getitem(elem)
 */
  while (1) {
    __pyx_t_2 = (PyDict_Next(__pyx_v_other, (&__pyx_v_ppos), (&__pyx_v_pkey), (&__pyx_v_pvalue)) != 0);
    if (!__pyx_t_2) break;

    /* "pyteomics/cmass.pyx":427
 *         result = CComposition(self)
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey             # <<<<<<<<<<<<<<
 *             cnt = result.getitem(elem)
 *             cnt += PyInt_AsLong(<object>pvalue)
 */
    __pyx_t_6 = ((PyObject *)__pyx_v_pkey);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_elem, ((PyObject*)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "pyteomics/cmass.pyx":428
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey
 *             cnt = result.getitem(elem)             # <<<<<<<<<<<<<<
 *             cnt += PyInt_AsLong(<object>pvalue)
 *             result.setitem(elem, cnt)
 */
    __pyx_v_cnt = __pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_result, __pyx_v_elem);

    /* "pyteomics/cmass.pyx":429
 *             elem = <str>pkey
 *             cnt = result.getitem(elem)
 *             cnt += PyInt_AsLong(<object>pvalue)             # <<<<<<<<<<<<<<
 *             result.setitem(elem, cnt)
 * 
 */
    __pyx_t_7 = PyInt_AsLong(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_7 == -1L && PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
    __pyx_v_cnt = (__pyx_v_cnt + __pyx_t_7);

    /* "pyteomics/cmass.pyx":430
 *             cnt = result.getitem(elem)
 *             cnt += PyInt_AsLong(<object>pvalue)
 *             result.setitem(elem, cnt)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_result, __pyx_v_elem, __pyx_v_cnt);
  }

  /* "pyteomics/cmass.pyx":432
 *             result.setitem(elem, cnt)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def __isub__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":415
 * 
 * 
 *     def __add__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_self);
  __Pyx_XDECREF(__pyx_v_other);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":434
 *         return result
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_15__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_15__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_14__isub__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_14__isub__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_elem = 0;
  long __pyx_v_cnt;
  PyObject *__pyx_v_pkey;
  PyObject *__pyx_v_pvalue;
  Py_ssize_t __pyx_v_ppos;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  long __pyx_t_3;
  __Pyx_RefNannySetupContext("__isub__", 0);
  __Pyx_TraceCall("__isub__", __pyx_f[0], 434, 0, __PYX_ERR(0, 434, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":440
 *             PyObject *pkey
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0             # <<<<<<<<<<<<<<
 * 
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 */
  __pyx_v_ppos = 0;

  /* "pyteomics/cmass.pyx":442
 *             Py_ssize_t ppos = 0
 * 
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):             # <<<<<<<<<<<<<<
 *             elem = <str>pkey
 *             cnt = self.getitem(elem)
 */
  while (1) {
    __pyx_t_1 = (PyDict_Next(__pyx_v_other, (&__pyx_v_ppos), (&__pyx_v_pkey), (&__pyx_v_pvalue)) != 0);
    if (!__pyx_t_1) break;

    /* "pyteomics/cmass.pyx":443
 * 
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey             # <<<<<<<<<<<<<<
 *             cnt = self.getitem(elem)
 *             self.setitem(elem, cnt - PyInt_AsLong(<object>pvalue))
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_pkey);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_elem, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":444
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey
 *             cnt = self.getitem(elem)             # <<<<<<<<<<<<<<
 *             self.setitem(elem, cnt - PyInt_AsLong(<object>pvalue))
 * 
 */
    __pyx_v_cnt = __pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_self, __pyx_v_elem);

    /* "pyteomics/cmass.pyx":445
 *             elem = <str>pkey
 *             cnt = self.getitem(elem)
 *             self.setitem(elem, cnt - PyInt_AsLong(<object>pvalue))             # <<<<<<<<<<<<<<
 * 
 *         self._mass_args = None
 */
    __pyx_t_3 = PyInt_AsLong(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_3 == -1L && PyErr_Occurred())) __PYX_ERR(0, 445, __pyx_L1_error)
    __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_self, __pyx_v_elem, (__pyx_v_cnt - __pyx_t_3));
  }

  /* "pyteomics/cmass.pyx":447
 *             self.setitem(elem, cnt - PyInt_AsLong(<object>pvalue))
 * 
 *         self._mass_args = None             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass_args);
  __Pyx_DECREF(__pyx_v_self->_mass_args);
  __pyx_v_self->_mass_args = ((PyObject*)Py_None);

  /* "pyteomics/cmass.pyx":448
 * 
 *         self._mass_args = None
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __sub__(self, other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":434
 *         return result
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__isub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":450
 *         return self
 * 
 *     def __sub__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_17__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_17__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_16__sub__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_16__sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_elem = 0;
  long __pyx_v_cnt;
  struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_result = 0;
  PyObject *__pyx_v_pkey;
  PyObject *__pyx_v_pvalue;
  Py_ssize_t __pyx_v_ppos;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  long __pyx_t_5;
  __Pyx_RefNannySetupContext("__sub__", 0);
  __Pyx_TraceCall("__sub__", __pyx_f[0], 450, 0, __PYX_ERR(0, 450, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_self);

  /* "pyteomics/cmass.pyx":457
 *             PyObject *pkey
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0             # <<<<<<<<<<<<<<
 *         if not isinstance(self, CComposition):
 *             self = CComposition(self)
 */
  __pyx_v_ppos = 0;

  /* "pyteomics/cmass.pyx":458
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0
 *         if not isinstance(self, CComposition):             # <<<<<<<<<<<<<<
 *             self = CComposition(self)
 *         result = CComposition(self)
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_self, __pyx_ptype_9pyteomics_5cmass_CComposition); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":459
 *             Py_ssize_t ppos = 0
 *         if not isinstance(self, CComposition):
 *             self = CComposition(self)             # <<<<<<<<<<<<<<
 *         result = CComposition(self)
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 459, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 459, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_self, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pyteomics/cmass.pyx":458
 *             PyObject *pvalue
 *             Py_ssize_t ppos = 0
 *         if not isinstance(self, CComposition):             # <<<<<<<<<<<<<<
 *             self = CComposition(self)
 *         result = CComposition(self)
 */
  }

  /* "pyteomics/cmass.pyx":460
 *         if not isinstance(self, CComposition):
 *             self = CComposition(self)
 *         result = CComposition(self)             # <<<<<<<<<<<<<<
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_result = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":461
 *             self = CComposition(self)
 *         result = CComposition(self)
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):             # <<<<<<<<<<<<<<
 *             elem = <str>pkey
 *             cnt = result.getitem(elem)
 */
  while (1) {
    __pyx_t_2 = (PyDict_Next(__pyx_v_other, (&__pyx_v_ppos), (&__pyx_v_pkey), (&__pyx_v_pvalue)) != 0);
    if (!__pyx_t_2) break;

    /* "pyteomics/cmass.pyx":462
 *         result = CComposition(self)
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey             # <<<<<<<<<<<<<<
 *             cnt = result.getitem(elem)
 *             cnt -= PyInt_AsLong(<object>pvalue)
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_pkey);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_elem, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "pyteomics/cmass.pyx":463
 *         while(PyDict_Next(other, &ppos, &pkey, &pvalue)):
 *             elem = <str>pkey
 *             cnt = result.getitem(elem)             # <<<<<<<<<<<<<<
 *             cnt -= PyInt_AsLong(<object>pvalue)
 *             result.setitem(elem, cnt)
 */
    __pyx_v_cnt = __pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_result, __pyx_v_elem);

    /* "pyteomics/cmass.pyx":464
 *             elem = <str>pkey
 *             cnt = result.getitem(elem)
 *             cnt -= PyInt_AsLong(<object>pvalue)             # <<<<<<<<<<<<<<
 *             result.setitem(elem, cnt)
 * 
 */
    __pyx_t_5 = PyInt_AsLong(((PyObject *)__pyx_v_pvalue)); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(0, 464, __pyx_L1_error)
    __pyx_v_cnt = (__pyx_v_cnt - __pyx_t_5);

    /* "pyteomics/cmass.pyx":465
 *             cnt = result.getitem(elem)
 *             cnt -= PyInt_AsLong(<object>pvalue)
 *             result.setitem(elem, cnt)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_result, __pyx_v_elem, __pyx_v_cnt);
  }

  /* "pyteomics/cmass.pyx":467
 *             result.setitem(elem, cnt)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":450
 *         return self
 * 
 *     def __sub__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":469
 *         return result
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return marshal_ccomposition, (dict(self),)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_19__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_18__reduce__[] = "CComposition.__reduce__(self)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_19__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_18__reduce__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_18__reduce__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__reduce__", 0);
  __Pyx_TraceCall("__reduce__", __pyx_f[0], 469, 0, __PYX_ERR(0, 469, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":470
 * 
 *     def __reduce__(self):
 *         return marshal_ccomposition, (dict(self),)             # <<<<<<<<<<<<<<
 * 
 *     def __getstate__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_marshal_ccomposition); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 470, __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, 470, __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 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 470, __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_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":469
 *         return result
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return marshal_ccomposition, (dict(self),)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":472
 *         return marshal_ccomposition, (dict(self),)
 * 
 *     def __getstate__(self):             # <<<<<<<<<<<<<<
 *         return dict(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_21__getstate__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_20__getstate__[] = "CComposition.__getstate__(self)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_21__getstate__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_20__getstate__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_20__getstate__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__getstate__", 0);
  __Pyx_TraceCall("__getstate__", __pyx_f[0], 472, 0, __PYX_ERR(0, 472, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":473
 * 
 *     def __getstate__(self):
 *         return dict(self)             # <<<<<<<<<<<<<<
 * 
 *     def __setstate__(self, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __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;

  /* "pyteomics/cmass.pyx":472
 *         return marshal_ccomposition, (dict(self),)
 * 
 *     def __getstate__(self):             # <<<<<<<<<<<<<<
 *         return dict(self)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__getstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":475
 *         return dict(self)
 * 
 *     def __setstate__(self, d):             # <<<<<<<<<<<<<<
 *         self._from_dict(d)
 *         self._mass = None
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_23__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_d); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_22__setstate__[] = "CComposition.__setstate__(self, d)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_23__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_22__setstate__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), ((PyObject *)__pyx_v_d));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_22__setstate__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate__", 0);
  __Pyx_TraceCall("__setstate__", __pyx_f[0], 475, 0, __PYX_ERR(0, 475, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":476
 * 
 *     def __setstate__(self, d):
 *         self._from_dict(d)             # <<<<<<<<<<<<<<
 *         self._mass = None
 *         self._mass_args = None
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *)__pyx_v_self->__pyx_vtab)->_from_dict(__pyx_v_self, __pyx_v_d, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":477
 *     def __setstate__(self, d):
 *         self._from_dict(d)
 *         self._mass = None             # <<<<<<<<<<<<<<
 *         self._mass_args = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass);
  __Pyx_DECREF(__pyx_v_self->_mass);
  __pyx_v_self->_mass = Py_None;

  /* "pyteomics/cmass.pyx":478
 *         self._from_dict(d)
 *         self._mass = None
 *         self._mass_args = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass_args);
  __Pyx_DECREF(__pyx_v_self->_mass_args);
  __pyx_v_self->_mass_args = ((PyObject*)Py_None);

  /* "pyteomics/cmass.pyx":475
 *         return dict(self)
 * 
 *     def __setstate__(self, d):             # <<<<<<<<<<<<<<
 *         self._from_dict(d)
 *         self._mass = None
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":481
 * 
 * 
 *     def __mul__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             CComposition prod = CComposition()
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_25__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_25__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_24__mul__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_24__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_prod = 0;
  int __pyx_v_rep;
  int __pyx_v_v;
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  __Pyx_RefNannySetupContext("__mul__", 0);
  __Pyx_TraceCall("__mul__", __pyx_f[0], 481, 0, __PYX_ERR(0, 481, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_other);

  /* "pyteomics/cmass.pyx":483
 *     def __mul__(self, other):
 *         cdef:
 *             CComposition prod = CComposition()             # <<<<<<<<<<<<<<
 *             int rep, v
 *             str k
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_prod = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":487
 *             str k
 * 
 *         if isinstance(other, CComposition):             # <<<<<<<<<<<<<<
 *             self, other = other, self
 * 
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_9pyteomics_5cmass_CComposition); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pyteomics/cmass.pyx":488
 * 
 *         if isinstance(other, CComposition):
 *             self, other = other, self             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(other, int):
 */
    __pyx_t_4 = __pyx_v_other;
    __pyx_t_5 = __pyx_v_self;
    __pyx_v_self = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_other = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "pyteomics/cmass.pyx":487
 *             str k
 * 
 *         if isinstance(other, CComposition):             # <<<<<<<<<<<<<<
 *             self, other = other, self
 * 
 */
  }

  /* "pyteomics/cmass.pyx":490
 *             self, other = other, self
 * 
 *         if not isinstance(other, int):             # <<<<<<<<<<<<<<
 *             raise PyteomicsError(
 *                 'Cannot multiply Composition by non-integer',
 */
  __pyx_t_3 = PyInt_Check(__pyx_v_other); 
  __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":491
 * 
 *         if not isinstance(other, int):
 *             raise PyteomicsError(             # <<<<<<<<<<<<<<
 *                 'Cannot multiply Composition by non-integer',
 *                 other)
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "pyteomics/cmass.pyx":493
 *             raise PyteomicsError(
 *                 'Cannot multiply Composition by non-integer',
 *                 other)             # <<<<<<<<<<<<<<
 *         rep = other
 *         for k, v in self.items():
 */
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && 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_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_Cannot_multiply_Composition_by_n, __pyx_v_other};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_Cannot_multiply_Composition_by_n, __pyx_v_other};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 491, __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_INCREF(__pyx_kp_s_Cannot_multiply_Composition_by_n);
      __Pyx_GIVEREF(__pyx_kp_s_Cannot_multiply_Composition_by_n);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_Cannot_multiply_Composition_by_n);
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_other);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __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, 491, __pyx_L1_error)

    /* "pyteomics/cmass.pyx":490
 *             self, other = other, self
 * 
 *         if not isinstance(other, int):             # <<<<<<<<<<<<<<
 *             raise PyteomicsError(
 *                 'Cannot multiply Composition by non-integer',
 */
  }

  /* "pyteomics/cmass.pyx":494
 *                 'Cannot multiply Composition by non-integer',
 *                 other)
 *         rep = other             # <<<<<<<<<<<<<<
 *         for k, v in self.items():
 *             prod.setitem(k, v * rep)
 */
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_other); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 494, __pyx_L1_error)
  __pyx_v_rep = __pyx_t_8;

  /* "pyteomics/cmass.pyx":495
 *                 other)
 *         rep = other
 *         for k, v in self.items():             # <<<<<<<<<<<<<<
 *             prod.setitem(k, v * rep)
 *         return prod
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_items); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (__pyx_t_9) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_6 = __pyx_t_1; __Pyx_INCREF(__pyx_t_6); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 495, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 495, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 495, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_11(__pyx_t_6);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 495, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if !CYTHON_COMPILING_IN_PYPY
      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, 495, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 495, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 495, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_12 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 495, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
      index = 0; __pyx_t_9 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_9)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      index = 1; __pyx_t_7 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) __PYX_ERR(0, 495, __pyx_L1_error)
      __pyx_t_13 = NULL;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L8_unpacking_done;
      __pyx_L7_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 495, __pyx_L1_error)
      __pyx_L8_unpacking_done:;
    }
    if (!(likely(PyString_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_9)->tp_name), 0))) __PYX_ERR(0, 495, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k, ((PyObject*)__pyx_t_9));
    __pyx_t_9 = 0;
    __pyx_v_v = __pyx_t_8;

    /* "pyteomics/cmass.pyx":496
 *         rep = other
 *         for k, v in self.items():
 *             prod.setitem(k, v * rep)             # <<<<<<<<<<<<<<
 *         return prod
 * 
 */
    __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_prod, __pyx_v_k, (__pyx_v_v * __pyx_v_rep));

    /* "pyteomics/cmass.pyx":495
 *                 other)
 *         rep = other
 *         for k, v in self.items():             # <<<<<<<<<<<<<<
 *             prod.setitem(k, v * rep)
 *         return prod
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyteomics/cmass.pyx":497
 *         for k, v in self.items():
 *             prod.setitem(k, v * rep)
 *         return prod             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(self, other, int code):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_prod));
  __pyx_r = ((PyObject *)__pyx_v_prod);
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":481
 * 
 * 
 *     def __mul__(self, other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             CComposition prod = CComposition()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__mul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_prod);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_self);
  __Pyx_XDECREF(__pyx_v_other);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":499
 *         return prod
 * 
 *     def __richcmp__(self, other, int code):             # <<<<<<<<<<<<<<
 *         if code == 2:
 *             if not isinstance(other, dict):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_27__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_code); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_27__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_code) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_26__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((int)__pyx_v_code));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_26__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_code) {
  PyObject *__pyx_v_self_items = NULL;
  PyObject *__pyx_v_other_items = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  __Pyx_RefNannySetupContext("__richcmp__", 0);
  __Pyx_TraceCall("__richcmp__", __pyx_f[0], 499, 0, __PYX_ERR(0, 499, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":500
 * 
 *     def __richcmp__(self, other, int code):
 *         if code == 2:             # <<<<<<<<<<<<<<
 *             if not isinstance(other, dict):
 *                 return False
 */
  __pyx_t_1 = ((__pyx_v_code == 2) != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":501
 *     def __richcmp__(self, other, int code):
 *         if code == 2:
 *             if not isinstance(other, dict):             # <<<<<<<<<<<<<<
 *                 return False
 *             self_items = set([i for i in self.items() if i[1]])
 */
    __pyx_t_1 = PyDict_Check(__pyx_v_other); 
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "pyteomics/cmass.pyx":502
 *         if code == 2:
 *             if not isinstance(other, dict):
 *                 return False             # <<<<<<<<<<<<<<
 *             self_items = set([i for i in self.items() if i[1]])
 *             other_items = set([i for i in other.items() if i[1]])
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L0;

      /* "pyteomics/cmass.pyx":501
 *     def __richcmp__(self, other, int code):
 *         if code == 2:
 *             if not isinstance(other, dict):             # <<<<<<<<<<<<<<
 *                 return False
 *             self_items = set([i for i in self.items() if i[1]])
 */
    }

    /* "pyteomics/cmass.pyx":503
 *             if not isinstance(other, dict):
 *                 return False
 *             self_items = set([i for i in self.items() if i[1]])             # <<<<<<<<<<<<<<
 *             other_items = set([i for i in other.items() if i[1]])
 *             return self_items == other_items
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_items); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 503, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 503, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 503, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 503, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_8(__pyx_t_5);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 503, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_i, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 503, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_2) {
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_v_i))) __PYX_ERR(0, 503, __pyx_L1_error)
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PySet_New(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_self_items = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "pyteomics/cmass.pyx":504
 *                 return False
 *             self_items = set([i for i in self.items() if i[1]])
 *             other_items = set([i for i in other.items() if i[1]])             # <<<<<<<<<<<<<<
 *             return self_items == other_items
 *         else:
 */
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 504, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 504, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 504, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_8(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 504, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_i, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 504, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_2) {
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_v_i))) __PYX_ERR(0, 504, __pyx_L1_error)
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PySet_New(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_other_items = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pyteomics/cmass.pyx":505
 *             self_items = set([i for i in self.items() if i[1]])
 *             other_items = set([i for i in other.items() if i[1]])
 *             return self_items == other_items             # <<<<<<<<<<<<<<
 *         else:
 *             return NotImplemented
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_self_items, __pyx_v_other_items, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 505, __pyx_L1_error)
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "pyteomics/cmass.pyx":500
 * 
 *     def __richcmp__(self, other, int code):
 *         if code == 2:             # <<<<<<<<<<<<<<
 *             if not isinstance(other, dict):
 *                 return False
 */
  }

  /* "pyteomics/cmass.pyx":507
 *             return self_items == other_items
 *         else:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 * 
 *     def __neg__(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;
  }

  /* "pyteomics/cmass.pyx":499
 *         return prod
 * 
 *     def __richcmp__(self, other, int code):             # <<<<<<<<<<<<<<
 *         if code == 2:
 *             if not isinstance(other, dict):
 */

  /* 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("pyteomics.cmass.CComposition.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_self_items);
  __Pyx_XDECREF(__pyx_v_other_items);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":509
 *             return NotImplemented
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return self * -1
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_29__neg__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_29__neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_28__neg__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_28__neg__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__neg__", 0);
  __Pyx_TraceCall("__neg__", __pyx_f[0], 509, 0, __PYX_ERR(0, 509, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":510
 * 
 *     def __neg__(self):
 *         return self * -1             # <<<<<<<<<<<<<<
 * 
 *     # Override the default behavior, if a key is not present
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_self), __pyx_int_neg_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":509
 *             return NotImplemented
 * 
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         return self * -1
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__neg__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":514
 *     # Override the default behavior, if a key is not present
 *     # do not initialize it to 0.
 *     def __missing__(self, str key):             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_31__missing__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_30__missing__[] = "CComposition.__missing__(self, str key)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_31__missing__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__missing__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyString_Type), 1, "key", 1))) __PYX_ERR(0, 514, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_30__missing__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), ((PyObject*)__pyx_v_key));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_30__missing__(CYTHON_UNUSED struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__missing__", 0);
  __Pyx_TraceCall("__missing__", __pyx_f[0], 514, 0, __PYX_ERR(0, 514, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":515
 *     # do not initialize it to 0.
 *     def __missing__(self, str key):
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, str key, object value):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_int_0);
  __pyx_r = __pyx_int_0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":514
 *     # Override the default behavior, if a key is not present
 *     # do not initialize it to 0.
 *     def __missing__(self, str key):             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__missing__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":517
 *         return 0
 * 
 *     def __setitem__(self, str key, object value):             # <<<<<<<<<<<<<<
 *         cdef long int_value = PyInt_AsLong(round(value))
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer
 */

/* Python wrapper */
static int __pyx_pw_9pyteomics_5cmass_12CComposition_33__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyteomics_5cmass_12CComposition_33__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyString_Type), 1, "key", 1))) __PYX_ERR(0, 517, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_32__setitem__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), ((PyObject*)__pyx_v_key), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_9pyteomics_5cmass_12CComposition_32__setitem__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  long __pyx_v_int_value;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  long __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __Pyx_TraceCall("__setitem__", __pyx_f[0], 517, 0, __PYX_ERR(0, 517, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":518
 * 
 *     def __setitem__(self, str key, object value):
 *         cdef long int_value = PyInt_AsLong(round(value))             # <<<<<<<<<<<<<<
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer
 *             self.setitem(key, int_value)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_round, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyInt_AsLong(__pyx_t_2); if (unlikely(__pyx_t_3 == -1L && PyErr_Occurred())) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_int_value = __pyx_t_3;

  /* "pyteomics/cmass.pyx":519
 *     def __setitem__(self, str key, object value):
 *         cdef long int_value = PyInt_AsLong(round(value))
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer             # <<<<<<<<<<<<<<
 *             self.setitem(key, int_value)
 *         elif key in self:
 */
  __pyx_t_4 = (__pyx_v_int_value != 0);
  if (__pyx_t_4) {

    /* "pyteomics/cmass.pyx":520
 *         cdef long int_value = PyInt_AsLong(round(value))
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer
 *             self.setitem(key, int_value)             # <<<<<<<<<<<<<<
 *         elif key in self:
 *             del self[key]
 */
    __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_self, __pyx_v_key, __pyx_v_int_value);

    /* "pyteomics/cmass.pyx":519
 *     def __setitem__(self, str key, object value):
 *         cdef long int_value = PyInt_AsLong(round(value))
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer             # <<<<<<<<<<<<<<
 *             self.setitem(key, int_value)
 *         elif key in self:
 */
    goto __pyx_L3;
  }

  /* "pyteomics/cmass.pyx":521
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer
 *             self.setitem(key, int_value)
 *         elif key in self:             # <<<<<<<<<<<<<<
 *             del self[key]
 *         self._mass_args = None
 */
  __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_key, ((PyObject *)__pyx_v_self), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 521, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pyteomics/cmass.pyx":522
 *             self.setitem(key, int_value)
 *         elif key in self:
 *             del self[key]             # <<<<<<<<<<<<<<
 *         self._mass_args = None
 * 
 */
    if (unlikely(PyObject_DelItem(((PyObject *)__pyx_v_self), __pyx_v_key) < 0)) __PYX_ERR(0, 522, __pyx_L1_error)

    /* "pyteomics/cmass.pyx":521
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer
 *             self.setitem(key, int_value)
 *         elif key in self:             # <<<<<<<<<<<<<<
 *             del self[key]
 *         self._mass_args = None
 */
  }
  __pyx_L3:;

  /* "pyteomics/cmass.pyx":523
 *         elif key in self:
 *             del self[key]
 *         self._mass_args = None             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass_args);
  __Pyx_DECREF(__pyx_v_self->_mass_args);
  __pyx_v_self->_mass_args = ((PyObject*)Py_None);

  /* "pyteomics/cmass.pyx":517
 *         return 0
 * 
 *     def __setitem__(self, str key, object value):             # <<<<<<<<<<<<<<
 *         cdef long int_value = PyInt_AsLong(round(value))
 *         if int_value:  # Will not occur on 0 as 0 is falsey AND an integer
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":525
 *         self._mass_args = None
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         return self.__class__(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_35copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_34copy[] = "CComposition.copy(self)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_35copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_34copy(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_34copy(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("copy", 0);
  __Pyx_TraceCall("copy", __pyx_f[0], 525, 0, __PYX_ERR(0, 525, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":526
 * 
 *     def copy(self):
 *         return self.__class__(self)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline long getitem(self, str elem):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 526, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __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_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":525
 *         self._mass_args = None
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         return self.__class__(self)
 * 
 */

  /* 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("pyteomics.cmass.CComposition.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":528
 *         return self.__class__(self)
 * 
 *     cdef inline long getitem(self, str elem):             # <<<<<<<<<<<<<<
 *         cdef:
 *             PyObject* resobj
 */

static long __pyx_f_9pyteomics_5cmass_12CComposition_getitem(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_elem) {
  PyObject *__pyx_v_resobj;
  long __pyx_v_count;
  long __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  long __pyx_t_2;
  __Pyx_RefNannySetupContext("getitem", 0);
  __Pyx_TraceCall("getitem", __pyx_f[0], 528, 0, __PYX_ERR(0, 528, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":532
 *             PyObject* resobj
 *             long count
 *         resobj = PyDict_GetItem(self, elem)             # <<<<<<<<<<<<<<
 *         if (resobj == NULL):
 *             return 0
 */
  __pyx_v_resobj = PyDict_GetItem(((PyObject *)__pyx_v_self), __pyx_v_elem);

  /* "pyteomics/cmass.pyx":533
 *             long count
 *         resobj = PyDict_GetItem(self, elem)
 *         if (resobj == NULL):             # <<<<<<<<<<<<<<
 *             return 0
 *         count = PyInt_AsLong(<object>resobj)
 */
  __pyx_t_1 = ((__pyx_v_resobj == NULL) != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":534
 *         resobj = PyDict_GetItem(self, elem)
 *         if (resobj == NULL):
 *             return 0             # <<<<<<<<<<<<<<
 *         count = PyInt_AsLong(<object>resobj)
 *         return count
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "pyteomics/cmass.pyx":533
 *             long count
 *         resobj = PyDict_GetItem(self, elem)
 *         if (resobj == NULL):             # <<<<<<<<<<<<<<
 *             return 0
 *         count = PyInt_AsLong(<object>resobj)
 */
  }

  /* "pyteomics/cmass.pyx":535
 *         if (resobj == NULL):
 *             return 0
 *         count = PyInt_AsLong(<object>resobj)             # <<<<<<<<<<<<<<
 *         return count
 * 
 */
  __pyx_t_2 = PyInt_AsLong(((PyObject *)__pyx_v_resobj)); if (unlikely(__pyx_t_2 == -1L && PyErr_Occurred())) __PYX_ERR(0, 535, __pyx_L1_error)
  __pyx_v_count = __pyx_t_2;

  /* "pyteomics/cmass.pyx":536
 *             return 0
 *         count = PyInt_AsLong(<object>resobj)
 *         return count             # <<<<<<<<<<<<<<
 * 
 *     cdef inline void setitem(self, str elem, long val):
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":528
 *         return self.__class__(self)
 * 
 *     cdef inline long getitem(self, str elem):             # <<<<<<<<<<<<<<
 *         cdef:
 *             PyObject* resobj
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pyteomics.cmass.CComposition.getitem", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":538
 *         return count
 * 
 *     cdef inline void setitem(self, str elem, long val):             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(self, elem, val)
 *         self._mass_args = None
 */

static void __pyx_f_9pyteomics_5cmass_12CComposition_setitem(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_elem, long __pyx_v_val) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("setitem", 0);
  __Pyx_TraceCall("setitem", __pyx_f[0], 538, 0, __PYX_ERR(0, 538, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":539
 * 
 *     cdef inline void setitem(self, str elem, long val):
 *         PyDict_SetItem(self, elem, val)             # <<<<<<<<<<<<<<
 *         self._mass_args = None
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_val); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_SetItem(((PyObject *)__pyx_v_self), __pyx_v_elem, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":540
 *     cdef inline void setitem(self, str elem, long val):
 *         PyDict_SetItem(self, elem, val)
 *         self._mass_args = None             # <<<<<<<<<<<<<<
 * 
 *     cpdef CComposition clone(self):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass_args);
  __Pyx_DECREF(__pyx_v_self->_mass_args);
  __pyx_v_self->_mass_args = ((PyObject*)Py_None);

  /* "pyteomics/cmass.pyx":538
 *         return count
 * 
 *     cdef inline void setitem(self, str elem, long val):             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(self, elem, val)
 *         self._mass_args = None
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_WriteUnraisable("pyteomics.cmass.CComposition.setitem", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "pyteomics/cmass.pyx":542
 *         self._mass_args = None
 * 
 *     cpdef CComposition clone(self):             # <<<<<<<<<<<<<<
 *         '''Create a copy of this instance
 * 
 */

static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_37clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_f_9pyteomics_5cmass_12CComposition_clone(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("clone", 0);
  __Pyx_TraceCall("clone", __pyx_f[0], 542, 0, __PYX_ERR(0, 542, __pyx_L1_error));
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clone); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_37clone)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __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, 542, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyteomics_5cmass_CComposition))))) __PYX_ERR(0, 542, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "pyteomics/cmass.pyx":549
 *         CComposition
 *         '''
 *         return CComposition(self)             # <<<<<<<<<<<<<<
 * 
 *     def update(self, *args, **kwargs):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":542
 *         self._mass_args = None
 * 
 *     cpdef CComposition clone(self):             # <<<<<<<<<<<<<<
 *         '''Create a copy of this instance
 * 
 */

  /* 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("pyteomics.cmass.CComposition.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_37clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_36clone[] = "CComposition.clone(self) -> CComposition\nCreate a copy of this instance\n\n        Returns\n        -------\n        CComposition\n        ";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_37clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clone (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_36clone(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_36clone(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("clone", 0);
  __Pyx_TraceCall("clone (wrapper)", __pyx_f[0], 542, 0, __PYX_ERR(0, 542, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyteomics_5cmass_12CComposition_clone(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __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("pyteomics.cmass.CComposition.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":551
 *         return CComposition(self)
 * 
 *     def update(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         dict.update(self, *args, **kwargs)
 *         self._mass_args = None
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_39update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_38update[] = "CComposition.update(self, *args, **kwargs)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_39update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "update", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_38update(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_38update(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("update", 0);
  __Pyx_TraceCall("update", __pyx_f[0], 551, 0, __PYX_ERR(0, 551, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":552
 * 
 *     def update(self, *args, **kwargs):
 *         dict.update(self, *args, **kwargs)             # <<<<<<<<<<<<<<
 *         self._mass_args = None
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyDict_Type)), __pyx_n_s_update); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __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;

  /* "pyteomics/cmass.pyx":553
 *     def update(self, *args, **kwargs):
 *         dict.update(self, *args, **kwargs)
 *         self._mass_args = None             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass_args);
  __Pyx_DECREF(__pyx_v_self->_mass_args);
  __pyx_v_self->_mass_args = ((PyObject*)Py_None);

  /* "pyteomics/cmass.pyx":551
 *         return CComposition(self)
 * 
 *     def update(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         dict.update(self, *args, **kwargs)
 *         self._mass_args = None
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":556
 * 
 *     @cython.boundscheck(False)
 *     cpdef _from_formula(self, str formula, dict mass_data):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem, isotope, number
 */

static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_41_from_formula(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9pyteomics_5cmass_12CComposition__from_formula(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_formula, PyObject *__pyx_v_mass_data, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_elem = 0;
  PyObject *__pyx_v_isotope = 0;
  PyObject *__pyx_v_number = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("_from_formula", 0);
  __Pyx_TraceCall("_from_formula", __pyx_f[0], 556, 0, __PYX_ERR(0, 556, __pyx_L1_error));
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_formula); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_41_from_formula)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && 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);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_formula, __pyx_v_mass_data};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_formula, __pyx_v_mass_data};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_v_formula);
        __Pyx_GIVEREF(__pyx_v_formula);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_formula);
        __Pyx_INCREF(__pyx_v_mass_data);
        __Pyx_GIVEREF(__pyx_v_mass_data);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_mass_data);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "pyteomics/cmass.pyx":559
 *         cdef:
 *             str elem, isotope, number
 *         if '(' in formula:             # <<<<<<<<<<<<<<
 *             self._from_formula_parens(formula, mass_data)
 *         elif not formula_pattern.match(formula):
 */
  __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_kp_s__17, __pyx_v_formula, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 559, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyteomics/cmass.pyx":560
 *             str elem, isotope, number
 *         if '(' in formula:
 *             self._from_formula_parens(formula, mass_data)             # <<<<<<<<<<<<<<
 *         elif not formula_pattern.match(formula):
 *             raise PyteomicsError('Invalid formula: ' + formula)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_formula_parens); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && 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);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_formula, __pyx_v_mass_data};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_formula, __pyx_v_mass_data};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_v_formula);
      __Pyx_GIVEREF(__pyx_v_formula);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_formula);
      __Pyx_INCREF(__pyx_v_mass_data);
      __Pyx_GIVEREF(__pyx_v_mass_data);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_mass_data);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyteomics/cmass.pyx":559
 *         cdef:
 *             str elem, isotope, number
 *         if '(' in formula:             # <<<<<<<<<<<<<<
 *             self._from_formula_parens(formula, mass_data)
 *         elif not formula_pattern.match(formula):
 */
    goto __pyx_L3;
  }

  /* "pyteomics/cmass.pyx":561
 *         if '(' in formula:
 *             self._from_formula_parens(formula, mass_data)
 *         elif not formula_pattern.match(formula):             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('Invalid formula: ' + formula)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_9pyteomics_5cmass_formula_pattern, __pyx_n_s_match); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_formula); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_formula};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_formula};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __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 = NULL;
      __Pyx_INCREF(__pyx_v_formula);
      __Pyx_GIVEREF(__pyx_v_formula);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_formula);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __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_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = ((!__pyx_t_8) != 0);
  if (__pyx_t_7) {

    /* "pyteomics/cmass.pyx":562
 *             self._from_formula_parens(formula, mass_data)
 *         elif not formula_pattern.match(formula):
 *             raise PyteomicsError('Invalid formula: ' + formula)             # <<<<<<<<<<<<<<
 *         else:
 *             for elem, isotope, number in re.findall(_atom, formula):
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Add(__pyx_kp_s_Invalid_formula, __pyx_v_formula); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 562, __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_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __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_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 562, __pyx_L1_error)

    /* "pyteomics/cmass.pyx":561
 *         if '(' in formula:
 *             self._from_formula_parens(formula, mass_data)
 *         elif not formula_pattern.match(formula):             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('Invalid formula: ' + formula)
 *         else:
 */
  }

  /* "pyteomics/cmass.pyx":564
 *             raise PyteomicsError('Invalid formula: ' + formula)
 *         else:
 *             for elem, isotope, number in re.findall(_atom, formula):             # <<<<<<<<<<<<<<
 *                 if not elem in mass_data:
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_findall); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && 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_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_9pyteomics_5cmass__atom, __pyx_v_formula};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_9pyteomics_5cmass__atom, __pyx_v_formula};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_9pyteomics_5cmass__atom);
      __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass__atom);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_9pyteomics_5cmass__atom);
      __Pyx_INCREF(__pyx_v_formula);
      __Pyx_GIVEREF(__pyx_v_formula);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_formula);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_9 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 564, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 564, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 564, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_10(__pyx_t_4);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 564, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if !CYTHON_COMPILING_IN_PYPY
        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, 564, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 564, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_2 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 2; __pyx_t_6 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(0, 564, __pyx_L1_error)
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 564, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 564, __pyx_L1_error)
      if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 564, __pyx_L1_error)
      if (!(likely(PyString_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_elem, ((PyObject*)__pyx_t_3));
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_isotope, ((PyObject*)__pyx_t_2));
      __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_number, ((PyObject*)__pyx_t_6));
      __pyx_t_6 = 0;

      /* "pyteomics/cmass.pyx":565
 *         else:
 *             for elem, isotope, number in re.findall(_atom, formula):
 *                 if not elem in mass_data:             # <<<<<<<<<<<<<<
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)
 *                 self[_make_isotope_string(elem, int(isotope) if isotope else 0)
 */
      if (unlikely(__pyx_v_mass_data == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 565, __pyx_L1_error)
      }
      __pyx_t_7 = (__Pyx_PyDict_ContainsTF(__pyx_v_elem, __pyx_v_mass_data, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 565, __pyx_L1_error)
      __pyx_t_8 = (__pyx_t_7 != 0);
      if (__pyx_t_8) {

        /* "pyteomics/cmass.pyx":566
 *             for elem, isotope, number in re.findall(_atom, formula):
 *                 if not elem in mass_data:
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)             # <<<<<<<<<<<<<<
 *                 self[_make_isotope_string(elem, int(isotope) if isotope else 0)
 *                         ] += int(number) if number else 1
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 566, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_2 = PyNumber_Add(__pyx_kp_s_Unknown_chemical_element, __pyx_v_elem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 566, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_3) {
          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
            __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
            __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else
          #endif
          {
            __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 566, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
            __Pyx_GIVEREF(__pyx_t_2);
            PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_2);
            __pyx_t_2 = 0;
            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
        }
        __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, 566, __pyx_L1_error)

        /* "pyteomics/cmass.pyx":565
 *         else:
 *             for elem, isotope, number in re.findall(_atom, formula):
 *                 if not elem in mass_data:             # <<<<<<<<<<<<<<
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)
 *                 self[_make_isotope_string(elem, int(isotope) if isotope else 0)
 */
      }

      /* "pyteomics/cmass.pyx":567
 *                 if not elem in mass_data:
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)
 *                 self[_make_isotope_string(elem, int(isotope) if isotope else 0)             # <<<<<<<<<<<<<<
 *                         ] += int(number) if number else 1
 * 
 */
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_isotope); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 567, __pyx_L1_error)
      if (__pyx_t_8) {
        __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_isotope); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __pyx_t_13;
      } else {
        __pyx_t_5 = 0;
      }
      __pyx_t_1 = __pyx_f_9pyteomics_5cmass__make_isotope_string(__pyx_v_elem, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 567, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 567, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);

      /* "pyteomics/cmass.pyx":568
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)
 *                 self[_make_isotope_string(elem, int(isotope) if isotope else 0)
 *                         ] += int(number) if number else 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(True)
 */
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_number); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 568, __pyx_L1_error)
      if (__pyx_t_8) {
        __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_number); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 568, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_11 = __pyx_t_2;
        __pyx_t_2 = 0;
      } else {
        __Pyx_INCREF(__pyx_int_1);
        __pyx_t_11 = __pyx_int_1;
      }

      /* "pyteomics/cmass.pyx":567
 *                 if not elem in mass_data:
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)
 *                 self[_make_isotope_string(elem, int(isotope) if isotope else 0)             # <<<<<<<<<<<<<<
 *                         ] += int(number) if number else 1
 * 
 */
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 567, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(0, 567, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyteomics/cmass.pyx":564
 *             raise PyteomicsError('Invalid formula: ' + formula)
 *         else:
 *             for elem, isotope, number in re.findall(_atom, formula):             # <<<<<<<<<<<<<<
 *                 if not elem in mass_data:
 *                     raise PyteomicsError('Unknown chemical element: ' + elem)
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "pyteomics/cmass.pyx":556
 * 
 *     @cython.boundscheck(False)
 *     cpdef _from_formula(self, str formula, dict mass_data):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str elem, isotope, number
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_formula", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF(__pyx_v_isotope);
  __Pyx_XDECREF(__pyx_v_number);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_41_from_formula(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_40_from_formula[] = "CComposition._from_formula(self, str formula, dict mass_data)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_41_from_formula(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_formula = 0;
  PyObject *__pyx_v_mass_data = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_from_formula (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_formula,&__pyx_n_s_mass_data,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_formula)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mass_data)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_from_formula", 1, 2, 2, 1); __PYX_ERR(0, 556, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_from_formula") < 0)) __PYX_ERR(0, 556, __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_formula = ((PyObject*)values[0]);
    __pyx_v_mass_data = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_from_formula", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 556, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_formula", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_formula), (&PyString_Type), 1, "formula", 1))) __PYX_ERR(0, 556, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mass_data), (&PyDict_Type), 1, "mass_data", 1))) __PYX_ERR(0, 556, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_40_from_formula(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_formula, __pyx_v_mass_data);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_40_from_formula(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_formula, PyObject *__pyx_v_mass_data) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_from_formula", 0);
  __Pyx_TraceCall("_from_formula (wrapper)", __pyx_f[0], 556, 0, __PYX_ERR(0, 556, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyteomics_5cmass_12CComposition__from_formula(__pyx_v_self, __pyx_v_formula, __pyx_v_mass_data, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 556, __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("pyteomics.cmass.CComposition._from_formula", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":571
 * 
 *     @cython.boundscheck(True)
 *     def _from_formula_parens(self, formula, mass_data):             # <<<<<<<<<<<<<<
 *         # Parsing a formula backwards.
 *         prev_chem_symbol_start = len(formula)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_43_from_formula_parens(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_42_from_formula_parens[] = "CComposition._from_formula_parens(self, formula, mass_data)";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_43_from_formula_parens(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_formula = 0;
  PyObject *__pyx_v_mass_data = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_from_formula_parens (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_formula,&__pyx_n_s_mass_data,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_formula)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mass_data)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_from_formula_parens", 1, 2, 2, 1); __PYX_ERR(0, 571, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_from_formula_parens") < 0)) __PYX_ERR(0, 571, __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_formula = values[0];
    __pyx_v_mass_data = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_from_formula_parens", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 571, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_formula_parens", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_42_from_formula_parens(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_formula, __pyx_v_mass_data);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_42_from_formula_parens(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_formula, PyObject *__pyx_v_mass_data) {
  PyObject *__pyx_v_prev_chem_symbol_start = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_seek_mode = NULL;
  PyObject *__pyx_v_parse_stack = NULL;
  PyObject *__pyx_v_resolve_stack = NULL;
  PyObject *__pyx_v_group_coef = NULL;
  PyObject *__pyx_v_num_atoms = NULL;
  PyObject *__pyx_v_brace_pos = NULL;
  PyObject *__pyx_v_isotope_num = NULL;
  int __pyx_v_element_found;
  PyObject *__pyx_v_element_name = NULL;
  PyObject *__pyx_v_isotope_string = NULL;
  PyObject *__pyx_v_ch = NULL;
  PyObject *__pyx_v_chunk = NULL;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_v_cnt = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  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)(PyObject *);
  Py_ssize_t __pyx_t_17;
  int __pyx_t_18;
  PyObject *(*__pyx_t_19)(PyObject *);
  __Pyx_RefNannySetupContext("_from_formula_parens", 0);
  __Pyx_TraceCall("_from_formula_parens", __pyx_f[0], 571, 0, __PYX_ERR(0, 571, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":573
 *     def _from_formula_parens(self, formula, mass_data):
 *         # Parsing a formula backwards.
 *         prev_chem_symbol_start = len(formula)             # <<<<<<<<<<<<<<
 *         i = len(formula) - 1
 * 
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_formula); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 573, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_prev_chem_symbol_start = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyteomics/cmass.pyx":574
 *         # Parsing a formula backwards.
 *         prev_chem_symbol_start = len(formula)
 *         i = len(formula) - 1             # <<<<<<<<<<<<<<
 * 
 *         seek_mode = 0
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_formula); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 574, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_1 - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_i = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyteomics/cmass.pyx":576
 *         i = len(formula) - 1
 * 
 *         seek_mode = 0             # <<<<<<<<<<<<<<
 *         parse_stack = ""
 *         resolve_stack = []
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_seek_mode = __pyx_int_0;

  /* "pyteomics/cmass.pyx":577
 * 
 *         seek_mode = 0
 *         parse_stack = ""             # <<<<<<<<<<<<<<
 *         resolve_stack = []
 *         group_coef = None
 */
  __Pyx_INCREF(__pyx_kp_s__15);
  __pyx_v_parse_stack = __pyx_kp_s__15;

  /* "pyteomics/cmass.pyx":578
 *         seek_mode = 0
 *         parse_stack = ""
 *         resolve_stack = []             # <<<<<<<<<<<<<<
 *         group_coef = None
 * 
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_resolve_stack = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pyteomics/cmass.pyx":579
 *         parse_stack = ""
 *         resolve_stack = []
 *         group_coef = None             # <<<<<<<<<<<<<<
 * 
 *         while i >= 0:
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_group_coef = Py_None;

  /* "pyteomics/cmass.pyx":581
 *         group_coef = None
 * 
 *         while i >= 0:             # <<<<<<<<<<<<<<
 *             if seek_mode < 1:
 *                 if (formula[i] == ")"):
 */
  while (1) {
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_i, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 581, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 581, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!__pyx_t_3) break;

    /* "pyteomics/cmass.pyx":582
 * 
 *         while i >= 0:
 *             if seek_mode < 1:             # <<<<<<<<<<<<<<
 *                 if (formula[i] == ")"):
 *                     seek_mode += 1
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_seek_mode, __pyx_int_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 582, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 582, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_3) {

      /* "pyteomics/cmass.pyx":583
 *         while i >= 0:
 *             if seek_mode < 1:
 *                 if (formula[i] == ")"):             # <<<<<<<<<<<<<<
 *                     seek_mode += 1
 *                     if i + 1 == prev_chem_symbol_start:
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_formula, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_kp_s__18, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 583, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_3) {

        /* "pyteomics/cmass.pyx":584
 *             if seek_mode < 1:
 *                 if (formula[i] == ")"):
 *                     seek_mode += 1             # <<<<<<<<<<<<<<
 *                     if i + 1 == prev_chem_symbol_start:
 *                         group_coef = 1
 */
        __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_seek_mode, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF_SET(__pyx_v_seek_mode, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "pyteomics/cmass.pyx":585
 *                 if (formula[i] == ")"):
 *                     seek_mode += 1
 *                     if i + 1 == prev_chem_symbol_start:             # <<<<<<<<<<<<<<
 *                         group_coef = 1
 *                     elif formula[i + 1].isdigit():
 */
        __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 585, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_v_prev_chem_symbol_start, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 585, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 585, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_3) {

          /* "pyteomics/cmass.pyx":586
 *                     seek_mode += 1
 *                     if i + 1 == prev_chem_symbol_start:
 *                         group_coef = 1             # <<<<<<<<<<<<<<
 *                     elif formula[i + 1].isdigit():
 *                         group_coef = int(formula[i + 1:prev_chem_symbol_start])
 */
          __Pyx_INCREF(__pyx_int_1);
          __Pyx_DECREF_SET(__pyx_v_group_coef, __pyx_int_1);

          /* "pyteomics/cmass.pyx":585
 *                 if (formula[i] == ")"):
 *                     seek_mode += 1
 *                     if i + 1 == prev_chem_symbol_start:             # <<<<<<<<<<<<<<
 *                         group_coef = 1
 *                     elif formula[i + 1].isdigit():
 */
          goto __pyx_L7;
        }

        /* "pyteomics/cmass.pyx":587
 *                     if i + 1 == prev_chem_symbol_start:
 *                         group_coef = 1
 *                     elif formula[i + 1].isdigit():             # <<<<<<<<<<<<<<
 *                         group_coef = int(formula[i + 1:prev_chem_symbol_start])
 *                     i -= 1
 */
        __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 587, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PyObject_GetItem(__pyx_v_formula, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 587, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isdigit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 587, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        if (__pyx_t_5) {
          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 587, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else {
          __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 587, __pyx_L1_error)
        }
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 587, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_3) {

          /* "pyteomics/cmass.pyx":588
 *                         group_coef = 1
 *                     elif formula[i + 1].isdigit():
 *                         group_coef = int(formula[i + 1:prev_chem_symbol_start])             # <<<<<<<<<<<<<<
 *                     i -= 1
 *                     continue
 */
          __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 588, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_formula, 0, 0, &__pyx_t_4, &__pyx_v_prev_chem_symbol_start, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 588, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF_SET(__pyx_v_group_coef, __pyx_t_4);
          __pyx_t_4 = 0;

          /* "pyteomics/cmass.pyx":587
 *                     if i + 1 == prev_chem_symbol_start:
 *                         group_coef = 1
 *                     elif formula[i + 1].isdigit():             # <<<<<<<<<<<<<<
 *                         group_coef = int(formula[i + 1:prev_chem_symbol_start])
 *                     i -= 1
 */
        }
        __pyx_L7:;

        /* "pyteomics/cmass.pyx":589
 *                     elif formula[i + 1].isdigit():
 *                         group_coef = int(formula[i + 1:prev_chem_symbol_start])
 *                     i -= 1             # <<<<<<<<<<<<<<
 *                     continue
 *                 # Read backwards until a non-number character is met.
 */
        __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_i, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 589, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "pyteomics/cmass.pyx":590
 *                         group_coef = int(formula[i + 1:prev_chem_symbol_start])
 *                     i -= 1
 *                     continue             # <<<<<<<<<<<<<<
 *                 # Read backwards until a non-number character is met.
 *                 if (formula[i].isdigit() or formula[i] == '-'):
 */
        goto __pyx_L3_continue;

        /* "pyteomics/cmass.pyx":583
 *         while i >= 0:
 *             if seek_mode < 1:
 *                 if (formula[i] == ")"):             # <<<<<<<<<<<<<<
 *                     seek_mode += 1
 *                     if i + 1 == prev_chem_symbol_start:
 */
      }

      /* "pyteomics/cmass.pyx":592
 *                     continue
 *                 # Read backwards until a non-number character is met.
 *                 if (formula[i].isdigit() or formula[i] == '-'):             # <<<<<<<<<<<<<<
 *                     i -= 1
 *                     continue
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_formula, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isdigit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_6) {
      } else {
        __pyx_t_3 = __pyx_t_6;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_4 = PyObject_GetItem(__pyx_v_formula, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_kp_s__19, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_3 = __pyx_t_6;
      __pyx_L9_bool_binop_done:;
      if (__pyx_t_3) {

        /* "pyteomics/cmass.pyx":593
 *                 # Read backwards until a non-number character is met.
 *                 if (formula[i].isdigit() or formula[i] == '-'):
 *                     i -= 1             # <<<<<<<<<<<<<<
 *                     continue
 * 
 */
        __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_i, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "pyteomics/cmass.pyx":594
 *                 if (formula[i].isdigit() or formula[i] == '-'):
 *                     i -= 1
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 else:
 */
        goto __pyx_L3_continue;

        /* "pyteomics/cmass.pyx":592
 *                     continue
 *                 # Read backwards until a non-number character is met.
 *                 if (formula[i].isdigit() or formula[i] == '-'):             # <<<<<<<<<<<<<<
 *                     i -= 1
 *                     continue
 */
      }

      /* "pyteomics/cmass.pyx":598
 *                 else:
 *                     # If the number of atoms is omitted then it is 1.
 *                     if i + 1 == prev_chem_symbol_start:             # <<<<<<<<<<<<<<
 *                         num_atoms = 1
 *                     else:
 */
      /*else*/ {
        __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 598, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_v_prev_chem_symbol_start, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 598, __pyx_L1_error)
        __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, 598, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_3) {

          /* "pyteomics/cmass.pyx":599
 *                     # If the number of atoms is omitted then it is 1.
 *                     if i + 1 == prev_chem_symbol_start:
 *                         num_atoms = 1             # <<<<<<<<<<<<<<
 *                     else:
 *                         try:
 */
          __Pyx_INCREF(__pyx_int_1);
          __Pyx_XDECREF_SET(__pyx_v_num_atoms, __pyx_int_1);

          /* "pyteomics/cmass.pyx":598
 *                 else:
 *                     # If the number of atoms is omitted then it is 1.
 *                     if i + 1 == prev_chem_symbol_start:             # <<<<<<<<<<<<<<
 *                         num_atoms = 1
 *                     else:
 */
          goto __pyx_L11;
        }

        /* "pyteomics/cmass.pyx":601
 *                         num_atoms = 1
 *                     else:
 *                         try:             # <<<<<<<<<<<<<<
 *                             num_atoms = int(formula[i + 1:prev_chem_symbol_start])
 *                         except ValueError:
 */
        /*else*/ {
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
            __Pyx_XGOTREF(__pyx_t_7);
            __Pyx_XGOTREF(__pyx_t_8);
            __Pyx_XGOTREF(__pyx_t_9);
            /*try:*/ {

              /* "pyteomics/cmass.pyx":602
 *                     else:
 *                         try:
 *                             num_atoms = int(formula[i + 1:prev_chem_symbol_start])             # <<<<<<<<<<<<<<
 *                         except ValueError:
 *                             raise PyteomicsError(
 */
              __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 602, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_formula, 0, 0, &__pyx_t_5, &__pyx_v_prev_chem_symbol_start, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 602, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_5 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 602, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF_SET(__pyx_v_num_atoms, __pyx_t_5);
              __pyx_t_5 = 0;

              /* "pyteomics/cmass.pyx":601
 *                         num_atoms = 1
 *                     else:
 *                         try:             # <<<<<<<<<<<<<<
 *                             num_atoms = int(formula[i + 1:prev_chem_symbol_start])
 *                         except ValueError:
 */
            }
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            goto __pyx_L19_try_end;
            __pyx_L12_error:;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "pyteomics/cmass.pyx":603
 *                         try:
 *                             num_atoms = int(formula[i + 1:prev_chem_symbol_start])
 *                         except ValueError:             # <<<<<<<<<<<<<<
 *                             raise PyteomicsError(
 *                                 'Badly-formed number of atoms: %s' % formula)
 */
            __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
            if (__pyx_t_10) {
              __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_formula_parens", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_2) < 0) __PYX_ERR(0, 603, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_GOTREF(__pyx_t_2);

              /* "pyteomics/cmass.pyx":604
 *                             num_atoms = int(formula[i + 1:prev_chem_symbol_start])
 *                         except ValueError:
 *                             raise PyteomicsError(             # <<<<<<<<<<<<<<
 *                                 'Badly-formed number of atoms: %s' % formula)
 * 
 */
              __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 604, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_12);

              /* "pyteomics/cmass.pyx":605
 *                         except ValueError:
 *                             raise PyteomicsError(
 *                                 'Badly-formed number of atoms: %s' % formula)             # <<<<<<<<<<<<<<
 * 
 *                     # Read isotope number if specified, else it is undefined (=0).
 */
              __pyx_t_13 = __Pyx_PyString_Format(__pyx_kp_s_Badly_formed_number_of_atoms_s, __pyx_v_formula); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 605, __pyx_L14_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_14 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
                if (likely(__pyx_t_14)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
                  __Pyx_INCREF(__pyx_t_14);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_12, function);
                }
              }
              if (!__pyx_t_14) {
                __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 604, __pyx_L14_except_error)
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_GOTREF(__pyx_t_11);
              } else {
                #if CYTHON_FAST_PYCALL
                if (PyFunction_Check(__pyx_t_12)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13};
                  __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 604, __pyx_L14_except_error)
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                } else
                #endif
                #if CYTHON_FAST_PYCCALL
                if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13};
                  __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 604, __pyx_L14_except_error)
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                } else
                #endif
                {
                  __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 604, __pyx_L14_except_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
                  __Pyx_GIVEREF(__pyx_t_13);
                  PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_13);
                  __pyx_t_13 = 0;
                  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 604, __pyx_L14_except_error)
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                }
              }
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_Raise(__pyx_t_11, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __PYX_ERR(0, 604, __pyx_L14_except_error)
            }
            goto __pyx_L14_except_error;
            __pyx_L14_except_error:;

            /* "pyteomics/cmass.pyx":601
 *                         num_atoms = 1
 *                     else:
 *                         try:             # <<<<<<<<<<<<<<
 *                             num_atoms = int(formula[i + 1:prev_chem_symbol_start])
 *                         except ValueError:
 */
            __Pyx_XGIVEREF(__pyx_t_7);
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            goto __pyx_L1_error;
            __pyx_L19_try_end:;
          }
        }
        __pyx_L11:;

        /* "pyteomics/cmass.pyx":608
 * 
 *                     # Read isotope number if specified, else it is undefined (=0).
 *                     if formula[i] == ']':             # <<<<<<<<<<<<<<
 *                         brace_pos = formula.rfind('[', 0, i)
 *                         if brace_pos == -1:
 */
        __pyx_t_2 = PyObject_GetItem(__pyx_v_formula, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 608, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_kp_s__13, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_3) {

          /* "pyteomics/cmass.pyx":609
 *                     # Read isotope number if specified, else it is undefined (=0).
 *                     if formula[i] == ']':
 *                         brace_pos = formula.rfind('[', 0, i)             # <<<<<<<<<<<<<<
 *                         if brace_pos == -1:
 *                             raise PyteomicsError(
 */
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_formula, __pyx_n_s_rfind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = NULL;
          __pyx_t_10 = 0;
          if (CYTHON_UNPACK_METHODS && 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);
              __pyx_t_10 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s__14, __pyx_int_0, __pyx_v_i};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_2);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s__14, __pyx_int_0, __pyx_v_i};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_2);
          } else
          #endif
          {
            __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 609, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_11);
            if (__pyx_t_5) {
              __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL;
            }
            __Pyx_INCREF(__pyx_kp_s__14);
            __Pyx_GIVEREF(__pyx_kp_s__14);
            PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_kp_s__14);
            __Pyx_INCREF(__pyx_int_0);
            __Pyx_GIVEREF(__pyx_int_0);
            PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_int_0);
            __Pyx_INCREF(__pyx_v_i);
            __Pyx_GIVEREF(__pyx_v_i);
            PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_v_i);
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF_SET(__pyx_v_brace_pos, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "pyteomics/cmass.pyx":610
 *                     if formula[i] == ']':
 *                         brace_pos = formula.rfind('[', 0, i)
 *                         if brace_pos == -1:             # <<<<<<<<<<<<<<
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)
 */
          __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_v_brace_pos, __pyx_int_neg_1, -1L, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 610, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 610, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_3) {

            /* "pyteomics/cmass.pyx":611
 *                         brace_pos = formula.rfind('[', 0, i)
 *                         if brace_pos == -1:
 *                             raise PyteomicsError(             # <<<<<<<<<<<<<<
 *                                 'Badly-formed isotope number: %s' % formula)
 *                         try:
 */
            __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);

            /* "pyteomics/cmass.pyx":612
 *                         if brace_pos == -1:
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)             # <<<<<<<<<<<<<<
 *                         try:
 *                             isotope_num = int(formula[brace_pos + 1:i])
 */
            __pyx_t_11 = __Pyx_PyString_Format(__pyx_kp_s_Badly_formed_isotope_number_s, __pyx_v_formula); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 612, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_5 = NULL;
            if (CYTHON_UNPACK_METHODS && 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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_GOTREF(__pyx_t_2);
            } else {
              #if CYTHON_FAST_PYCALL
              if (PyFunction_Check(__pyx_t_4)) {
                PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_11};
                __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              } else
              #endif
              #if CYTHON_FAST_PYCCALL
              if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
                PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_11};
                __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              } else
              #endif
              {
                __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 611, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_12);
                __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL;
                __Pyx_GIVEREF(__pyx_t_11);
                PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
                __pyx_t_11 = 0;
                __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              }
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 611, __pyx_L1_error)

            /* "pyteomics/cmass.pyx":610
 *                     if formula[i] == ']':
 *                         brace_pos = formula.rfind('[', 0, i)
 *                         if brace_pos == -1:             # <<<<<<<<<<<<<<
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)
 */
          }

          /* "pyteomics/cmass.pyx":613
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)
 *                         try:             # <<<<<<<<<<<<<<
 *                             isotope_num = int(formula[brace_pos + 1:i])
 *                         except ValueError:
 */
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
            __Pyx_XGOTREF(__pyx_t_9);
            __Pyx_XGOTREF(__pyx_t_8);
            __Pyx_XGOTREF(__pyx_t_7);
            /*try:*/ {

              /* "pyteomics/cmass.pyx":614
 *                                 'Badly-formed isotope number: %s' % formula)
 *                         try:
 *                             isotope_num = int(formula[brace_pos + 1:i])             # <<<<<<<<<<<<<<
 *                         except ValueError:
 *                             raise PyteomicsError(
 */
              __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_brace_pos, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 614, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_formula, 0, 0, &__pyx_t_2, &__pyx_v_i, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 614, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 614, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF_SET(__pyx_v_isotope_num, __pyx_t_2);
              __pyx_t_2 = 0;

              /* "pyteomics/cmass.pyx":613
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)
 *                         try:             # <<<<<<<<<<<<<<
 *                             isotope_num = int(formula[brace_pos + 1:i])
 *                         except ValueError:
 */
            }
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            goto __pyx_L31_try_end;
            __pyx_L24_error:;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "pyteomics/cmass.pyx":615
 *                         try:
 *                             isotope_num = int(formula[brace_pos + 1:i])
 *                         except ValueError:             # <<<<<<<<<<<<<<
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)
 */
            __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
            if (__pyx_t_10) {
              __Pyx_AddTraceback("pyteomics.cmass.CComposition._from_formula_parens", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_4, &__pyx_t_12) < 0) __PYX_ERR(0, 615, __pyx_L26_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_GOTREF(__pyx_t_12);

              /* "pyteomics/cmass.pyx":616
 *                             isotope_num = int(formula[brace_pos + 1:i])
 *                         except ValueError:
 *                             raise PyteomicsError(             # <<<<<<<<<<<<<<
 *                                 'Badly-formed isotope number: %s' % formula)
 *                         i = brace_pos - 1
 */
              __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 616, __pyx_L26_except_error)
              __Pyx_GOTREF(__pyx_t_5);

              /* "pyteomics/cmass.pyx":617
 *                         except ValueError:
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)             # <<<<<<<<<<<<<<
 *                         i = brace_pos - 1
 *                     else:
 */
              __pyx_t_15 = __Pyx_PyString_Format(__pyx_kp_s_Badly_formed_isotope_number_s, __pyx_v_formula); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 617, __pyx_L26_except_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_13 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
                if (likely(__pyx_t_13)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_13);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_5, function);
                }
              }
              if (!__pyx_t_13) {
                __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 616, __pyx_L26_except_error)
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_GOTREF(__pyx_t_11);
              } else {
                #if CYTHON_FAST_PYCALL
                if (PyFunction_Check(__pyx_t_5)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_15};
                  __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 616, __pyx_L26_except_error)
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                } else
                #endif
                #if CYTHON_FAST_PYCCALL
                if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_15};
                  __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 616, __pyx_L26_except_error)
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                } else
                #endif
                {
                  __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 616, __pyx_L26_except_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
                  __Pyx_GIVEREF(__pyx_t_15);
                  PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_15);
                  __pyx_t_15 = 0;
                  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 616, __pyx_L26_except_error)
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                }
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_Raise(__pyx_t_11, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __PYX_ERR(0, 616, __pyx_L26_except_error)
            }
            goto __pyx_L26_except_error;
            __pyx_L26_except_error:;

            /* "pyteomics/cmass.pyx":613
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)
 *                         try:             # <<<<<<<<<<<<<<
 *                             isotope_num = int(formula[brace_pos + 1:i])
 *                         except ValueError:
 */
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_XGIVEREF(__pyx_t_7);
            __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7);
            goto __pyx_L1_error;
            __pyx_L31_try_end:;
          }

          /* "pyteomics/cmass.pyx":618
 *                             raise PyteomicsError(
 *                                 'Badly-formed isotope number: %s' % formula)
 *                         i = brace_pos - 1             # <<<<<<<<<<<<<<
 *                     else:
 *                         isotope_num = 0
 */
          __pyx_t_12 = __Pyx_PyInt_SubtractObjC(__pyx_v_brace_pos, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 618, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_12);
          __pyx_t_12 = 0;

          /* "pyteomics/cmass.pyx":608
 * 
 *                     # Read isotope number if specified, else it is undefined (=0).
 *                     if formula[i] == ']':             # <<<<<<<<<<<<<<
 *                         brace_pos = formula.rfind('[', 0, i)
 *                         if brace_pos == -1:
 */
          goto __pyx_L22;
        }

        /* "pyteomics/cmass.pyx":620
 *                         i = brace_pos - 1
 *                     else:
 *                         isotope_num = 0             # <<<<<<<<<<<<<<
 * 
 *                     # Match the element name to the mass_data.
 */
        /*else*/ {
          __Pyx_INCREF(__pyx_int_0);
          __Pyx_XDECREF_SET(__pyx_v_isotope_num, __pyx_int_0);
        }
        __pyx_L22:;

        /* "pyteomics/cmass.pyx":623
 * 
 *                     # Match the element name to the mass_data.
 *                     element_found = False             # <<<<<<<<<<<<<<
 *                     # Sort the keys from longest to shortest to workaround
 *                     # the overlapping keys issue
 */
        __pyx_v_element_found = 0;

        /* "pyteomics/cmass.pyx":626
 *                     # Sort the keys from longest to shortest to workaround
 *                     # the overlapping keys issue
 *                     for element_name in sorted(mass_data, key=len, reverse=True):             # <<<<<<<<<<<<<<
 *                         if formula.endswith(element_name, 0, i + 1):
 *                             isotope_string = _make_isotope_string(
 */
        __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 626, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_v_mass_data);
        __Pyx_GIVEREF(__pyx_v_mass_data);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_mass_data);
        __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = __Pyx_GetBuiltinName(__pyx_n_s_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_key, __pyx_t_2) < 0) __PYX_ERR(0, 626, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_reverse, Py_True) < 0) __PYX_ERR(0, 626, __pyx_L1_error)
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_12, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
          __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = 0;
          __pyx_t_16 = NULL;
        } else {
          __pyx_t_1 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_16 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 626, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        for (;;) {
          if (likely(!__pyx_t_16)) {
            if (likely(PyList_CheckExact(__pyx_t_4))) {
              if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 626, __pyx_L1_error)
              #else
              __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              #endif
            } else {
              if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 626, __pyx_L1_error)
              #else
              __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              #endif
            }
          } else {
            __pyx_t_2 = __pyx_t_16(__pyx_t_4);
            if (unlikely(!__pyx_t_2)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 626, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_XDECREF_SET(__pyx_v_element_name, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "pyteomics/cmass.pyx":627
 *                     # the overlapping keys issue
 *                     for element_name in sorted(mass_data, key=len, reverse=True):
 *                         if formula.endswith(element_name, 0, i + 1):             # <<<<<<<<<<<<<<
 *                             isotope_string = _make_isotope_string(
 *                                 element_name, isotope_num)
 */
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_formula, __pyx_n_s_endswith); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 627, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_11 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 627, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_5 = NULL;
          __pyx_t_10 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_12);
            if (likely(__pyx_t_5)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_12, function);
              __pyx_t_10 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_12)) {
            PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_element_name, __pyx_int_0, __pyx_t_11};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 627, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
            PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_element_name, __pyx_int_0, __pyx_t_11};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 627, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 627, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            if (__pyx_t_5) {
              __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5); __pyx_t_5 = NULL;
            }
            __Pyx_INCREF(__pyx_v_element_name);
            __Pyx_GIVEREF(__pyx_v_element_name);
            PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_10, __pyx_v_element_name);
            __Pyx_INCREF(__pyx_int_0);
            __Pyx_GIVEREF(__pyx_int_0);
            PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_10, __pyx_int_0);
            __Pyx_GIVEREF(__pyx_t_11);
            PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_10, __pyx_t_11);
            __pyx_t_11 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 627, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 627, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_3) {

            /* "pyteomics/cmass.pyx":629
 *                         if formula.endswith(element_name, 0, i + 1):
 *                             isotope_string = _make_isotope_string(
 *                                 element_name, isotope_num)             # <<<<<<<<<<<<<<
 *                             self[isotope_string] += num_atoms
 *                             i -= len(element_name)
 */
            if (!(likely(PyString_CheckExact(__pyx_v_element_name))||((__pyx_v_element_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_element_name)->tp_name), 0))) __PYX_ERR(0, 629, __pyx_L1_error)
            __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_isotope_num); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 629, __pyx_L1_error)

            /* "pyteomics/cmass.pyx":628
 *                     for element_name in sorted(mass_data, key=len, reverse=True):
 *                         if formula.endswith(element_name, 0, i + 1):
 *                             isotope_string = _make_isotope_string(             # <<<<<<<<<<<<<<
 *                                 element_name, isotope_num)
 *                             self[isotope_string] += num_atoms
 */
            __pyx_t_2 = __pyx_f_9pyteomics_5cmass__make_isotope_string(((PyObject*)__pyx_v_element_name), __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 628, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_XDECREF_SET(__pyx_v_isotope_string, __pyx_t_2);
            __pyx_t_2 = 0;

            /* "pyteomics/cmass.pyx":630
 *                             isotope_string = _make_isotope_string(
 *                                 element_name, isotope_num)
 *                             self[isotope_string] += num_atoms             # <<<<<<<<<<<<<<
 *                             i -= len(element_name)
 *                             prev_chem_symbol_start = i + 1
 */
            __Pyx_INCREF(__pyx_v_isotope_string);
            __pyx_t_2 = __pyx_v_isotope_string;
            __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 630, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_14 = PyNumber_InPlaceAdd(__pyx_t_12, __pyx_v_num_atoms); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 630, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_t_2, __pyx_t_14) < 0)) __PYX_ERR(0, 630, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "pyteomics/cmass.pyx":631
 *                                 element_name, isotope_num)
 *                             self[isotope_string] += num_atoms
 *                             i -= len(element_name)             # <<<<<<<<<<<<<<
 *                             prev_chem_symbol_start = i + 1
 *                             element_found = True
 */
            __pyx_t_17 = PyObject_Length(__pyx_v_element_name); if (unlikely(__pyx_t_17 == -1)) __PYX_ERR(0, 631, __pyx_L1_error)
            __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_14 = PyNumber_InPlaceSubtract(__pyx_v_i, __pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 631, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_14);
            __pyx_t_14 = 0;

            /* "pyteomics/cmass.pyx":632
 *                             self[isotope_string] += num_atoms
 *                             i -= len(element_name)
 *                             prev_chem_symbol_start = i + 1             # <<<<<<<<<<<<<<
 *                             element_found = True
 *                             break
 */
            __pyx_t_14 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 632, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF_SET(__pyx_v_prev_chem_symbol_start, __pyx_t_14);
            __pyx_t_14 = 0;

            /* "pyteomics/cmass.pyx":633
 *                             i -= len(element_name)
 *                             prev_chem_symbol_start = i + 1
 *                             element_found = True             # <<<<<<<<<<<<<<
 *                             break
 * 
 */
            __pyx_v_element_found = 1;

            /* "pyteomics/cmass.pyx":634
 *                             prev_chem_symbol_start = i + 1
 *                             element_found = True
 *                             break             # <<<<<<<<<<<<<<
 * 
 *                     if not element_found:
 */
            goto __pyx_L35_break;

            /* "pyteomics/cmass.pyx":627
 *                     # the overlapping keys issue
 *                     for element_name in sorted(mass_data, key=len, reverse=True):
 *                         if formula.endswith(element_name, 0, i + 1):             # <<<<<<<<<<<<<<
 *                             isotope_string = _make_isotope_string(
 *                                 element_name, isotope_num)
 */
          }

          /* "pyteomics/cmass.pyx":626
 *                     # Sort the keys from longest to shortest to workaround
 *                     # the overlapping keys issue
 *                     for element_name in sorted(mass_data, key=len, reverse=True):             # <<<<<<<<<<<<<<
 *                         if formula.endswith(element_name, 0, i + 1):
 *                             isotope_string = _make_isotope_string(
 */
        }
        __pyx_L35_break:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pyteomics/cmass.pyx":636
 *                             break
 * 
 *                     if not element_found:             # <<<<<<<<<<<<<<
 *                         raise PyteomicsError(
 *                             'Unknown chemical element in the formula: %s' % formula)
 */
        __pyx_t_3 = ((!(__pyx_v_element_found != 0)) != 0);
        if (__pyx_t_3) {

          /* "pyteomics/cmass.pyx":637
 * 
 *                     if not element_found:
 *                         raise PyteomicsError(             # <<<<<<<<<<<<<<
 *                             'Unknown chemical element in the formula: %s' % formula)
 *             else:
 */
          __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 637, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);

          /* "pyteomics/cmass.pyx":638
 *                     if not element_found:
 *                         raise PyteomicsError(
 *                             'Unknown chemical element in the formula: %s' % formula)             # <<<<<<<<<<<<<<
 *             else:
 *                 ch = formula[i]
 */
          __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_chemical_element_in_the, __pyx_v_formula); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_14);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_14, function);
            }
          }
          if (!__pyx_t_12) {
            __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_GOTREF(__pyx_t_4);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_14)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_2};
              __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
              PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_2};
              __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            } else
            #endif
            {
              __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 637, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL;
              __Pyx_GIVEREF(__pyx_t_2);
              PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_2);
              __pyx_t_2 = 0;
              __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_Raise(__pyx_t_4, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __PYX_ERR(0, 637, __pyx_L1_error)

          /* "pyteomics/cmass.pyx":636
 *                             break
 * 
 *                     if not element_found:             # <<<<<<<<<<<<<<
 *                         raise PyteomicsError(
 *                             'Unknown chemical element in the formula: %s' % formula)
 */
        }
      }

      /* "pyteomics/cmass.pyx":582
 * 
 *         while i >= 0:
 *             if seek_mode < 1:             # <<<<<<<<<<<<<<
 *                 if (formula[i] == ")"):
 *                     seek_mode += 1
 */
      goto __pyx_L5;
    }

    /* "pyteomics/cmass.pyx":640
 *                             'Unknown chemical element in the formula: %s' % formula)
 *             else:
 *                 ch = formula[i]             # <<<<<<<<<<<<<<
 *                 parse_stack += ch
 *                 i -= 1
 */
    /*else*/ {
      __pyx_t_4 = PyObject_GetItem(__pyx_v_formula, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 640, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_ch, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "pyteomics/cmass.pyx":641
 *             else:
 *                 ch = formula[i]
 *                 parse_stack += ch             # <<<<<<<<<<<<<<
 *                 i -= 1
 *                 if(ch == "("):
 */
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_parse_stack, __pyx_v_ch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_parse_stack, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "pyteomics/cmass.pyx":642
 *                 ch = formula[i]
 *                 parse_stack += ch
 *                 i -= 1             # <<<<<<<<<<<<<<
 *                 if(ch == "("):
 *                     seek_mode -= 1
 */
      __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_i, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 642, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "pyteomics/cmass.pyx":643
 *                 parse_stack += ch
 *                 i -= 1
 *                 if(ch == "("):             # <<<<<<<<<<<<<<
 *                     seek_mode -= 1
 *                     if seek_mode == 0:
 */
      __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_v_ch, __pyx_kp_s__17, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 643, __pyx_L1_error)
      if (__pyx_t_3) {

        /* "pyteomics/cmass.pyx":644
 *                 i -= 1
 *                 if(ch == "("):
 *                     seek_mode -= 1             # <<<<<<<<<<<<<<
 *                     if seek_mode == 0:
 * 
 */
        __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_seek_mode, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 644, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v_seek_mode, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "pyteomics/cmass.pyx":645
 *                 if(ch == "("):
 *                     seek_mode -= 1
 *                     if seek_mode == 0:             # <<<<<<<<<<<<<<
 * 
 *                         resolve_stack.append(Composition(
 */
        __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_seek_mode, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 645, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 645, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_3) {

          /* "pyteomics/cmass.pyx":647
 *                     if seek_mode == 0:
 * 
 *                         resolve_stack.append(Composition(             # <<<<<<<<<<<<<<
 *                                              # Omit the last character, then reverse the parse
 *                                              # stack string.
 */
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Composition_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 647, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);

          /* "pyteomics/cmass.pyx":650
 *                                              # Omit the last character, then reverse the parse
 *                                              # stack string.
 *                                              formula=parse_stack[:-1][::-1],             # <<<<<<<<<<<<<<
 *                                              mass_data=mass_data)
 *                                              * group_coef)
 */
          __pyx_t_14 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 650, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_11 = __Pyx_PyObject_GetSlice(__pyx_v_parse_stack, 0, -1L, NULL, NULL, &__pyx_slice__20, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 650, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_2 = PyObject_GetItem(__pyx_t_11, __pyx_slice__21); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 650, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_formula, __pyx_t_2) < 0) __PYX_ERR(0, 650, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "pyteomics/cmass.pyx":651
 *                                              # stack string.
 *                                              formula=parse_stack[:-1][::-1],
 *                                              mass_data=mass_data)             # <<<<<<<<<<<<<<
 *                                              * group_coef)
 *                         prev_chem_symbol_start = i + 1
 */
          if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_mass_data, __pyx_v_mass_data) < 0) __PYX_ERR(0, 650, __pyx_L1_error)

          /* "pyteomics/cmass.pyx":647
 *                     if seek_mode == 0:
 * 
 *                         resolve_stack.append(Composition(             # <<<<<<<<<<<<<<
 *                                              # Omit the last character, then reverse the parse
 *                                              # stack string.
 */
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 647, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

          /* "pyteomics/cmass.pyx":652
 *                                              formula=parse_stack[:-1][::-1],
 *                                              mass_data=mass_data)
 *                                              * group_coef)             # <<<<<<<<<<<<<<
 *                         prev_chem_symbol_start = i + 1
 *                         seek_mode = False
 */
          __pyx_t_14 = PyNumber_Multiply(__pyx_t_2, __pyx_v_group_coef); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 652, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "pyteomics/cmass.pyx":647
 *                     if seek_mode == 0:
 * 
 *                         resolve_stack.append(Composition(             # <<<<<<<<<<<<<<
 *                                              # Omit the last character, then reverse the parse
 *                                              # stack string.
 */
          __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_resolve_stack, __pyx_t_14); if (unlikely(__pyx_t_18 == -1)) __PYX_ERR(0, 647, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

          /* "pyteomics/cmass.pyx":653
 *                                              mass_data=mass_data)
 *                                              * group_coef)
 *                         prev_chem_symbol_start = i + 1             # <<<<<<<<<<<<<<
 *                         seek_mode = False
 *                         parse_stack = ""
 */
          __pyx_t_14 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 653, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF_SET(__pyx_v_prev_chem_symbol_start, __pyx_t_14);
          __pyx_t_14 = 0;

          /* "pyteomics/cmass.pyx":654
 *                                              * group_coef)
 *                         prev_chem_symbol_start = i + 1
 *                         seek_mode = False             # <<<<<<<<<<<<<<
 *                         parse_stack = ""
 *                 elif(formula[i] == ")"):
 */
          __Pyx_INCREF(Py_False);
          __Pyx_DECREF_SET(__pyx_v_seek_mode, Py_False);

          /* "pyteomics/cmass.pyx":655
 *                         prev_chem_symbol_start = i + 1
 *                         seek_mode = False
 *                         parse_stack = ""             # <<<<<<<<<<<<<<
 *                 elif(formula[i] == ")"):
 *                     seek_mode += 1
 */
          __Pyx_INCREF(__pyx_kp_s__15);
          __Pyx_DECREF_SET(__pyx_v_parse_stack, __pyx_kp_s__15);

          /* "pyteomics/cmass.pyx":645
 *                 if(ch == "("):
 *                     seek_mode -= 1
 *                     if seek_mode == 0:             # <<<<<<<<<<<<<<
 * 
 *                         resolve_stack.append(Composition(
 */
        }

        /* "pyteomics/cmass.pyx":643
 *                 parse_stack += ch
 *                 i -= 1
 *                 if(ch == "("):             # <<<<<<<<<<<<<<
 *                     seek_mode -= 1
 *                     if seek_mode == 0:
 */
        goto __pyx_L38;
      }

      /* "pyteomics/cmass.pyx":656
 *                         seek_mode = False
 *                         parse_stack = ""
 *                 elif(formula[i] == ")"):             # <<<<<<<<<<<<<<
 *                     seek_mode += 1
 *                 else:
 */
      __pyx_t_14 = PyObject_GetItem(__pyx_v_formula, __pyx_v_i); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 656, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_14, __pyx_kp_s__18, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 656, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (__pyx_t_3) {

        /* "pyteomics/cmass.pyx":657
 *                         parse_stack = ""
 *                 elif(formula[i] == ")"):
 *                     seek_mode += 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     # continue to accumulate tokens
 */
        __pyx_t_14 = __Pyx_PyInt_AddObjC(__pyx_v_seek_mode, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 657, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF_SET(__pyx_v_seek_mode, __pyx_t_14);
        __pyx_t_14 = 0;

        /* "pyteomics/cmass.pyx":656
 *                         seek_mode = False
 *                         parse_stack = ""
 *                 elif(formula[i] == ")"):             # <<<<<<<<<<<<<<
 *                     seek_mode += 1
 *                 else:
 */
        goto __pyx_L38;
      }

      /* "pyteomics/cmass.pyx":660
 *                 else:
 *                     # continue to accumulate tokens
 *                     pass             # <<<<<<<<<<<<<<
 * 
 *         # Unspool the resolve stack, adding together the chunks
 */
      /*else*/ {
      }
      __pyx_L38:;
    }
    __pyx_L5:;
    __pyx_L3_continue:;
  }

  /* "pyteomics/cmass.pyx":665
 *         # at this level. __add__ operates immutably, so must manually
 *         # loop through each chunk.
 *         for chunk in resolve_stack:             # <<<<<<<<<<<<<<
 *             for elem, cnt in chunk.items():
 *                 self[elem] += cnt
 */
  __pyx_t_14 = __pyx_v_resolve_stack; __Pyx_INCREF(__pyx_t_14); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_14)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 665, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_14, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_chunk, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":666
 *         # loop through each chunk.
 *         for chunk in resolve_stack:
 *             for elem, cnt in chunk.items():             # <<<<<<<<<<<<<<
 *                 self[elem] += cnt
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_chunk, __pyx_n_s_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_11) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 666, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 666, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_17 = 0;
      __pyx_t_16 = NULL;
    } else {
      __pyx_t_17 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_16 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 666, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_16)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_17); __Pyx_INCREF(__pyx_t_2); __pyx_t_17++; if (unlikely(0 < 0)) __PYX_ERR(0, 666, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 666, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_17); __Pyx_INCREF(__pyx_t_2); __pyx_t_17++; if (unlikely(0 < 0)) __PYX_ERR(0, 666, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 666, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_16(__pyx_t_4);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 666, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if !CYTHON_COMPILING_IN_PYPY
        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, 666, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 666, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 666, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 666, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_19 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_19(__pyx_t_5); if (unlikely(!__pyx_t_11)) goto __pyx_L44_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_12 = __pyx_t_19(__pyx_t_5); if (unlikely(!__pyx_t_12)) goto __pyx_L44_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_19(__pyx_t_5), 2) < 0) __PYX_ERR(0, 666, __pyx_L1_error)
        __pyx_t_19 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L45_unpacking_done;
        __pyx_L44_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_19 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 666, __pyx_L1_error)
        __pyx_L45_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_v_cnt, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "pyteomics/cmass.pyx":667
 *         for chunk in resolve_stack:
 *             for elem, cnt in chunk.items():
 *                 self[elem] += cnt             # <<<<<<<<<<<<<<
 * 
 *     cpdef _from_dict(self, comp):
 */
      __Pyx_INCREF(__pyx_v_elem);
      __pyx_t_2 = __pyx_v_elem;
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 667, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_t_12, __pyx_v_cnt); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 667, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_t_2, __pyx_t_11) < 0)) __PYX_ERR(0, 667, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyteomics/cmass.pyx":666
 *         # loop through each chunk.
 *         for chunk in resolve_stack:
 *             for elem, cnt in chunk.items():             # <<<<<<<<<<<<<<
 *                 self[elem] += cnt
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pyteomics/cmass.pyx":665
 *         # at this level. __add__ operates immutably, so must manually
 *         # loop through each chunk.
 *         for chunk in resolve_stack:             # <<<<<<<<<<<<<<
 *             for elem, cnt in chunk.items():
 *                 self[elem] += cnt
 */
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "pyteomics/cmass.pyx":571
 * 
 *     @cython.boundscheck(True)
 *     def _from_formula_parens(self, formula, mass_data):             # <<<<<<<<<<<<<<
 *         # Parsing a formula backwards.
 *         prev_chem_symbol_start = len(formula)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __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_AddTraceback("pyteomics.cmass.CComposition._from_formula_parens", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_prev_chem_symbol_start);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_seek_mode);
  __Pyx_XDECREF(__pyx_v_parse_stack);
  __Pyx_XDECREF(__pyx_v_resolve_stack);
  __Pyx_XDECREF(__pyx_v_group_coef);
  __Pyx_XDECREF(__pyx_v_num_atoms);
  __Pyx_XDECREF(__pyx_v_brace_pos);
  __Pyx_XDECREF(__pyx_v_isotope_num);
  __Pyx_XDECREF(__pyx_v_element_name);
  __Pyx_XDECREF(__pyx_v_isotope_string);
  __Pyx_XDECREF(__pyx_v_ch);
  __Pyx_XDECREF(__pyx_v_chunk);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF(__pyx_v_cnt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":669
 *                 self[elem] += cnt
 * 
 *     cpdef _from_dict(self, comp):             # <<<<<<<<<<<<<<
 *         '''
 *         Directly overwrite this object's keys with the values in
 */

static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_45_from_dict(PyObject *__pyx_v_self, PyObject *__pyx_v_comp); /*proto*/
static PyObject *__pyx_f_9pyteomics_5cmass_12CComposition__from_dict(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_comp, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_from_dict", 0);
  __Pyx_TraceCall("_from_dict", __pyx_f[0], 669, 0, __PYX_ERR(0, 669, __pyx_L1_error));
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_45_from_dict)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_comp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_comp};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_comp};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 669, __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_comp);
          __Pyx_GIVEREF(__pyx_v_comp);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_comp);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "pyteomics/cmass.pyx":674
 *         `comp` without checking their type.
 *         '''
 *         PyDict_Update(self, comp)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = PyDict_Update(((PyObject *)__pyx_v_self), __pyx_v_comp); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 674, __pyx_L1_error)

  /* "pyteomics/cmass.pyx":669
 *                 self[elem] += cnt
 * 
 *     cpdef _from_dict(self, comp):             # <<<<<<<<<<<<<<
 *         '''
 *         Directly overwrite this object's keys with the values in
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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_AddTraceback("pyteomics.cmass.CComposition._from_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_45_from_dict(PyObject *__pyx_v_self, PyObject *__pyx_v_comp); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_44_from_dict[] = "CComposition._from_dict(self, comp)\n\n        Directly overwrite this object's keys with the values in\n        `comp` without checking their type.\n        ";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_45_from_dict(PyObject *__pyx_v_self, PyObject *__pyx_v_comp) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_from_dict (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_44_from_dict(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), ((PyObject *)__pyx_v_comp));

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_44_from_dict(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_comp) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_from_dict", 0);
  __Pyx_TraceCall("_from_dict (wrapper)", __pyx_f[0], 669, 0, __PYX_ERR(0, 669, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyteomics_5cmass_12CComposition__from_dict(__pyx_v_self, __pyx_v_comp, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __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("pyteomics.cmass.CComposition._from_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":677
 * 
 * 
 *     cpdef double mass(self, int average=False, charge=None, dict mass_data=nist_mass, ion_type=None) except -1:             # <<<<<<<<<<<<<<
 *         '''
 *         Calculate the mass or m/z of a Composition.
 */

static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_47mass(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_9pyteomics_5cmass_12CComposition_mass(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_12CComposition_mass *__pyx_optional_args) {
  int __pyx_v_average = ((int)0);
  PyObject *__pyx_v_charge = ((PyObject *)Py_None);
  PyObject *__pyx_v_mass_data = __pyx_k__22;
  PyObject *__pyx_v_ion_type = ((PyObject *)Py_None);
  long __pyx_v_mdid;
  double __pyx_r;
  __Pyx_TraceDeclarations
  __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 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  long __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  struct __pyx_opt_args_9pyteomics_5cmass__calculate_mass __pyx_t_13;
  __Pyx_RefNannySetupContext("mass", 0);
  __Pyx_TraceCall("mass", __pyx_f[0], 677, 0, __PYX_ERR(0, 677, __pyx_L1_error));
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_average = __pyx_optional_args->average;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_charge = __pyx_optional_args->charge;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_mass_data = __pyx_optional_args->mass_data;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ion_type = __pyx_optional_args->ion_type;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_mass); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_47mass)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_average); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && 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);
          __pyx_t_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_3, __pyx_v_charge, __pyx_v_mass_data, __pyx_v_ion_type};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_3, __pyx_v_charge, __pyx_v_mass_data, __pyx_v_ion_type};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_charge);
        __Pyx_GIVEREF(__pyx_v_charge);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_charge);
        __Pyx_INCREF(__pyx_v_mass_data);
        __Pyx_GIVEREF(__pyx_v_mass_data);
        PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_mass_data);
        __Pyx_INCREF(__pyx_v_ion_type);
        __Pyx_GIVEREF(__pyx_v_ion_type);
        PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_v_ion_type);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 677, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 677, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_8;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "pyteomics/cmass.pyx":682
 *         '''
 *         cdef long mdid
 *         mdid = id(mass_data)             # <<<<<<<<<<<<<<
 *         if self._mass_args is not None and average is self._mass_args[0]\
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_mass_data);
  __Pyx_GIVEREF(__pyx_v_mass_data);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_mass_data);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_long(__pyx_t_2); if (unlikely((__pyx_t_9 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_mdid = __pyx_t_9;

  /* "pyteomics/cmass.pyx":683
 *         cdef long mdid
 *         mdid = id(mass_data)
 *         if self._mass_args is not None and average is self._mass_args[0]\             # <<<<<<<<<<<<<<
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 *                 and ion_type == self._mass_args[3]:
 */
  __pyx_t_11 = (__pyx_v_self->_mass_args != ((PyObject*)Py_None));
  __pyx_t_12 = (__pyx_t_11 != 0);
  if (__pyx_t_12) {
  } else {
    __pyx_t_10 = __pyx_t_12;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pyteomics/cmass.pyx":684
 *         mdid = id(mass_data)
 *         if self._mass_args is not None and average is self._mass_args[0]\
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\             # <<<<<<<<<<<<<<
 *                 and ion_type == self._mass_args[3]:
 *             return self._mass
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_average); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "pyteomics/cmass.pyx":683
 *         cdef long mdid
 *         mdid = id(mass_data)
 *         if self._mass_args is not None and average is self._mass_args[0]\             # <<<<<<<<<<<<<<
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 *                 and ion_type == self._mass_args[3]:
 */
  if (unlikely(__pyx_v_self->_mass_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 683, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_mass_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = (__pyx_t_2 == __pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = (__pyx_t_12 != 0);
  if (__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pyteomics/cmass.pyx":684
 *         mdid = id(mass_data)
 *         if self._mass_args is not None and average is self._mass_args[0]\
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\             # <<<<<<<<<<<<<<
 *                 and ion_type == self._mass_args[3]:
 *             return self._mass
 */
  if (unlikely(__pyx_v_self->_mass_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 684, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_mass_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_charge, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pyteomics/cmass.pyx":685
 *         if self._mass_args is not None and average is self._mass_args[0]\
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 *                 and ion_type == self._mass_args[3]:             # <<<<<<<<<<<<<<
 *             return self._mass
 *         else:
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_mdid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "pyteomics/cmass.pyx":684
 *         mdid = id(mass_data)
 *         if self._mass_args is not None and average is self._mass_args[0]\
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\             # <<<<<<<<<<<<<<
 *                 and ion_type == self._mass_args[3]:
 *             return self._mass
 */
  if (unlikely(__pyx_v_self->_mass_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 684, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_mass_args, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_11) {
  } else {
    __pyx_t_10 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }

  /* "pyteomics/cmass.pyx":685
 *         if self._mass_args is not None and average is self._mass_args[0]\
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 *                 and ion_type == self._mass_args[3]:             # <<<<<<<<<<<<<<
 *             return self._mass
 *         else:
 */
  if (unlikely(__pyx_v_self->_mass_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 685, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_mass_args, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_ion_type, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 685, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 685, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_10 = __pyx_t_11;
  __pyx_L4_bool_binop_done:;

  /* "pyteomics/cmass.pyx":683
 *         cdef long mdid
 *         mdid = id(mass_data)
 *         if self._mass_args is not None and average is self._mass_args[0]\             # <<<<<<<<<<<<<<
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 *                 and ion_type == self._mass_args[3]:
 */
  if (__pyx_t_10) {

    /* "pyteomics/cmass.pyx":686
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 *                 and ion_type == self._mass_args[3]:
 *             return self._mass             # <<<<<<<<<<<<<<
 *         else:
 *             self._mass_args = (average, charge, mdid, ion_type)
 */
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_self->_mass); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 686, __pyx_L1_error)
    __pyx_r = __pyx_t_8;
    goto __pyx_L0;

    /* "pyteomics/cmass.pyx":683
 *         cdef long mdid
 *         mdid = id(mass_data)
 *         if self._mass_args is not None and average is self._mass_args[0]\             # <<<<<<<<<<<<<<
 *                 and charge == self._mass_args[1] and mdid == self._mass_args[2]\
 *                 and ion_type == self._mass_args[3]:
 */
  }

  /* "pyteomics/cmass.pyx":688
 *             return self._mass
 *         else:
 *             self._mass_args = (average, charge, mdid, ion_type)             # <<<<<<<<<<<<<<
 *             self._mass = _calculate_mass(composition=self, average=average, charge=charge, mass_data=mass_data, ion_type=ion_type)
 *             return self._mass
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_average); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 688, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_mdid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 688, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 688, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_charge);
    __Pyx_GIVEREF(__pyx_v_charge);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_charge);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_ion_type);
    __Pyx_GIVEREF(__pyx_v_ion_type);
    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_ion_type);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->_mass_args);
    __Pyx_DECREF(__pyx_v_self->_mass_args);
    __pyx_v_self->_mass_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":689
 *         else:
 *             self._mass_args = (average, charge, mdid, ion_type)
 *             self._mass = _calculate_mass(composition=self, average=average, charge=charge, mass_data=mass_data, ion_type=ion_type)             # <<<<<<<<<<<<<<
 *             return self._mass
 * 
 */
    __pyx_t_13.__pyx_n = 4;
    __pyx_t_13.average = __pyx_v_average;
    __pyx_t_13.charge = __pyx_v_charge;
    __pyx_t_13.mass_data = __pyx_v_mass_data;
    __pyx_t_13.ion_type = __pyx_v_ion_type;
    __pyx_t_8 = __pyx_f_9pyteomics_5cmass__calculate_mass(__pyx_v_self, &__pyx_t_13); if (unlikely(__pyx_t_8 == -1.0)) __PYX_ERR(0, 689, __pyx_L1_error)
    __pyx_t_2 = PyFloat_FromDouble(__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->_mass);
    __Pyx_DECREF(__pyx_v_self->_mass);
    __pyx_v_self->_mass = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pyteomics/cmass.pyx":690
 *             self._mass_args = (average, charge, mdid, ion_type)
 *             self._mass = _calculate_mass(composition=self, average=average, charge=charge, mass_data=mass_data, ion_type=ion_type)
 *             return self._mass             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *args, **kwargs):
 */
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_self->_mass); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 690, __pyx_L1_error)
    __pyx_r = __pyx_t_8;
    goto __pyx_L0;
  }

  /* "pyteomics/cmass.pyx":677
 * 
 * 
 *     cpdef double mass(self, int average=False, charge=None, dict mass_data=nist_mass, ion_type=None) except -1:             # <<<<<<<<<<<<<<
 *         '''
 *         Calculate the mass or m/z of a Composition.
 */

  /* 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_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1.0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_47mass(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_12CComposition_46mass[] = "CComposition.mass(self, int average=False, charge=None, dict mass_data=nist_mass, ion_type=None) -> double\n\n        Calculate the mass or m/z of a Composition.\n        ";
static PyObject *__pyx_pw_9pyteomics_5cmass_12CComposition_47mass(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_average;
  PyObject *__pyx_v_charge = 0;
  PyObject *__pyx_v_mass_data = 0;
  PyObject *__pyx_v_ion_type = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("mass (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_average,&__pyx_n_s_charge,&__pyx_n_s_mass_data,&__pyx_n_s_ion_type,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = __pyx_k__22;
    values[3] = ((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  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_average);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_charge);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mass_data);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ion_type);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "mass") < 0)) __PYX_ERR(0, 677, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_average = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_average == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 677, __pyx_L3_error)
    } else {
      __pyx_v_average = ((int)0);
    }
    __pyx_v_charge = values[1];
    __pyx_v_mass_data = ((PyObject*)values[2]);
    __pyx_v_ion_type = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("mass", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 677, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mass_data), (&PyDict_Type), 1, "mass_data", 1))) __PYX_ERR(0, 677, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_46mass(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_average, __pyx_v_charge, __pyx_v_mass_data, __pyx_v_ion_type);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_12CComposition_46mass(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, int __pyx_v_average, PyObject *__pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_ion_type) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  struct __pyx_opt_args_9pyteomics_5cmass_12CComposition_mass __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("mass", 0);
  __Pyx_TraceCall("mass (wrapper)", __pyx_f[0], 677, 0, __PYX_ERR(0, 677, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.average = __pyx_v_average;
  __pyx_t_2.charge = __pyx_v_charge;
  __pyx_t_2.mass_data = __pyx_v_mass_data;
  __pyx_t_2.ion_type = __pyx_v_ion_type;
  __pyx_t_1 = __pyx_vtabptr_9pyteomics_5cmass_CComposition->mass(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1.0)) __PYX_ERR(0, 677, __pyx_L1_error)
  __pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":692
 *             return self._mass
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         dict.__init__(self)
 *         cdef:
 */

/* Python wrapper */
static int __pyx_pw_9pyteomics_5cmass_12CComposition_49__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyteomics_5cmass_12CComposition_49__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9pyteomics_5cmass_12CComposition_48__init__(((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

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

static int __pyx_pf_9pyteomics_5cmass_12CComposition_48__init__(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_mass_data = 0;
  PyObject *__pyx_v_aa_comp = 0;
  PyObject *__pyx_v_kwa = 0;
  PyObject *__pyx_v_kw_sources = 0;
  PyObject *__pyx_v_kw_given = 0;
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  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;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 692, 0, __PYX_ERR(0, 692, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":693
 * 
 *     def __init__(self, *args, **kwargs):
 *         dict.__init__(self)             # <<<<<<<<<<<<<<
 *         cdef:
 *             dict mass_data, aa_comp
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyDict_Type)), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 693, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __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(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __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(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":698
 *             str kwa
 *             set kw_sources, kw_given
 *         aa_comp=kwargs.get('aa_comp', std_aa_comp)             # <<<<<<<<<<<<<<
 *         mass_data=kwargs.get('mass_data')
 *         if mass_data is None:
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_aa_comp, __pyx_v_9pyteomics_5cmass_std_aa_comp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 698, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 698, __pyx_L1_error)
  __pyx_v_aa_comp = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":699
 *             set kw_sources, kw_given
 *         aa_comp=kwargs.get('aa_comp', std_aa_comp)
 *         mass_data=kwargs.get('mass_data')             # <<<<<<<<<<<<<<
 *         if mass_data is None:
 *             mass_data = nist_mass
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_mass_data, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 699, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 699, __pyx_L1_error)
  __pyx_v_mass_data = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":700
 *         aa_comp=kwargs.get('aa_comp', std_aa_comp)
 *         mass_data=kwargs.get('mass_data')
 *         if mass_data is None:             # <<<<<<<<<<<<<<
 *             mass_data = nist_mass
 * 
 */
  __pyx_t_5 = (__pyx_v_mass_data == ((PyObject*)Py_None));
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "pyteomics/cmass.pyx":701
 *         mass_data=kwargs.get('mass_data')
 *         if mass_data is None:
 *             mass_data = nist_mass             # <<<<<<<<<<<<<<
 * 
 *         kw_sources = {'formula', 'sequence', 'parsed_sequence',
 */
    __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
    __Pyx_DECREF_SET(__pyx_v_mass_data, __pyx_v_9pyteomics_5cmass_nist_mass);

    /* "pyteomics/cmass.pyx":700
 *         aa_comp=kwargs.get('aa_comp', std_aa_comp)
 *         mass_data=kwargs.get('mass_data')
 *         if mass_data is None:             # <<<<<<<<<<<<<<
 *             mass_data = nist_mass
 * 
 */
  }

  /* "pyteomics/cmass.pyx":703
 *             mass_data = nist_mass
 * 
 *         kw_sources = {'formula', 'sequence', 'parsed_sequence',             # <<<<<<<<<<<<<<
 *                 'split_sequence'}
 *         kw_given = kw_sources.intersection(kwargs)
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PySet_Add(__pyx_t_1, __pyx_n_s_formula) < 0) __PYX_ERR(0, 703, __pyx_L1_error)
  if (PySet_Add(__pyx_t_1, __pyx_n_s_sequence) < 0) __PYX_ERR(0, 703, __pyx_L1_error)
  if (PySet_Add(__pyx_t_1, __pyx_n_s_parsed_sequence) < 0) __PYX_ERR(0, 703, __pyx_L1_error)
  if (PySet_Add(__pyx_t_1, __pyx_n_s_split_sequence) < 0) __PYX_ERR(0, 703, __pyx_L1_error)
  __pyx_v_kw_sources = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":705
 *         kw_sources = {'formula', 'sequence', 'parsed_sequence',
 *                 'split_sequence'}
 *         kw_given = kw_sources.intersection(kwargs)             # <<<<<<<<<<<<<<
 *         if len(kw_given) > 1:
 *             raise PyteomicsError('Only one of {} can be specified!\n'
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kw_sources, __pyx_n_s_intersection); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 705, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_kwargs};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_kwargs};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 705, __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_kwargs);
      __Pyx_GIVEREF(__pyx_v_kwargs);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_kwargs);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __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;
  if (!(likely(PySet_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 705, __pyx_L1_error)
  __pyx_v_kw_given = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyteomics/cmass.pyx":706
 *                 'split_sequence'}
 *         kw_given = kw_sources.intersection(kwargs)
 *         if len(kw_given) > 1:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('Only one of {} can be specified!\n'
 *                     'Given: {}'.format(', '.join(kw_sources),
 */
  if (unlikely(__pyx_v_kw_given == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 706, __pyx_L1_error)
  }
  __pyx_t_7 = PySet_GET_SIZE(__pyx_v_kw_given); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 706, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_7 > 1) != 0);
  if (__pyx_t_6) {

    /* "pyteomics/cmass.pyx":707
 *         kw_given = kw_sources.intersection(kwargs)
 *         if len(kw_given) > 1:
 *             raise PyteomicsError('Only one of {} can be specified!\n'             # <<<<<<<<<<<<<<
 *                     'Given: {}'.format(', '.join(kw_sources),
 *                         ', '.join(kw_given)))
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "pyteomics/cmass.pyx":708
 *         if len(kw_given) > 1:
 *             raise PyteomicsError('Only one of {} can be specified!\n'
 *                     'Given: {}'.format(', '.join(kw_sources),             # <<<<<<<<<<<<<<
 *                         ', '.join(kw_given)))
 *         elif kw_given:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Only_one_of_can_be_specified_Giv, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 708, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyString_Join(__pyx_kp_s__11, __pyx_v_kw_sources); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 708, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);

    /* "pyteomics/cmass.pyx":709
 *             raise PyteomicsError('Only one of {} can be specified!\n'
 *                     'Given: {}'.format(', '.join(kw_sources),
 *                         ', '.join(kw_given)))             # <<<<<<<<<<<<<<
 *         elif kw_given:
 *             kwa = kw_given.pop()
 */
    __pyx_t_9 = __Pyx_PyString_Join(__pyx_kp_s__11, __pyx_v_kw_given); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_8, __pyx_t_9};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 708, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_8, __pyx_t_9};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 708, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 708, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_9);
      __pyx_t_8 = 0;
      __pyx_t_9 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 708, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 707, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 707, __pyx_L1_error)

    /* "pyteomics/cmass.pyx":706
 *                 'split_sequence'}
 *         kw_given = kw_sources.intersection(kwargs)
 *         if len(kw_given) > 1:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError('Only one of {} can be specified!\n'
 *                     'Given: {}'.format(', '.join(kw_sources),
 */
  }

  /* "pyteomics/cmass.pyx":710
 *                     'Given: {}'.format(', '.join(kw_sources),
 *                         ', '.join(kw_given)))
 *         elif kw_given:             # <<<<<<<<<<<<<<
 *             kwa = kw_given.pop()
 *             getattr(self, '_from_' + kwa)(kwargs[kwa],
 */
  __pyx_t_6 = (__pyx_v_kw_given != Py_None) && (PySet_GET_SIZE(__pyx_v_kw_given) != 0);
  if (__pyx_t_6) {

    /* "pyteomics/cmass.pyx":711
 *                         ', '.join(kw_given)))
 *         elif kw_given:
 *             kwa = kw_given.pop()             # <<<<<<<<<<<<<<
 *             getattr(self, '_from_' + kwa)(kwargs[kwa],
 *                     mass_data if kwa == 'formula' else aa_comp)
 */
    if (unlikely(__pyx_v_kw_given == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
      __PYX_ERR(0, 711, __pyx_L1_error)
    }
    __pyx_t_1 = PySet_Pop(__pyx_v_kw_given); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 711, __pyx_L1_error)
    __pyx_v_kwa = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyteomics/cmass.pyx":712
 *         elif kw_given:
 *             kwa = kw_given.pop()
 *             getattr(self, '_from_' + kwa)(kwargs[kwa],             # <<<<<<<<<<<<<<
 *                     mass_data if kwa == 'formula' else aa_comp)
 * 
 */
    __pyx_t_2 = PyNumber_Add(__pyx_n_s_from, __pyx_v_kwa); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = __Pyx_GetAttr(((PyObject *)__pyx_v_self), __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 712, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_kwargs, __pyx_v_kwa); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "pyteomics/cmass.pyx":713
 *             kwa = kw_given.pop()
 *             getattr(self, '_from_' + kwa)(kwargs[kwa],
 *                     mass_data if kwa == 'formula' else aa_comp)             # <<<<<<<<<<<<<<
 * 
 *         # can't build from kwargs
 */
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_v_kwa, __pyx_n_s_formula, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 713, __pyx_L1_error)
    if ((__pyx_t_6 != 0)) {
      __Pyx_INCREF(__pyx_v_mass_data);
      __pyx_t_3 = __pyx_v_mass_data;
    } else {
      __Pyx_INCREF(__pyx_v_aa_comp);
      __pyx_t_3 = __pyx_v_aa_comp;
    }
    __pyx_t_4 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyteomics/cmass.pyx":710
 *                     'Given: {}'.format(', '.join(kw_sources),
 *                         ', '.join(kw_given)))
 *         elif kw_given:             # <<<<<<<<<<<<<<
 *             kwa = kw_given.pop()
 *             getattr(self, '_from_' + kwa)(kwargs[kwa],
 */
    goto __pyx_L4;
  }

  /* "pyteomics/cmass.pyx":716
 * 
 *         # can't build from kwargs
 *         elif args:             # <<<<<<<<<<<<<<
 *             if isinstance(args[0], dict):
 *                 self._from_dict(args[0])
 */
  __pyx_t_6 = (__pyx_v_args != Py_None) && (PyTuple_GET_SIZE(__pyx_v_args) != 0);
  if (__pyx_t_6) {

    /* "pyteomics/cmass.pyx":717
 *         # can't build from kwargs
 *         elif args:
 *             if isinstance(args[0], dict):             # <<<<<<<<<<<<<<
 *                 self._from_dict(args[0])
 *             elif isinstance(args[0], str):
 */
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 717, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyDict_Check(__pyx_t_1); 
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = (__pyx_t_6 != 0);
    if (__pyx_t_5) {

      /* "pyteomics/cmass.pyx":718
 *         elif args:
 *             if isinstance(args[0], dict):
 *                 self._from_dict(args[0])             # <<<<<<<<<<<<<<
 *             elif isinstance(args[0], str):
 *                 try:
 */
      __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = ((struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *)__pyx_v_self->__pyx_vtab)->_from_dict(__pyx_v_self, __pyx_t_1, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 718, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "pyteomics/cmass.pyx":717
 *         # can't build from kwargs
 *         elif args:
 *             if isinstance(args[0], dict):             # <<<<<<<<<<<<<<
 *                 self._from_dict(args[0])
 *             elif isinstance(args[0], str):
 */
      goto __pyx_L5;
    }

    /* "pyteomics/cmass.pyx":719
 *             if isinstance(args[0], dict):
 *                 self._from_dict(args[0])
 *             elif isinstance(args[0], str):             # <<<<<<<<<<<<<<
 *                 try:
 *                     self._from_sequence(args[0], aa_comp)
 */
    __pyx_t_12 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_5 = PyString_Check(__pyx_t_12); 
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "pyteomics/cmass.pyx":720
 *                 self._from_dict(args[0])
 *             elif isinstance(args[0], str):
 *                 try:             # <<<<<<<<<<<<<<
 *                     self._from_sequence(args[0], aa_comp)
 *                 except PyteomicsError:
 */
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_15);
        /*try:*/ {

          /* "pyteomics/cmass.pyx":721
 *             elif isinstance(args[0], str):
 *                 try:
 *                     self._from_sequence(args[0], aa_comp)             # <<<<<<<<<<<<<<
 *                 except PyteomicsError:
 *                     try:
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 721, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_9 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 721, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_3 = NULL;
          __pyx_t_11 = 0;
          if (CYTHON_UNPACK_METHODS && likely(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);
              __pyx_t_11 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_9, __pyx_v_aa_comp};
            __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 721, __pyx_L6_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_9, __pyx_v_aa_comp};
            __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 721, __pyx_L6_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          } else
          #endif
          {
            __pyx_t_2 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L6_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_GIVEREF(__pyx_t_9);
            PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, __pyx_t_9);
            __Pyx_INCREF(__pyx_v_aa_comp);
            __Pyx_GIVEREF(__pyx_v_aa_comp);
            PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, __pyx_v_aa_comp);
            __pyx_t_9 = 0;
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 721, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "pyteomics/cmass.pyx":720
 *                 self._from_dict(args[0])
 *             elif isinstance(args[0], str):
 *                 try:             # <<<<<<<<<<<<<<
 *                     self._from_sequence(args[0], aa_comp)
 *                 except PyteomicsError:
 */
        }
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        goto __pyx_L11_try_end;
        __pyx_L6_error:;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "pyteomics/cmass.pyx":722
 *                 try:
 *                     self._from_sequence(args[0], aa_comp)
 *                 except PyteomicsError:             # <<<<<<<<<<<<<<
 *                     try:
 *                         self._from_formula(args[0], mass_data)
 */
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 722, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (__pyx_t_11) {
          __Pyx_AddTraceback("pyteomics.cmass.CComposition.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 722, __pyx_L8_except_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_2);

          /* "pyteomics/cmass.pyx":723
 *                     self._from_sequence(args[0], aa_comp)
 *                 except PyteomicsError:
 *                     try:             # <<<<<<<<<<<<<<
 *                         self._from_formula(args[0], mass_data)
 *                     except PyteomicsError:
 */
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_18);
            /*try:*/ {

              /* "pyteomics/cmass.pyx":724
 *                 except PyteomicsError:
 *                     try:
 *                         self._from_formula(args[0], mass_data)             # <<<<<<<<<<<<<<
 *                     except PyteomicsError:
 *                         raise PyteomicsError(
 */
              __pyx_t_9 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 724, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_9);
              if (!(likely(PyString_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_9)->tp_name), 0))) __PYX_ERR(0, 724, __pyx_L14_error)
              __pyx_t_3 = ((struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *)__pyx_v_self->__pyx_vtab)->_from_formula(__pyx_v_self, ((PyObject*)__pyx_t_9), __pyx_v_mass_data, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 724, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "pyteomics/cmass.pyx":723
 *                     self._from_sequence(args[0], aa_comp)
 *                 except PyteomicsError:
 *                     try:             # <<<<<<<<<<<<<<
 *                         self._from_formula(args[0], mass_data)
 *                     except PyteomicsError:
 */
            }
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L21_try_end;
            __pyx_L14_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "pyteomics/cmass.pyx":725
 *                     try:
 *                         self._from_formula(args[0], mass_data)
 *                     except PyteomicsError:             # <<<<<<<<<<<<<<
 *                         raise PyteomicsError(
 *                                 'Could not create a Composition object from '
 */
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 725, __pyx_L16_except_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (__pyx_t_11) {
              __Pyx_AddTraceback("pyteomics.cmass.CComposition.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 725, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_GOTREF(__pyx_t_4);

              /* "pyteomics/cmass.pyx":726
 *                         self._from_formula(args[0], mass_data)
 *                     except PyteomicsError:
 *                         raise PyteomicsError(             # <<<<<<<<<<<<<<
 *                                 'Could not create a Composition object from '
 *                                 'string: "{}": not a valid sequence or '
 */
              __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 726, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_10);

              /* "pyteomics/cmass.pyx":729
 *                                 'Could not create a Composition object from '
 *                                 'string: "{}": not a valid sequence or '
 *                                 'formula'.format(args[0]))             # <<<<<<<<<<<<<<
 *             else:
 *                 try:
 */
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Could_not_create_a_Composition_o, __pyx_n_s_format); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 729, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_21 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 729, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_21);
              __pyx_t_22 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_20))) {
                __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_20);
                if (likely(__pyx_t_22)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20);
                  __Pyx_INCREF(__pyx_t_22);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_20, function);
                }
              }
              if (!__pyx_t_22) {
                __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_20, __pyx_t_21); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 729, __pyx_L16_except_error)
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_GOTREF(__pyx_t_19);
              } else {
                #if CYTHON_FAST_PYCALL
                if (PyFunction_Check(__pyx_t_20)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_22, __pyx_t_21};
                  __pyx_t_19 = __Pyx_PyFunction_FastCall(__pyx_t_20, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 729, __pyx_L16_except_error)
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                } else
                #endif
                #if CYTHON_FAST_PYCCALL
                if (__Pyx_PyFastCFunction_Check(__pyx_t_20)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_22, __pyx_t_21};
                  __pyx_t_19 = __Pyx_PyCFunction_FastCall(__pyx_t_20, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 729, __pyx_L16_except_error)
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                } else
                #endif
                {
                  __pyx_t_23 = PyTuple_New(1+1); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 729, __pyx_L16_except_error)
                  __Pyx_GOTREF(__pyx_t_23);
                  __Pyx_GIVEREF(__pyx_t_22); PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_22); __pyx_t_22 = NULL;
                  __Pyx_GIVEREF(__pyx_t_21);
                  PyTuple_SET_ITEM(__pyx_t_23, 0+1, __pyx_t_21);
                  __pyx_t_21 = 0;
                  __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_23, NULL); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 729, __pyx_L16_except_error)
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                }
              }
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __pyx_t_20 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
                __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_10);
                if (likely(__pyx_t_20)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
                  __Pyx_INCREF(__pyx_t_20);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_10, function);
                }
              }
              if (!__pyx_t_20) {
                __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_19); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 726, __pyx_L16_except_error)
                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_GOTREF(__pyx_t_8);
              } else {
                #if CYTHON_FAST_PYCALL
                if (PyFunction_Check(__pyx_t_10)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_t_19};
                  __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 726, __pyx_L16_except_error)
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_GOTREF(__pyx_t_8);
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                } else
                #endif
                #if CYTHON_FAST_PYCCALL
                if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
                  PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_t_19};
                  __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 726, __pyx_L16_except_error)
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_GOTREF(__pyx_t_8);
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                } else
                #endif
                {
                  __pyx_t_23 = PyTuple_New(1+1); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 726, __pyx_L16_except_error)
                  __Pyx_GOTREF(__pyx_t_23);
                  __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_20); __pyx_t_20 = NULL;
                  __Pyx_GIVEREF(__pyx_t_19);
                  PyTuple_SET_ITEM(__pyx_t_23, 0+1, __pyx_t_19);
                  __pyx_t_19 = 0;
                  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_23, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 726, __pyx_L16_except_error)
                  __Pyx_GOTREF(__pyx_t_8);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                }
              }
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_Raise(__pyx_t_8, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              __PYX_ERR(0, 726, __pyx_L16_except_error)
            }
            goto __pyx_L16_except_error;
            __pyx_L16_except_error:;

            /* "pyteomics/cmass.pyx":723
 *                     self._from_sequence(args[0], aa_comp)
 *                 except PyteomicsError:
 *                     try:             # <<<<<<<<<<<<<<
 *                         self._from_formula(args[0], mass_data)
 *                     except PyteomicsError:
 */
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            goto __pyx_L8_except_error;
            __pyx_L21_try_end:;
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L7_exception_handled;
        }
        goto __pyx_L8_except_error;
        __pyx_L8_except_error:;

        /* "pyteomics/cmass.pyx":720
 *                 self._from_dict(args[0])
 *             elif isinstance(args[0], str):
 *                 try:             # <<<<<<<<<<<<<<
 *                     self._from_sequence(args[0], aa_comp)
 *                 except PyteomicsError:
 */
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
        goto __pyx_L1_error;
        __pyx_L7_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
        __pyx_L11_try_end:;
      }

      /* "pyteomics/cmass.pyx":719
 *             if isinstance(args[0], dict):
 *                 self._from_dict(args[0])
 *             elif isinstance(args[0], str):             # <<<<<<<<<<<<<<
 *                 try:
 *                     self._from_sequence(args[0], aa_comp)
 */
      goto __pyx_L5;
    }

    /* "pyteomics/cmass.pyx":731
 *                                 'formula'.format(args[0]))
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     self._from_sequence(cparser.tostring(args[0], True),
 *                             aa_comp)
 */
    /*else*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_13);
        /*try:*/ {

          /* "pyteomics/cmass.pyx":732
 *             else:
 *                 try:
 *                     self._from_sequence(cparser.tostring(args[0], True),             # <<<<<<<<<<<<<<
 *                             aa_comp)
 *                 except:
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 732, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cparser); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 732, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_tostring); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 732, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 732, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = NULL;
          __pyx_t_11 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
              __pyx_t_11 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, Py_True};
            __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 732, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, Py_True};
            __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 732, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          {
            __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 732, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_8);
            if (__pyx_t_3) {
              __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_t_4);
            __Pyx_INCREF(Py_True);
            __Pyx_GIVEREF(Py_True);
            PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, Py_True);
            __pyx_t_4 = 0;
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 732, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          }
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "pyteomics/cmass.pyx":733
 *                 try:
 *                     self._from_sequence(cparser.tostring(args[0], True),
 *                             aa_comp)             # <<<<<<<<<<<<<<
 *                 except:
 *                     raise PyteomicsError('Could not create a Composition object'
 */
          __pyx_t_9 = NULL;
          __pyx_t_11 = 0;
          if (CYTHON_UNPACK_METHODS && likely(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);
              __pyx_t_11 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_12, __pyx_v_aa_comp};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_12, __pyx_v_aa_comp};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          #endif
          {
            __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 732, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_8);
            if (__pyx_t_9) {
              __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_12);
            PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_t_12);
            __Pyx_INCREF(__pyx_v_aa_comp);
            __Pyx_GIVEREF(__pyx_v_aa_comp);
            PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_v_aa_comp);
            __pyx_t_12 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L24_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_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "pyteomics/cmass.pyx":731
 *                                 'formula'.format(args[0]))
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     self._from_sequence(cparser.tostring(args[0], True),
 *                             aa_comp)
 */
        }
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L29_try_end;
        __pyx_L24_error:;
        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyteomics/cmass.pyx":734
 *                     self._from_sequence(cparser.tostring(args[0], True),
 *                             aa_comp)
 *                 except:             # <<<<<<<<<<<<<<
 *                     raise PyteomicsError('Could not create a Composition object'
 *                             ' from `{}`. A Composition object must be '
 */
        /*except:*/ {
          __Pyx_AddTraceback("pyteomics.cmass.CComposition.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_8) < 0) __PYX_ERR(0, 734, __pyx_L26_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_8);

          /* "pyteomics/cmass.pyx":735
 *                             aa_comp)
 *                 except:
 *                     raise PyteomicsError('Could not create a Composition object'             # <<<<<<<<<<<<<<
 *                             ' from `{}`. A Composition object must be '
 *                             'specified by sequence, parsed or split sequence,'
 */
          __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 735, __pyx_L26_except_error)
          __Pyx_GOTREF(__pyx_t_9);

          /* "pyteomics/cmass.pyx":738
 *                             ' from `{}`. A Composition object must be '
 *                             'specified by sequence, parsed or split sequence,'
 *                             ' formula or dict.'.format(args[0]))             # <<<<<<<<<<<<<<
 *         else:
 *             self._from_dict(kwargs)
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Could_not_create_a_Composition_o_2, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 738, __pyx_L26_except_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_10 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 738, __pyx_L26_except_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_23 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_23)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_23);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          if (!__pyx_t_23) {
            __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 738, __pyx_L26_except_error)
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_4);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_3)) {
              PyObject *__pyx_temp[2] = {__pyx_t_23, __pyx_t_10};
              __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 738, __pyx_L26_except_error)
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
              PyObject *__pyx_temp[2] = {__pyx_t_23, __pyx_t_10};
              __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 738, __pyx_L26_except_error)
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            } else
            #endif
            {
              __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 738, __pyx_L26_except_error)
              __Pyx_GOTREF(__pyx_t_19);
              __Pyx_GIVEREF(__pyx_t_23); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_23); __pyx_t_23 = NULL;
              __Pyx_GIVEREF(__pyx_t_10);
              PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_t_10);
              __pyx_t_10 = 0;
              __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_19, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 738, __pyx_L26_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
            }
          }
          if (!__pyx_t_3) {
            __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 735, __pyx_L26_except_error)
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_12);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_9)) {
              PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
              __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 735, __pyx_L26_except_error)
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
              PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
              __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 735, __pyx_L26_except_error)
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            } else
            #endif
            {
              __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 735, __pyx_L26_except_error)
              __Pyx_GOTREF(__pyx_t_19);
              __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_3); __pyx_t_3 = NULL;
              __Pyx_GIVEREF(__pyx_t_4);
              PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_t_4);
              __pyx_t_4 = 0;
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_19, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 735, __pyx_L26_except_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_Raise(__pyx_t_12, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __PYX_ERR(0, 735, __pyx_L26_except_error)
        }
        __pyx_L26_except_error:;

        /* "pyteomics/cmass.pyx":731
 *                                 'formula'.format(args[0]))
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     self._from_sequence(cparser.tostring(args[0], True),
 *                             aa_comp)
 */
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_14, __pyx_t_13);
        goto __pyx_L1_error;
        __pyx_L29_try_end:;
      }
    }
    __pyx_L5:;

    /* "pyteomics/cmass.pyx":716
 * 
 *         # can't build from kwargs
 *         elif args:             # <<<<<<<<<<<<<<
 *             if isinstance(args[0], dict):
 *                 self._from_dict(args[0])
 */
    goto __pyx_L4;
  }

  /* "pyteomics/cmass.pyx":740
 *                             ' formula or dict.'.format(args[0]))
 *         else:
 *             self._from_dict(kwargs)             # <<<<<<<<<<<<<<
 * 
 *         self._mass = None
 */
  /*else*/ {
    __pyx_t_8 = ((struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition *)__pyx_v_self->__pyx_vtab)->_from_dict(__pyx_v_self, __pyx_v_kwargs, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __pyx_L4:;

  /* "pyteomics/cmass.pyx":742
 *             self._from_dict(kwargs)
 * 
 *         self._mass = None             # <<<<<<<<<<<<<<
 *         self._mass_args = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass);
  __Pyx_DECREF(__pyx_v_self->_mass);
  __pyx_v_self->_mass = Py_None;

  /* "pyteomics/cmass.pyx":743
 * 
 *         self._mass = None
 *         self._mass_args = None             # <<<<<<<<<<<<<<
 * 
 * Composition = CComposition
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mass_args);
  __Pyx_DECREF(__pyx_v_self->_mass_args);
  __pyx_v_self->_mass_args = ((PyObject*)Py_None);

  /* "pyteomics/cmass.pyx":692
 *             return self._mass
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         dict.__init__(self)
 *         cdef:
 */

  /* function exit code */
  __pyx_r = 0;
  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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_AddTraceback("pyteomics.cmass.CComposition.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mass_data);
  __Pyx_XDECREF(__pyx_v_aa_comp);
  __Pyx_XDECREF(__pyx_v_kwa);
  __Pyx_XDECREF(__pyx_v_kw_sources);
  __Pyx_XDECREF(__pyx_v_kw_given);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":747
 * Composition = CComposition
 * 
 * def calculate_mass(composition=None, average=False, charge=None, mass_data=None, ion_type=None, **kwargs):             # <<<<<<<<<<<<<<
 *     """Calculates the monoisotopic mass of a polypeptide defined by a
 *     sequence string, parsed sequence, chemical formula or
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyteomics_5cmass_9calculate_mass(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyteomics_5cmass_8calculate_mass[] = "calculate_mass(composition=None, average=False, charge=None, mass_data=None, ion_type=None, **kwargs)\nCalculates the monoisotopic mass of a polypeptide defined by a\n    sequence string, parsed sequence, chemical formula or\n    Composition object.\n\n    One or none of the following keyword arguments is required:\n    **formula**, **sequence**, **parsed_sequence**, **split_sequence**\n    or **composition**.\n    All arguments given are used to create a :py:class:`Composition` object,\n    unless an existing one is passed as a keyword argument.\n\n    Note that if a sequence string is supplied and terminal groups are not\n    explicitly shown, then the mass is calculated for a polypeptide with\n    standard terminal groups (NH2- and -OH).\n\n    .. warning::\n\n        Be careful when supplying a list with a parsed sequence. It must be\n        obtained with enabled `show_unmodified_termini` option.\n\n    Parameters\n    ----------\n    formula : str, optional\n        A string with a chemical formula.\n    sequence : str, optional\n        A polypeptide sequence string in modX notation.\n    parsed_sequence : list of str, optional\n        A polypeptide sequence parsed into a list of amino acids.\n    composition : Composition, optional\n        A Composition object with the elemental composition of a substance.\n    aa_comp : dict, optional\n        A dict with the elemental composition of the amino acids (the\n        default value is std_aa_comp).\n    average : bool, optional\n        If :py:const:`True` then the average mass is calculated. Note that mass\n        is not averaged for elements with specified isotopes. Default is\n        :py:const:`False`.\n    charge : int, optional\n        If not 0 then m/z is calculated: the mass is increased\n        by the corresponding number of proton masses and divided\n        by `charge`.\n    mass_data : dict, optional\n        A dict with the masses of the chemical elements (the default\n        value is :py:data"":`nist_mass`).\n    ion_comp : dict, optional\n        A dict with the relative elemental compositions of peptide ion\n        fragments (default is :py:data:`std_ion_comp`).\n    ion_type : str, optional\n        If specified, then the polypeptide is considered to be in the form\n        of the corresponding ion. Do not forget to specify the charge state!\n\n    Returns\n    -------\n    mass : float\n    ";
static PyMethodDef __pyx_mdef_9pyteomics_5cmass_9calculate_mass = {"calculate_mass", (PyCFunction)__pyx_pw_9pyteomics_5cmass_9calculate_mass, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_8calculate_mass};
static PyObject *__pyx_pw_9pyteomics_5cmass_9calculate_mass(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_composition = 0;
  PyObject *__pyx_v_average = 0;
  PyObject *__pyx_v_charge = 0;
  PyObject *__pyx_v_mass_data = 0;
  PyObject *__pyx_v_ion_type = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("calculate_mass (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_composition,&__pyx_n_s_average,&__pyx_n_s_charge,&__pyx_n_s_mass_data,&__pyx_n_s_ion_type,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_False);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        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_composition);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_average);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_charge);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mass_data);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ion_type);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "calculate_mass") < 0)) __PYX_ERR(0, 747, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_composition = values[0];
    __pyx_v_average = values[1];
    __pyx_v_charge = values[2];
    __pyx_v_mass_data = values[3];
    __pyx_v_ion_type = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("calculate_mass", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 747, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pyteomics.cmass.calculate_mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyteomics_5cmass_8calculate_mass(__pyx_self, __pyx_v_composition, __pyx_v_average, __pyx_v_charge, __pyx_v_mass_data, __pyx_v_ion_type, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_9pyteomics_5cmass_8calculate_mass(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_composition, PyObject *__pyx_v_average, PyObject *__pyx_v_charge, PyObject *__pyx_v_mass_data, PyObject *__pyx_v_ion_type, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __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;
  __Pyx_TraceFrameInit(__pyx_codeobj__23)
  __Pyx_RefNannySetupContext("calculate_mass", 0);
  __Pyx_TraceCall("calculate_mass", __pyx_f[0], 747, 0, __PYX_ERR(0, 747, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_composition);

  /* "pyteomics/cmass.pyx":802
 *     mass : float
 *     """
 *     if composition is None:             # <<<<<<<<<<<<<<
 *         composition = CComposition(mass_data=mass_data, **kwargs)
 *     return composition.mass(average=average, charge=charge, mass_data=mass_data, ion_type=ion_type)
 */
  __pyx_t_1 = (__pyx_v_composition == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":803
 *     """
 *     if composition is None:
 *         composition = CComposition(mass_data=mass_data, **kwargs)             # <<<<<<<<<<<<<<
 *     return composition.mass(average=average, charge=charge, mass_data=mass_data, ion_type=ion_type)
 * 
 */
    __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_mass_data, __pyx_v_mass_data) < 0) __PYX_ERR(0, 803, __pyx_L1_error)
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
    if (__Pyx_MergeKeywords(__pyx_t_3, __pyx_v_kwargs) < 0) __PYX_ERR(0, 803, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_composition, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pyteomics/cmass.pyx":802
 *     mass : float
 *     """
 *     if composition is None:             # <<<<<<<<<<<<<<
 *         composition = CComposition(mass_data=mass_data, **kwargs)
 *     return composition.mass(average=average, charge=charge, mass_data=mass_data, ion_type=ion_type)
 */
  }

  /* "pyteomics/cmass.pyx":804
 *     if composition is None:
 *         composition = CComposition(mass_data=mass_data, **kwargs)
 *     return composition.mass(average=average, charge=charge, mass_data=mass_data, ion_type=ion_type)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_composition, __pyx_n_s_mass); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_average, __pyx_v_average) < 0) __PYX_ERR(0, 804, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_charge, __pyx_v_charge) < 0) __PYX_ERR(0, 804, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mass_data, __pyx_v_mass_data) < 0) __PYX_ERR(0, 804, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ion_type, __pyx_v_ion_type) < 0) __PYX_ERR(0, 804, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":747
 * Composition = CComposition
 * 
 * def calculate_mass(composition=None, average=False, charge=None, mass_data=None, ion_type=None, **kwargs):             # <<<<<<<<<<<<<<
 *     """Calculates the monoisotopic mass of a polypeptide defined by a
 *     sequence string, parsed sequence, chemical formula or
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyteomics.cmass.calculate_mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_composition);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyteomics/cmass.pyx":810
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * cdef double _calculate_mass(CComposition composition,             # <<<<<<<<<<<<<<
 *                                    int average=False, charge=None, mass_data=None,
 *                                    ion_type=None) except -1:
 */

static double __pyx_f_9pyteomics_5cmass__calculate_mass(struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_composition, struct __pyx_opt_args_9pyteomics_5cmass__calculate_mass *__pyx_optional_args) {

  /* "pyteomics/cmass.pyx":811
 * @cython.boundscheck(False)
 * cdef double _calculate_mass(CComposition composition,
 *                                    int average=False, charge=None, mass_data=None,             # <<<<<<<<<<<<<<
 *                                    ion_type=None) except -1:
 *     """Calculates the monoisotopic mass of a CComposition object.
 */
  int __pyx_v_average = ((int)0);
  PyObject *__pyx_v_charge = ((PyObject *)Py_None);
  PyObject *__pyx_v_mass_data = ((PyObject *)Py_None);

  /* "pyteomics/cmass.pyx":812
 * cdef double _calculate_mass(CComposition composition,
 *                                    int average=False, charge=None, mass_data=None,
 *                                    ion_type=None) except -1:             # <<<<<<<<<<<<<<
 *     """Calculates the monoisotopic mass of a CComposition object.
 * 
 */
  PyObject *__pyx_v_ion_type = ((PyObject *)Py_None);
  int __pyx_v_old_charge;
  int __pyx_v_isotope_num;
  int __pyx_v_isotope;
  int __pyx_v_quantity;
  double __pyx_v_mass;
  double __pyx_v_isotope_mass;
  double __pyx_v_isotope_frequency;
  long __pyx_v__charge;
  PyObject *__pyx_v_isotope_string = 0;
  PyObject *__pyx_v_element_name = 0;
  PyObject *__pyx_v_mass_provider = 0;
  struct __pyx_obj_9pyteomics_5cmass_CComposition *__pyx_v_ion_type_comp = 0;
  PyObject *__pyx_v_key_list = 0;
  PyObject *__pyx_v_interm;
  Py_ssize_t __pyx_v_iter_pos;
  PyObject *__pyx_v_interim;
  double __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  long __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  double __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("_calculate_mass", 0);
  __Pyx_TraceCall("_calculate_mass", __pyx_f[0], 810, 0, __PYX_ERR(0, 810, __pyx_L1_error));
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_average = __pyx_optional_args->average;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_charge = __pyx_optional_args->charge;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_mass_data = __pyx_optional_args->mass_data;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_ion_type = __pyx_optional_args->ion_type;
          }
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_charge);

  /* "pyteomics/cmass.pyx":844
 *         list key_list
 *         PyObject* interm
 *         Py_ssize_t iter_pos = 0             # <<<<<<<<<<<<<<
 * 
 *     if mass_data is None:
 */
  __pyx_v_iter_pos = 0;

  /* "pyteomics/cmass.pyx":846
 *         Py_ssize_t iter_pos = 0
 * 
 *     if mass_data is None:             # <<<<<<<<<<<<<<
 *         mass_provider = nist_mass
 *     else:
 */
  __pyx_t_1 = (__pyx_v_mass_data == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":847
 * 
 *     if mass_data is None:
 *         mass_provider = nist_mass             # <<<<<<<<<<<<<<
 *     else:
 *         mass_provider = mass_data
 */
    __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
    __pyx_v_mass_provider = __pyx_v_9pyteomics_5cmass_nist_mass;

    /* "pyteomics/cmass.pyx":846
 *         Py_ssize_t iter_pos = 0
 * 
 *     if mass_data is None:             # <<<<<<<<<<<<<<
 *         mass_provider = nist_mass
 *     else:
 */
    goto __pyx_L3;
  }

  /* "pyteomics/cmass.pyx":849
 *         mass_provider = nist_mass
 *     else:
 *         mass_provider = mass_data             # <<<<<<<<<<<<<<
 * 
 *     # Get charge.
 */
  /*else*/ {
    if (!(likely(PyDict_CheckExact(__pyx_v_mass_data))||((__pyx_v_mass_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_mass_data)->tp_name), 0))) __PYX_ERR(0, 849, __pyx_L1_error)
    __pyx_t_3 = __pyx_v_mass_data;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_mass_provider = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pyteomics/cmass.pyx":852
 * 
 *     # Get charge.
 *     if charge is None:             # <<<<<<<<<<<<<<
 *         charge = composition.getitem('H+')
 *     else:
 */
  __pyx_t_2 = (__pyx_v_charge == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "pyteomics/cmass.pyx":853
 *     # Get charge.
 *     if charge is None:
 *         charge = composition.getitem('H+')             # <<<<<<<<<<<<<<
 *     else:
 *         if charge != 0 and composition.getitem('H+') != 0:
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_composition, __pyx_kp_s_H_2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_charge, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pyteomics/cmass.pyx":852
 * 
 *     # Get charge.
 *     if charge is None:             # <<<<<<<<<<<<<<
 *         charge = composition.getitem('H+')
 *     else:
 */
    goto __pyx_L4;
  }

  /* "pyteomics/cmass.pyx":855
 *         charge = composition.getitem('H+')
 *     else:
 *         if charge != 0 and composition.getitem('H+') != 0:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError("Charge is specified both by the number of protons and parameters")
 *     _charge = PyInt_AsLong(charge)
 */
  /*else*/ {
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_charge, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 855, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_composition, __pyx_kp_s_H_2) != 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_1) {

      /* "pyteomics/cmass.pyx":856
 *     else:
 *         if charge != 0 and composition.getitem('H+') != 0:
 *             raise PyteomicsError("Charge is specified both by the number of protons and parameters")             # <<<<<<<<<<<<<<
 *     _charge = PyInt_AsLong(charge)
 *     old_charge = composition.getitem('H+')
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 856, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 856, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __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, 856, __pyx_L1_error)

      /* "pyteomics/cmass.pyx":855
 *         charge = composition.getitem('H+')
 *     else:
 *         if charge != 0 and composition.getitem('H+') != 0:             # <<<<<<<<<<<<<<
 *             raise PyteomicsError("Charge is specified both by the number of protons and parameters")
 *     _charge = PyInt_AsLong(charge)
 */
    }
  }
  __pyx_L4:;

  /* "pyteomics/cmass.pyx":857
 *         if charge != 0 and composition.getitem('H+') != 0:
 *             raise PyteomicsError("Charge is specified both by the number of protons and parameters")
 *     _charge = PyInt_AsLong(charge)             # <<<<<<<<<<<<<<
 *     old_charge = composition.getitem('H+')
 *     composition.setitem('H+', charge)
 */
  __pyx_t_5 = PyInt_AsLong(__pyx_v_charge); if (unlikely(__pyx_t_5 == -1L && PyErr_Occurred())) __PYX_ERR(0, 857, __pyx_L1_error)
  __pyx_v__charge = __pyx_t_5;

  /* "pyteomics/cmass.pyx":858
 *             raise PyteomicsError("Charge is specified both by the number of protons and parameters")
 *     _charge = PyInt_AsLong(charge)
 *     old_charge = composition.getitem('H+')             # <<<<<<<<<<<<<<
 *     composition.setitem('H+', charge)
 * 
 */
  __pyx_v_old_charge = __pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_composition, __pyx_kp_s_H_2);

  /* "pyteomics/cmass.pyx":859
 *     _charge = PyInt_AsLong(charge)
 *     old_charge = composition.getitem('H+')
 *     composition.setitem('H+', charge)             # <<<<<<<<<<<<<<
 * 
 *     # Calculate mass.
 */
  __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_charge); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 859, __pyx_L1_error)
  __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_composition, __pyx_kp_s_H_2, __pyx_t_5);

  /* "pyteomics/cmass.pyx":862
 * 
 *     # Calculate mass.
 *     mass = 0.0             # <<<<<<<<<<<<<<
 *     key_list = PyDict_Keys(composition)
 *     for iter_pos in range(len(key_list)):
 */
  __pyx_v_mass = 0.0;

  /* "pyteomics/cmass.pyx":863
 *     # Calculate mass.
 *     mass = 0.0
 *     key_list = PyDict_Keys(composition)             # <<<<<<<<<<<<<<
 *     for iter_pos in range(len(key_list)):
 *         isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)
 */
  __pyx_t_4 = PyDict_Keys(((PyObject *)__pyx_v_composition)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 863, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_key_list = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pyteomics/cmass.pyx":864
 *     mass = 0.0
 *     key_list = PyDict_Keys(composition)
 *     for iter_pos in range(len(key_list)):             # <<<<<<<<<<<<<<
 *         isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)
 *         # element_name, isotope_num = _parse_isotope_string(isotope_string)
 */
  if (unlikely(__pyx_v_key_list == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 864, __pyx_L1_error)
  }
  __pyx_t_6 = PyList_GET_SIZE(__pyx_v_key_list); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 864, __pyx_L1_error)
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_iter_pos = __pyx_t_7;

    /* "pyteomics/cmass.pyx":865
 *     key_list = PyDict_Keys(composition)
 *     for iter_pos in range(len(key_list)):
 *         isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)             # <<<<<<<<<<<<<<
 *         # element_name, isotope_num = _parse_isotope_string(isotope_string)
 *         element_name = _parse_isotope_string(isotope_string, &isotope_num)
 */
    __pyx_t_8 = PyList_GET_ITEM(__pyx_v_key_list, __pyx_v_iter_pos);
    __pyx_t_4 = ((PyObject *)__pyx_t_8);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_isotope_string, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "pyteomics/cmass.pyx":867
 *         isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)
 *         # element_name, isotope_num = _parse_isotope_string(isotope_string)
 *         element_name = _parse_isotope_string(isotope_string, &isotope_num)             # <<<<<<<<<<<<<<
 * 
 *         # Calculate average mass if required and the isotope number is
 */
    __pyx_t_4 = __pyx_f_9pyteomics_5cmass__parse_isotope_string(__pyx_v_isotope_string, (&__pyx_v_isotope_num)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 867, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_element_name, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "pyteomics/cmass.pyx":871
 *         # Calculate average mass if required and the isotope number is
 *         # not specified.
 *         if (not isotope_num) and average:             # <<<<<<<<<<<<<<
 *             for isotope in mass_provider[element_name]:
 *                 if isotope != 0:
 */
    __pyx_t_2 = ((!(__pyx_v_isotope_num != 0)) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_average != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_1) {

      /* "pyteomics/cmass.pyx":872
 *         # not specified.
 *         if (not isotope_num) and average:
 *             for isotope in mass_provider[element_name]:             # <<<<<<<<<<<<<<
 *                 if isotope != 0:
 *                     quantity = <int>composition.getitem(element_name)
 */
      if (unlikely(__pyx_v_mass_provider == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 872, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
        __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
      } else {
        __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 872, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      for (;;) {
        if (likely(!__pyx_t_10)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 872, __pyx_L1_error)
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 872, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          } else {
            if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 872, __pyx_L1_error)
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 872, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          }
        } else {
          __pyx_t_4 = __pyx_t_10(__pyx_t_3);
          if (unlikely(!__pyx_t_4)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 872, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_isotope = __pyx_t_11;

        /* "pyteomics/cmass.pyx":873
 *         if (not isotope_num) and average:
 *             for isotope in mass_provider[element_name]:
 *                 if isotope != 0:             # <<<<<<<<<<<<<<
 *                     quantity = <int>composition.getitem(element_name)
 *                     isotope_mass = <double>mass_provider[element_name][isotope][0]
 */
        __pyx_t_1 = ((__pyx_v_isotope != 0) != 0);
        if (__pyx_t_1) {

          /* "pyteomics/cmass.pyx":874
 *             for isotope in mass_provider[element_name]:
 *                 if isotope != 0:
 *                     quantity = <int>composition.getitem(element_name)             # <<<<<<<<<<<<<<
 *                     isotope_mass = <double>mass_provider[element_name][isotope][0]
 *                     isotope_frequency = <double>mass_provider[element_name][isotope][1]
 */
          __pyx_v_quantity = ((int)__pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_composition, __pyx_v_element_name));

          /* "pyteomics/cmass.pyx":875
 *                 if isotope != 0:
 *                     quantity = <int>composition.getitem(element_name)
 *                     isotope_mass = <double>mass_provider[element_name][isotope][0]             # <<<<<<<<<<<<<<
 *                     isotope_frequency = <double>mass_provider[element_name][isotope][1]
 * 
 */
          if (unlikely(__pyx_v_mass_provider == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 875, __pyx_L1_error)
          }
          __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_isotope, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_12, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_v_isotope_mass = ((double)__pyx_t_13);

          /* "pyteomics/cmass.pyx":876
 *                     quantity = <int>composition.getitem(element_name)
 *                     isotope_mass = <double>mass_provider[element_name][isotope][0]
 *                     isotope_frequency = <double>mass_provider[element_name][isotope][1]             # <<<<<<<<<<<<<<
 * 
 *                     mass += quantity * isotope_mass * isotope_frequency
 */
          if (unlikely(__pyx_v_mass_provider == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 876, __pyx_L1_error)
          }
          __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 876, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_isotope, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 876, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_12, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 876, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 876, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_v_isotope_frequency = ((double)__pyx_t_13);

          /* "pyteomics/cmass.pyx":878
 *                     isotope_frequency = <double>mass_provider[element_name][isotope][1]
 * 
 *                     mass += quantity * isotope_mass * isotope_frequency             # <<<<<<<<<<<<<<
 *         else:
 *             interim = PyDict_GetItem(mass_provider, element_name)
 */
          __pyx_v_mass = (__pyx_v_mass + ((__pyx_v_quantity * __pyx_v_isotope_mass) * __pyx_v_isotope_frequency));

          /* "pyteomics/cmass.pyx":873
 *         if (not isotope_num) and average:
 *             for isotope in mass_provider[element_name]:
 *                 if isotope != 0:             # <<<<<<<<<<<<<<
 *                     quantity = <int>composition.getitem(element_name)
 *                     isotope_mass = <double>mass_provider[element_name][isotope][0]
 */
        }

        /* "pyteomics/cmass.pyx":872
 *         # not specified.
 *         if (not isotope_num) and average:
 *             for isotope in mass_provider[element_name]:             # <<<<<<<<<<<<<<
 *                 if isotope != 0:
 *                     quantity = <int>composition.getitem(element_name)
 */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyteomics/cmass.pyx":871
 *         # Calculate average mass if required and the isotope number is
 *         # not specified.
 *         if (not isotope_num) and average:             # <<<<<<<<<<<<<<
 *             for isotope in mass_provider[element_name]:
 *                 if isotope != 0:
 */
      goto __pyx_L10;
    }

    /* "pyteomics/cmass.pyx":880
 *                     mass += quantity * isotope_mass * isotope_frequency
 *         else:
 *             interim = PyDict_GetItem(mass_provider, element_name)             # <<<<<<<<<<<<<<
 *             interim = PyDict_GetItem(<dict>interim, isotope_num)
 *             isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 */
    /*else*/ {
      __pyx_v_interim = PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name);

      /* "pyteomics/cmass.pyx":881
 *         else:
 *             interim = PyDict_GetItem(mass_provider, element_name)
 *             interim = PyDict_GetItem(<dict>interim, isotope_num)             # <<<<<<<<<<<<<<
 *             isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 * 
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_isotope_num); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_interim = PyDict_GetItem(((PyObject *)__pyx_v_interim), __pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyteomics/cmass.pyx":882
 *             interim = PyDict_GetItem(mass_provider, element_name)
 *             interim = PyDict_GetItem(<dict>interim, isotope_num)
 *             isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))             # <<<<<<<<<<<<<<
 * 
 *             mass += (composition.getitem(isotope_string) * isotope_mass)
 */
      __pyx_t_8 = PyTuple_GetItem(((PyObject *)__pyx_v_interim), 0); if (unlikely(__pyx_t_8 == NULL)) __PYX_ERR(0, 882, __pyx_L1_error)
      __pyx_t_13 = PyFloat_AsDouble(((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_13 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 882, __pyx_L1_error)
      __pyx_v_isotope_mass = __pyx_t_13;

      /* "pyteomics/cmass.pyx":884
 *             isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 * 
 *             mass += (composition.getitem(isotope_string) * isotope_mass)             # <<<<<<<<<<<<<<
 * 
 *     if ion_type is not None:
 */
      __pyx_v_mass = (__pyx_v_mass + (__pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_composition, __pyx_v_isotope_string) * __pyx_v_isotope_mass));
    }
    __pyx_L10:;
  }

  /* "pyteomics/cmass.pyx":886
 *             mass += (composition.getitem(isotope_string) * isotope_mass)
 * 
 *     if ion_type is not None:             # <<<<<<<<<<<<<<
 *         interm = PyDict_GetItem(std_ion_comp, ion_type)
 *         if interm == NULL:
 */
  __pyx_t_1 = (__pyx_v_ion_type != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":887
 * 
 *     if ion_type is not None:
 *         interm = PyDict_GetItem(std_ion_comp, ion_type)             # <<<<<<<<<<<<<<
 *         if interm == NULL:
 *             raise KeyError("Unknown ion_type: {}".format(ion_type))
 */
    __pyx_t_3 = __pyx_v_9pyteomics_5cmass_std_ion_comp;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_interm = PyDict_GetItem(__pyx_t_3, __pyx_v_ion_type);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyteomics/cmass.pyx":888
 *     if ion_type is not None:
 *         interm = PyDict_GetItem(std_ion_comp, ion_type)
 *         if interm == NULL:             # <<<<<<<<<<<<<<
 *             raise KeyError("Unknown ion_type: {}".format(ion_type))
 *         ion_type_comp = <CComposition>interm
 */
    __pyx_t_2 = ((__pyx_v_interm == NULL) != 0);
    if (__pyx_t_2) {

      /* "pyteomics/cmass.pyx":889
 *         interm = PyDict_GetItem(std_ion_comp, ion_type)
 *         if interm == NULL:
 *             raise KeyError("Unknown ion_type: {}".format(ion_type))             # <<<<<<<<<<<<<<
 *         ion_type_comp = <CComposition>interm
 *         key_list = PyDict_Keys(ion_type_comp)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unknown_ion_type_2, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 889, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_12) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_ion_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_ion_type};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_ion_type};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 889, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
          __Pyx_INCREF(__pyx_v_ion_type);
          __Pyx_GIVEREF(__pyx_v_ion_type);
          PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_ion_type);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 889, __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 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __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, 889, __pyx_L1_error)

      /* "pyteomics/cmass.pyx":888
 *     if ion_type is not None:
 *         interm = PyDict_GetItem(std_ion_comp, ion_type)
 *         if interm == NULL:             # <<<<<<<<<<<<<<
 *             raise KeyError("Unknown ion_type: {}".format(ion_type))
 *         ion_type_comp = <CComposition>interm
 */
    }

    /* "pyteomics/cmass.pyx":890
 *         if interm == NULL:
 *             raise KeyError("Unknown ion_type: {}".format(ion_type))
 *         ion_type_comp = <CComposition>interm             # <<<<<<<<<<<<<<
 *         key_list = PyDict_Keys(ion_type_comp)
 *         for iter_pos in range(len(key_list)):
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_interm);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_ion_type_comp = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pyteomics/cmass.pyx":891
 *             raise KeyError("Unknown ion_type: {}".format(ion_type))
 *         ion_type_comp = <CComposition>interm
 *         key_list = PyDict_Keys(ion_type_comp)             # <<<<<<<<<<<<<<
 *         for iter_pos in range(len(key_list)):
 *             isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)
 */
    __pyx_t_3 = PyDict_Keys(((PyObject *)__pyx_v_ion_type_comp)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_key_list, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "pyteomics/cmass.pyx":892
 *         ion_type_comp = <CComposition>interm
 *         key_list = PyDict_Keys(ion_type_comp)
 *         for iter_pos in range(len(key_list)):             # <<<<<<<<<<<<<<
 *             isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)
 *             element_name = _parse_isotope_string(isotope_string, &isotope_num)
 */
    if (unlikely(__pyx_v_key_list == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 892, __pyx_L1_error)
    }
    __pyx_t_6 = PyList_GET_SIZE(__pyx_v_key_list); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 892, __pyx_L1_error)
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_iter_pos = __pyx_t_7;

      /* "pyteomics/cmass.pyx":893
 *         key_list = PyDict_Keys(ion_type_comp)
 *         for iter_pos in range(len(key_list)):
 *             isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)             # <<<<<<<<<<<<<<
 *             element_name = _parse_isotope_string(isotope_string, &isotope_num)
 * 
 */
      __pyx_t_8 = PyList_GET_ITEM(__pyx_v_key_list, __pyx_v_iter_pos);
      __pyx_t_3 = ((PyObject *)__pyx_t_8);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_isotope_string, ((PyObject*)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "pyteomics/cmass.pyx":894
 *         for iter_pos in range(len(key_list)):
 *             isotope_string = <str>PyList_GET_ITEM(key_list, iter_pos)
 *             element_name = _parse_isotope_string(isotope_string, &isotope_num)             # <<<<<<<<<<<<<<
 * 
 *             # Calculate average mass if required and the isotope number is
 */
      __pyx_t_3 = __pyx_f_9pyteomics_5cmass__parse_isotope_string(__pyx_v_isotope_string, (&__pyx_v_isotope_num)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 894, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_element_name, ((PyObject*)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "pyteomics/cmass.pyx":898
 *             # Calculate average mass if required and the isotope number is
 *             # not specified.
 *             if (not isotope_num) and average:             # <<<<<<<<<<<<<<
 *                 for isotope in mass_provider[element_name]:
 *                     if isotope != 0:
 */
      __pyx_t_1 = ((!(__pyx_v_isotope_num != 0)) != 0);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L21_bool_binop_done;
      }
      __pyx_t_1 = (__pyx_v_average != 0);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L21_bool_binop_done:;
      if (__pyx_t_2) {

        /* "pyteomics/cmass.pyx":899
 *             # not specified.
 *             if (not isotope_num) and average:
 *                 for isotope in mass_provider[element_name]:             # <<<<<<<<<<<<<<
 *                     if isotope != 0:
 *                         quantity = ion_type_comp.getitem(element_name)
 */
        if (unlikely(__pyx_v_mass_provider == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 899, __pyx_L1_error)
        }
        __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
          __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0;
          __pyx_t_10 = NULL;
        } else {
          __pyx_t_9 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 899, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 899, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        for (;;) {
          if (likely(!__pyx_t_10)) {
            if (likely(PyList_CheckExact(__pyx_t_4))) {
              if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 899, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            } else {
              if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 899, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            }
          } else {
            __pyx_t_3 = __pyx_t_10(__pyx_t_4);
            if (unlikely(!__pyx_t_3)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 899, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 899, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_isotope = __pyx_t_11;

          /* "pyteomics/cmass.pyx":900
 *             if (not isotope_num) and average:
 *                 for isotope in mass_provider[element_name]:
 *                     if isotope != 0:             # <<<<<<<<<<<<<<
 *                         quantity = ion_type_comp.getitem(element_name)
 *                         isotope_mass = <double>mass_provider[element_name][isotope][0]
 */
          __pyx_t_2 = ((__pyx_v_isotope != 0) != 0);
          if (__pyx_t_2) {

            /* "pyteomics/cmass.pyx":901
 *                 for isotope in mass_provider[element_name]:
 *                     if isotope != 0:
 *                         quantity = ion_type_comp.getitem(element_name)             # <<<<<<<<<<<<<<
 *                         isotope_mass = <double>mass_provider[element_name][isotope][0]
 *                         isotope_frequency = <double>mass_provider[element_name][isotope][1]
 */
            __pyx_v_quantity = __pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_ion_type_comp, __pyx_v_element_name);

            /* "pyteomics/cmass.pyx":902
 *                     if isotope != 0:
 *                         quantity = ion_type_comp.getitem(element_name)
 *                         isotope_mass = <double>mass_provider[element_name][isotope][0]             # <<<<<<<<<<<<<<
 *                         isotope_frequency = <double>mass_provider[element_name][isotope][1]
 * 
 */
            if (unlikely(__pyx_v_mass_provider == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              __PYX_ERR(0, 902, __pyx_L1_error)
            }
            __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 902, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_14 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_isotope, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 902, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_14, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 902, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 902, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_v_isotope_mass = ((double)__pyx_t_13);

            /* "pyteomics/cmass.pyx":903
 *                         quantity = ion_type_comp.getitem(element_name)
 *                         isotope_mass = <double>mass_provider[element_name][isotope][0]
 *                         isotope_frequency = <double>mass_provider[element_name][isotope][1]             # <<<<<<<<<<<<<<
 * 
 *                         mass += quantity * isotope_mass * isotope_frequency
 */
            if (unlikely(__pyx_v_mass_provider == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              __PYX_ERR(0, 903, __pyx_L1_error)
            }
            __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 903, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_14 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_isotope, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 903, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_14, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 903, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 903, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_v_isotope_frequency = ((double)__pyx_t_13);

            /* "pyteomics/cmass.pyx":905
 *                         isotope_frequency = <double>mass_provider[element_name][isotope][1]
 * 
 *                         mass += quantity * isotope_mass * isotope_frequency             # <<<<<<<<<<<<<<
 *             else:
 *                 interim = PyDict_GetItem(mass_provider, element_name)
 */
            __pyx_v_mass = (__pyx_v_mass + ((__pyx_v_quantity * __pyx_v_isotope_mass) * __pyx_v_isotope_frequency));

            /* "pyteomics/cmass.pyx":900
 *             if (not isotope_num) and average:
 *                 for isotope in mass_provider[element_name]:
 *                     if isotope != 0:             # <<<<<<<<<<<<<<
 *                         quantity = ion_type_comp.getitem(element_name)
 *                         isotope_mass = <double>mass_provider[element_name][isotope][0]
 */
          }

          /* "pyteomics/cmass.pyx":899
 *             # not specified.
 *             if (not isotope_num) and average:
 *                 for isotope in mass_provider[element_name]:             # <<<<<<<<<<<<<<
 *                     if isotope != 0:
 *                         quantity = ion_type_comp.getitem(element_name)
 */
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pyteomics/cmass.pyx":898
 *             # Calculate average mass if required and the isotope number is
 *             # not specified.
 *             if (not isotope_num) and average:             # <<<<<<<<<<<<<<
 *                 for isotope in mass_provider[element_name]:
 *                     if isotope != 0:
 */
        goto __pyx_L20;
      }

      /* "pyteomics/cmass.pyx":907
 *                         mass += quantity * isotope_mass * isotope_frequency
 *             else:
 *                 interim = PyDict_GetItem(mass_provider, element_name)             # <<<<<<<<<<<<<<
 *                 interim = PyDict_GetItem(<dict>interim, isotope_num)
 *                 isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 */
      /*else*/ {
        __pyx_v_interim = PyDict_GetItem(__pyx_v_mass_provider, __pyx_v_element_name);

        /* "pyteomics/cmass.pyx":908
 *             else:
 *                 interim = PyDict_GetItem(mass_provider, element_name)
 *                 interim = PyDict_GetItem(<dict>interim, isotope_num)             # <<<<<<<<<<<<<<
 *                 isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 * 
 */
        __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_isotope_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 908, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_v_interim = PyDict_GetItem(((PyObject *)__pyx_v_interim), __pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pyteomics/cmass.pyx":909
 *                 interim = PyDict_GetItem(mass_provider, element_name)
 *                 interim = PyDict_GetItem(<dict>interim, isotope_num)
 *                 isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))             # <<<<<<<<<<<<<<
 * 
 *                 mass += (ion_type_comp.getitem(isotope_string) * isotope_mass)
 */
        __pyx_t_8 = PyTuple_GetItem(((PyObject *)__pyx_v_interim), 0); if (unlikely(__pyx_t_8 == NULL)) __PYX_ERR(0, 909, __pyx_L1_error)
        __pyx_t_13 = PyFloat_AsDouble(((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_13 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 909, __pyx_L1_error)
        __pyx_v_isotope_mass = __pyx_t_13;

        /* "pyteomics/cmass.pyx":911
 *                 isotope_mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 * 
 *                 mass += (ion_type_comp.getitem(isotope_string) * isotope_mass)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_v_mass = (__pyx_v_mass + (__pyx_f_9pyteomics_5cmass_12CComposition_getitem(__pyx_v_ion_type_comp, __pyx_v_isotope_string) * __pyx_v_isotope_mass));
      }
      __pyx_L20:;
    }

    /* "pyteomics/cmass.pyx":886
 *             mass += (composition.getitem(isotope_string) * isotope_mass)
 * 
 *     if ion_type is not None:             # <<<<<<<<<<<<<<
 *         interm = PyDict_GetItem(std_ion_comp, ion_type)
 *         if interm == NULL:
 */
  }

  /* "pyteomics/cmass.pyx":915
 * 
 *     # Calculate m/z if required.
 *     if _charge != 0:             # <<<<<<<<<<<<<<
 *         mass /= abs(_charge)
 * 
 */
  __pyx_t_2 = ((__pyx_v__charge != 0) != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":916
 *     # Calculate m/z if required.
 *     if _charge != 0:
 *         mass /= abs(_charge)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_5 = labs(__pyx_v__charge); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 916, __pyx_L1_error)
    if (unlikely(__pyx_t_5 == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 916, __pyx_L1_error)
    }
    __pyx_v_mass = (__pyx_v_mass / __pyx_t_5);

    /* "pyteomics/cmass.pyx":915
 * 
 *     # Calculate m/z if required.
 *     if _charge != 0:             # <<<<<<<<<<<<<<
 *         mass /= abs(_charge)
 * 
 */
  }

  /* "pyteomics/cmass.pyx":919
 * 
 * 
 *     if old_charge != 0:             # <<<<<<<<<<<<<<
 *         composition.setitem('H+', old_charge)
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_old_charge != 0) != 0);
  if (__pyx_t_2) {

    /* "pyteomics/cmass.pyx":920
 * 
 *     if old_charge != 0:
 *         composition.setitem('H+', old_charge)             # <<<<<<<<<<<<<<
 *     else:
 *         PyDict_DelItem(composition, "H+")
 */
    __pyx_f_9pyteomics_5cmass_12CComposition_setitem(__pyx_v_composition, __pyx_kp_s_H_2, __pyx_v_old_charge);

    /* "pyteomics/cmass.pyx":919
 * 
 * 
 *     if old_charge != 0:             # <<<<<<<<<<<<<<
 *         composition.setitem('H+', old_charge)
 *     else:
 */
    goto __pyx_L27;
  }

  /* "pyteomics/cmass.pyx":922
 *         composition.setitem('H+', old_charge)
 *     else:
 *         PyDict_DelItem(composition, "H+")             # <<<<<<<<<<<<<<
 * 
 *     return mass
 */
  /*else*/ {
    __pyx_t_11 = PyDict_DelItem(((PyObject *)__pyx_v_composition), __pyx_kp_s_H_2); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 922, __pyx_L1_error)
  }
  __pyx_L27:;

  /* "pyteomics/cmass.pyx":924
 *         PyDict_DelItem(composition, "H+")
 * 
 *     return mass             # <<<<<<<<<<<<<<
 * 
 * Composition = CComposition
 */
  __pyx_r = __pyx_v_mass;
  goto __pyx_L0;

  /* "pyteomics/cmass.pyx":810
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * cdef double _calculate_mass(CComposition composition,             # <<<<<<<<<<<<<<
 *                                    int average=False, charge=None, mass_data=None,
 *                                    ion_type=None) except -1:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("pyteomics.cmass._calculate_mass", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1.0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_isotope_string);
  __Pyx_XDECREF(__pyx_v_element_name);
  __Pyx_XDECREF(__pyx_v_mass_provider);
  __Pyx_XDECREF((PyObject *)__pyx_v_ion_type_comp);
  __Pyx_XDECREF(__pyx_v_key_list);
  __Pyx_XDECREF(__pyx_v_charge);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_9pyteomics_5cmass_CComposition __pyx_vtable_9pyteomics_5cmass_CComposition;

static PyObject *__pyx_tp_new_9pyteomics_5cmass_CComposition(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9pyteomics_5cmass_CComposition *p;
  PyObject *o = (&PyDict_Type)->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyteomics_5cmass_CComposition *)o);
  p->__pyx_vtab = __pyx_vtabptr_9pyteomics_5cmass_CComposition;
  p->_mass = Py_None; Py_INCREF(Py_None);
  p->_mass_args = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9pyteomics_5cmass_CComposition(PyObject *o) {
  struct __pyx_obj_9pyteomics_5cmass_CComposition *p = (struct __pyx_obj_9pyteomics_5cmass_CComposition *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_mass);
  Py_CLEAR(p->_mass_args);
  PyObject_GC_Track(o);
  (&PyDict_Type)->tp_dealloc(o);
}

static int __pyx_tp_traverse_9pyteomics_5cmass_CComposition(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyteomics_5cmass_CComposition *p = (struct __pyx_obj_9pyteomics_5cmass_CComposition *)o;
  if (!(&PyDict_Type)->tp_traverse); else { e = (&PyDict_Type)->tp_traverse(o,v,a); if (e) return e; }
  if (p->_mass) {
    e = (*v)(p->_mass, a); if (e) return e;
  }
  if (p->_mass_args) {
    e = (*v)(p->_mass_args, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyteomics_5cmass_CComposition(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyteomics_5cmass_CComposition *p = (struct __pyx_obj_9pyteomics_5cmass_CComposition *)o;
  if (!(&PyDict_Type)->tp_clear); else (&PyDict_Type)->tp_clear(o);
  tmp = ((PyObject*)p->_mass);
  p->_mass = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_mass_args);
  p->_mass_args = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static int __pyx_mp_ass_subscript_9pyteomics_5cmass_CComposition(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_9pyteomics_5cmass_12CComposition_33__setitem__(o, i, v);
  }
  else {
    if ((&PyDict_Type)->tp_as_mapping && (&PyDict_Type)->tp_as_mapping->mp_ass_subscript)
      return (&PyDict_Type)->tp_as_mapping->mp_ass_subscript(o, i, v);
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyMethodDef __pyx_methods_9pyteomics_5cmass_CComposition[] = {
  {"_from_parsed_sequence", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_1_from_parsed_sequence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_12CComposition__from_parsed_sequence},
  {"_from_split_sequence", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_3_from_split_sequence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_12CComposition_2_from_split_sequence},
  {"_from_sequence", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_5_from_sequence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_12CComposition_4_from_sequence},
  {"__reduce__", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_19__reduce__, METH_NOARGS, __pyx_doc_9pyteomics_5cmass_12CComposition_18__reduce__},
  {"__getstate__", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_21__getstate__, METH_NOARGS, __pyx_doc_9pyteomics_5cmass_12CComposition_20__getstate__},
  {"__setstate__", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_23__setstate__, METH_O, __pyx_doc_9pyteomics_5cmass_12CComposition_22__setstate__},
  {"__missing__", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_31__missing__, METH_O, __pyx_doc_9pyteomics_5cmass_12CComposition_30__missing__},
  {"copy", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_35copy, METH_NOARGS, __pyx_doc_9pyteomics_5cmass_12CComposition_34copy},
  {"clone", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_37clone, METH_NOARGS, __pyx_doc_9pyteomics_5cmass_12CComposition_36clone},
  {"update", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_39update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_12CComposition_38update},
  {"_from_formula", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_41_from_formula, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_12CComposition_40_from_formula},
  {"_from_formula_parens", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_43_from_formula_parens, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_12CComposition_42_from_formula_parens},
  {"_from_dict", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_45_from_dict, METH_O, __pyx_doc_9pyteomics_5cmass_12CComposition_44_from_dict},
  {"mass", (PyCFunction)__pyx_pw_9pyteomics_5cmass_12CComposition_47mass, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_12CComposition_46mass},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CComposition = {
  __pyx_pw_9pyteomics_5cmass_12CComposition_13__add__, /*nb_add*/
  __pyx_pw_9pyteomics_5cmass_12CComposition_17__sub__, /*nb_subtract*/
  __pyx_pw_9pyteomics_5cmass_12CComposition_25__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  __pyx_pw_9pyteomics_5cmass_12CComposition_29__neg__, /*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 && PY_VERSION_HEX < 0x03050000)
  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 && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  __pyx_pw_9pyteomics_5cmass_12CComposition_11__iadd__, /*nb_inplace_add*/
  __pyx_pw_9pyteomics_5cmass_12CComposition_15__isub__, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  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 PyMappingMethods __pyx_tp_as_mapping_CComposition = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  __pyx_mp_ass_subscript_9pyteomics_5cmass_CComposition, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_9pyteomics_5cmass_CComposition = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyteomics.cmass.CComposition", /*tp_name*/
  sizeof(struct __pyx_obj_9pyteomics_5cmass_CComposition), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyteomics_5cmass_CComposition, /*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_9pyteomics_5cmass_12CComposition_9__repr__, /*tp_repr*/
  &__pyx_tp_as_number_CComposition, /*tp_as_number*/
  0, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CComposition, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyteomics_5cmass_12CComposition_7__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*/
  "CComposition(*args, **kwargs)\n\n    A Composition object stores a chemical composition of a\n    substance. Basically it is a dict object, in which keys are the names\n    of chemical elements and values contain integer numbers of\n    corresponding atoms in a substance.\n\n    The main improvement over dict is that Composition objects allow\n    addition and subtraction.\n\n    If ``formula`` is not specified, the constructor will look at the first\n    positional argument and try to build the object from it. Without\n    positional arguments, a Composition will be constructed directly from\n    keyword arguments.\n\n    Parameters\n    ----------\n    formula : str, optional\n        A string with a chemical formula. All elements must be present in\n        `mass_data`.\n    mass_data : dict, optional\n        A dict with the masses of chemical elements (the default\n        value is :py:data:`nist_mass`). It is used for formulae parsing only.\n    ", /*tp_doc*/
  __pyx_tp_traverse_9pyteomics_5cmass_CComposition, /*tp_traverse*/
  __pyx_tp_clear_9pyteomics_5cmass_CComposition, /*tp_clear*/
  __pyx_pw_9pyteomics_5cmass_12CComposition_27__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyteomics_5cmass_CComposition, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyteomics_5cmass_12CComposition_49__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyteomics_5cmass_CComposition, /*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[] = {
  {"fast_mass", (PyCFunction)__pyx_pw_9pyteomics_5cmass_3fast_mass, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_2fast_mass},
  {"fast_mass2", (PyCFunction)__pyx_pw_9pyteomics_5cmass_5fast_mass2, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyteomics_5cmass_4fast_mass2},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_cmass(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_cmass},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "cmass",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_A_Z_a_z_d, __pyx_k_A_Z_a_z_d, sizeof(__pyx_k_A_Z_a_z_d), 0, 0, 1, 0},
  {&__pyx_kp_s_A_Z_a_z_d_d, __pyx_k_A_Z_a_z_d_d, sizeof(__pyx_k_A_Z_a_z_d_d), 0, 0, 1, 0},
  {&__pyx_kp_s_An_error_occurred_in_cmass_fast, __pyx_k_An_error_occurred_in_cmass_fast, sizeof(__pyx_k_An_error_occurred_in_cmass_fast), 0, 0, 1, 0},
  {&__pyx_kp_s_An_error_occurred_in_cmass_fast_2, __pyx_k_An_error_occurred_in_cmass_fast_2, sizeof(__pyx_k_An_error_occurred_in_cmass_fast_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Badly_formed_isotope_number_s, __pyx_k_Badly_formed_isotope_number_s, sizeof(__pyx_k_Badly_formed_isotope_number_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Badly_formed_number_of_atoms_s, __pyx_k_Badly_formed_number_of_atoms_s, sizeof(__pyx_k_Badly_formed_number_of_atoms_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_multiply_Composition_by_n, __pyx_k_Cannot_multiply_Composition_by_n, sizeof(__pyx_k_Cannot_multiply_Composition_by_n), 0, 0, 1, 0},
  {&__pyx_kp_s_Charge_is_specified_both_by_the, __pyx_k_Charge_is_specified_both_by_the, sizeof(__pyx_k_Charge_is_specified_both_by_the), 0, 0, 1, 0},
  {&__pyx_kp_s_Composition, __pyx_k_Composition, sizeof(__pyx_k_Composition), 0, 0, 1, 0},
  {&__pyx_n_s_Composition_2, __pyx_k_Composition_2, sizeof(__pyx_k_Composition_2), 0, 0, 1, 1},
  {&__pyx_kp_s_Could_not_create_a_Composition_o, __pyx_k_Could_not_create_a_Composition_o, sizeof(__pyx_k_Could_not_create_a_Composition_o), 0, 0, 1, 0},
  {&__pyx_kp_s_Could_not_create_a_Composition_o_2, __pyx_k_Could_not_create_a_Composition_o_2, sizeof(__pyx_k_Could_not_create_a_Composition_o_2), 0, 0, 1, 0},
  {&__pyx_n_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 1},
  {&__pyx_kp_s_H_2, __pyx_k_H_2, sizeof(__pyx_k_H_2), 0, 0, 1, 0},
  {&__pyx_kp_s_H_3, __pyx_k_H_3, sizeof(__pyx_k_H_3), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_formula, __pyx_k_Invalid_formula, sizeof(__pyx_k_Invalid_formula), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_group_starting_from_posi, __pyx_k_Invalid_group_starting_from_posi, sizeof(__pyx_k_Invalid_group_starting_from_posi), 0, 0, 1, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_kp_s_Mass_not_specified_for_label_s, __pyx_k_Mass_not_specified_for_label_s, sizeof(__pyx_k_Mass_not_specified_for_label_s), 0, 0, 1, 0},
  {&__pyx_kp_s_No_information_for_s_in_aa_comp, __pyx_k_No_information_for_s_in_aa_comp, sizeof(__pyx_k_No_information_for_s_in_aa_comp), 0, 0, 1, 0},
  {&__pyx_kp_s_No_mass_data_for_residue_r, __pyx_k_No_mass_data_for_residue_r, sizeof(__pyx_k_No_mass_data_for_residue_r), 0, 0, 1, 0},
  {&__pyx_n_s_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1},
  {&__pyx_n_s_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 1, 1},
  {&__pyx_kp_s_OH, __pyx_k_OH, sizeof(__pyx_k_OH), 0, 0, 1, 0},
  {&__pyx_kp_s_Only_one_of_can_be_specified_Giv, __pyx_k_Only_one_of_can_be_specified_Giv, sizeof(__pyx_k_Only_one_of_can_be_specified_Giv), 0, 0, 1, 0},
  {&__pyx_n_s_PyteomicsError, __pyx_k_PyteomicsError, sizeof(__pyx_k_PyteomicsError), 0, 0, 1, 1},
  {&__pyx_kp_s_Unknown_chemical_element, __pyx_k_Unknown_chemical_element, sizeof(__pyx_k_Unknown_chemical_element), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_chemical_element_in_the, __pyx_k_Unknown_chemical_element_in_the, sizeof(__pyx_k_Unknown_chemical_element_in_the), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_ion_type, __pyx_k_Unknown_ion_type, sizeof(__pyx_k_Unknown_ion_type), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_ion_type_2, __pyx_k_Unknown_ion_type_2, sizeof(__pyx_k_Unknown_ion_type_2), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 0, 1, 0},
  {&__pyx_kp_s__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 0, 1, 0},
  {&__pyx_kp_s__14, __pyx_k__14, sizeof(__pyx_k__14), 0, 0, 1, 0},
  {&__pyx_kp_s__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 0, 1, 0},
  {&__pyx_kp_s__17, __pyx_k__17, sizeof(__pyx_k__17), 0, 0, 1, 0},
  {&__pyx_kp_s__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 0, 1, 0},
  {&__pyx_kp_s__19, __pyx_k__19, sizeof(__pyx_k__19), 0, 0, 1, 0},
  {&__pyx_kp_s__25, __pyx_k__25, sizeof(__pyx_k__25), 0, 0, 1, 0},
  {&__pyx_n_s_aa_comp, __pyx_k_aa_comp, sizeof(__pyx_k_aa_comp), 0, 0, 1, 1},
  {&__pyx_n_s_aa_mass, __pyx_k_aa_mass, sizeof(__pyx_k_aa_mass), 0, 0, 1, 1},
  {&__pyx_n_s_allow_unknown_modifications, __pyx_k_allow_unknown_modifications, sizeof(__pyx_k_allow_unknown_modifications), 0, 0, 1, 1},
  {&__pyx_n_s_amino_acid_composition, __pyx_k_amino_acid_composition, sizeof(__pyx_k_amino_acid_composition), 0, 0, 1, 1},
  {&__pyx_n_s_atom, __pyx_k_atom, sizeof(__pyx_k_atom), 0, 0, 1, 1},
  {&__pyx_n_s_average, __pyx_k_average, sizeof(__pyx_k_average), 0, 0, 1, 1},
  {&__pyx_n_s_calculate_mass, __pyx_k_calculate_mass, sizeof(__pyx_k_calculate_mass), 0, 0, 1, 1},
  {&__pyx_n_s_chain, __pyx_k_chain, sizeof(__pyx_k_chain), 0, 0, 1, 1},
  {&__pyx_n_s_charge, __pyx_k_charge, sizeof(__pyx_k_charge), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_clone, __pyx_k_clone, sizeof(__pyx_k_clone), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
  {&__pyx_n_s_composition, __pyx_k_composition, sizeof(__pyx_k_composition), 0, 0, 1, 1},
  {&__pyx_n_s_cparser, __pyx_k_cparser, sizeof(__pyx_k_cparser), 0, 0, 1, 1},
  {&__pyx_n_s_defaultdict, __pyx_k_defaultdict, sizeof(__pyx_k_defaultdict), 0, 0, 1, 1},
  {&__pyx_n_s_difference, __pyx_k_difference, sizeof(__pyx_k_difference), 0, 0, 1, 1},
  {&__pyx_n_s_endswith, __pyx_k_endswith, sizeof(__pyx_k_endswith), 0, 0, 1, 1},
  {&__pyx_n_s_findall, __pyx_k_findall, sizeof(__pyx_k_findall), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_formula, __pyx_k_formula, sizeof(__pyx_k_formula), 0, 0, 1, 1},
  {&__pyx_n_s_formula_2, __pyx_k_formula_2, sizeof(__pyx_k_formula_2), 0, 0, 1, 1},
  {&__pyx_n_s_formula_pattern, __pyx_k_formula_pattern, sizeof(__pyx_k_formula_pattern), 0, 0, 1, 1},
  {&__pyx_n_s_from, __pyx_k_from, sizeof(__pyx_k_from), 0, 0, 1, 1},
  {&__pyx_n_s_from_dict, __pyx_k_from_dict, sizeof(__pyx_k_from_dict), 0, 0, 1, 1},
  {&__pyx_n_s_from_formula, __pyx_k_from_formula, sizeof(__pyx_k_from_formula), 0, 0, 1, 1},
  {&__pyx_n_s_from_formula_parens, __pyx_k_from_formula_parens, sizeof(__pyx_k_from_formula_parens), 0, 0, 1, 1},
  {&__pyx_n_s_from_parsed_sequence, __pyx_k_from_parsed_sequence, sizeof(__pyx_k_from_parsed_sequence), 0, 0, 1, 1},
  {&__pyx_n_s_from_sequence, __pyx_k_from_sequence, sizeof(__pyx_k_from_sequence), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_constants, __pyx_k_get_constants, sizeof(__pyx_k_get_constants), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1},
  {&__pyx_n_s_ion_comp, __pyx_k_ion_comp, sizeof(__pyx_k_ion_comp), 0, 0, 1, 1},
  {&__pyx_n_s_ion_type, __pyx_k_ion_type, sizeof(__pyx_k_ion_type), 0, 0, 1, 1},
  {&__pyx_n_s_isdigit, __pyx_k_isdigit, sizeof(__pyx_k_isdigit), 0, 0, 1, 1},
  {&__pyx_n_s_isotope_pattern, __pyx_k_isotope_pattern, sizeof(__pyx_k_isotope_pattern), 0, 0, 1, 1},
  {&__pyx_n_s_isotope_string, __pyx_k_isotope_string, sizeof(__pyx_k_isotope_string), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_itertools, __pyx_k_itertools, sizeof(__pyx_k_itertools), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_n_s_labels, __pyx_k_labels, sizeof(__pyx_k_labels), 0, 0, 1, 1},
  {&__pyx_n_s_len, __pyx_k_len, sizeof(__pyx_k_len), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_marshal_ccomposition, __pyx_k_marshal_ccomposition, sizeof(__pyx_k_marshal_ccomposition), 0, 0, 1, 1},
  {&__pyx_n_s_mass, __pyx_k_mass, sizeof(__pyx_k_mass), 0, 0, 1, 1},
  {&__pyx_n_s_mass_data, __pyx_k_mass_data, sizeof(__pyx_k_mass_data), 0, 0, 1, 1},
  {&__pyx_n_s_match, __pyx_k_match, sizeof(__pyx_k_match), 0, 0, 1, 1},
  {&__pyx_n_s_nist_mass, __pyx_k_nist_mass, sizeof(__pyx_k_nist_mass), 0, 0, 1, 1},
  {&__pyx_n_s_parse, __pyx_k_parse, sizeof(__pyx_k_parse), 0, 0, 1, 1},
  {&__pyx_n_s_parsed_sequence, __pyx_k_parsed_sequence, sizeof(__pyx_k_parsed_sequence), 0, 0, 1, 1},
  {&__pyx_n_s_pyteomics, __pyx_k_pyteomics, sizeof(__pyx_k_pyteomics), 0, 0, 1, 1},
  {&__pyx_n_s_pyteomics_auxiliary, __pyx_k_pyteomics_auxiliary, sizeof(__pyx_k_pyteomics_auxiliary), 0, 0, 1, 1},
  {&__pyx_n_s_pyteomics_cmass, __pyx_k_pyteomics_cmass, sizeof(__pyx_k_pyteomics_cmass), 0, 0, 1, 1},
  {&__pyx_kp_s_pyteomics_cmass_pyx, __pyx_k_pyteomics_cmass_pyx, sizeof(__pyx_k_pyteomics_cmass_pyx), 0, 0, 1, 0},
  {&__pyx_n_s_pyteomics_mass, __pyx_k_pyteomics_mass, sizeof(__pyx_k_pyteomics_mass), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
  {&__pyx_n_s_repr, __pyx_k_repr, sizeof(__pyx_k_repr), 0, 0, 1, 1},
  {&__pyx_n_s_reverse, __pyx_k_reverse, sizeof(__pyx_k_reverse), 0, 0, 1, 1},
  {&__pyx_n_s_rfind, __pyx_k_rfind, sizeof(__pyx_k_rfind), 0, 0, 1, 1},
  {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1},
  {&__pyx_kp_s_s_d, __pyx_k_s_d, sizeof(__pyx_k_s_d), 0, 0, 1, 0},
  {&__pyx_n_s_sequence, __pyx_k_sequence, sizeof(__pyx_k_sequence), 0, 0, 1, 1},
  {&__pyx_n_s_show_unmodified_termini, __pyx_k_show_unmodified_termini, sizeof(__pyx_k_show_unmodified_termini), 0, 0, 1, 1},
  {&__pyx_n_s_sorted, __pyx_k_sorted, sizeof(__pyx_k_sorted), 0, 0, 1, 1},
  {&__pyx_n_s_split_label, __pyx_k_split_label, sizeof(__pyx_k_split_label), 0, 0, 1, 1},
  {&__pyx_n_s_split_sequence, __pyx_k_split_sequence, sizeof(__pyx_k_split_sequence), 0, 0, 1, 1},
  {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1},
  {&__pyx_n_s_std_aa_comp, __pyx_k_std_aa_comp, sizeof(__pyx_k_std_aa_comp), 0, 0, 1, 1},
  {&__pyx_n_s_std_aa_comp_2, __pyx_k_std_aa_comp_2, sizeof(__pyx_k_std_aa_comp_2), 0, 0, 1, 1},
  {&__pyx_n_s_std_aa_mass, __pyx_k_std_aa_mass, sizeof(__pyx_k_std_aa_mass), 0, 0, 1, 1},
  {&__pyx_n_s_std_aa_mass_2, __pyx_k_std_aa_mass_2, sizeof(__pyx_k_std_aa_mass_2), 0, 0, 1, 1},
  {&__pyx_n_s_std_ion_comp, __pyx_k_std_ion_comp, sizeof(__pyx_k_std_ion_comp), 0, 0, 1, 1},
  {&__pyx_n_s_std_ion_comp_2, __pyx_k_std_ion_comp_2, sizeof(__pyx_k_std_ion_comp_2), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_tostring, __pyx_k_tostring, sizeof(__pyx_k_tostring), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 70, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 121, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 507, __pyx_L1_error)
  __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s_round); if (!__pyx_builtin_round) __PYX_ERR(0, 518, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 603, __pyx_L1_error)
  __pyx_builtin_sorted = __Pyx_GetBuiltinName(__pyx_n_s_sorted); if (!__pyx_builtin_sorted) __PYX_ERR(0, 626, __pyx_L1_error)
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 682, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "pyteomics/cmass.pyx":73
 *     interim = PyDict_GetItem(<dict>interim, 0)
 *     if interim == NULL:
 *         raise KeyError(0)             # <<<<<<<<<<<<<<
 *     mass = PyFloat_AsDouble(<object>PyTuple_GetItem(<tuple>interim, 0))
 *     return mass
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "pyteomics/cmass.pyx":129
 *     pvalue = PyErr_Occurred()
 *     if pvalue != NULL:
 *         raise (<object>pvalue)("An error occurred in cmass.fast_mass")             # <<<<<<<<<<<<<<
 *     mass += get_mass(mass_data, 'H') * 2 + get_mass(mass_data, 'O')
 * 
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_An_error_occurred_in_cmass_fast); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "pyteomics/cmass.pyx":142
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")             # <<<<<<<<<<<<<<
 * 
 *     if charge:
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_An_error_occurred_in_cmass_fast); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "pyteomics/cmass.pyx":244
 *         pvalue = PyErr_Occurred()
 *         if pvalue != NULL:
 *             raise (<object>pvalue)("An error occurred in cmass.fast_mass")             # <<<<<<<<<<<<<<
 * 
 *     if charge:
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_An_error_occurred_in_cmass_fast); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "pyteomics/cmass.pyx":650
 *                                              # Omit the last character, then reverse the parse
 *                                              # stack string.
 *                                              formula=parse_stack[:-1][::-1],             # <<<<<<<<<<<<<<
 *                                              mass_data=mass_data)
 *                                              * group_coef)
 */
  __pyx_slice__20 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(0, 650, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__20);
  __Pyx_GIVEREF(__pyx_slice__20);
  __pyx_slice__21 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__21)) __PYX_ERR(0, 650, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__21);
  __Pyx_GIVEREF(__pyx_slice__21);

  /* "pyteomics/cmass.pyx":856
 *     else:
 *         if charge != 0 and composition.getitem('H+') != 0:
 *             raise PyteomicsError("Charge is specified both by the number of protons and parameters")             # <<<<<<<<<<<<<<
 *     _charge = PyInt_AsLong(charge)
 *     old_charge = composition.getitem('H+')
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_Charge_is_specified_both_by_the); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 856, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "pyteomics/cmass.pyx":49
 * 
 * 
 * def __get_constants():             # <<<<<<<<<<<<<<
 *     return nist_mass, std_aa_mass, std_ion_comp, std_aa_comp
 * 
 */
  __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyteomics_cmass_pyx, __pyx_n_s_get_constants, 49, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 49, __pyx_L1_error)

  /* "pyteomics/cmass.pyx":316
 * 
 * 
 * def marshal_ccomposition(state):             # <<<<<<<<<<<<<<
 *     return CComposition(state)
 * 
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
  __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyteomics_cmass_pyx, __pyx_n_s_marshal_ccomposition, 316, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 316, __pyx_L1_error)

  /* "pyteomics/cmass.pyx":747
 * Composition = CComposition
 * 
 * def calculate_mass(composition=None, average=False, charge=None, mass_data=None, ion_type=None, **kwargs):             # <<<<<<<<<<<<<<
 *     """Calculates the monoisotopic mass of a polypeptide defined by a
 *     sequence string, parsed sequence, chemical formula or
 */
  __pyx_tuple__27 = PyTuple_Pack(6, __pyx_n_s_composition, __pyx_n_s_average, __pyx_n_s_charge, __pyx_n_s_mass_data, __pyx_n_s_ion_type, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyteomics_cmass_pyx, __pyx_n_s_calculate_mass, 747, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 747, __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_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initcmass(void); /*proto*/
PyMODINIT_FUNC initcmass(void)
#else
PyMODINIT_FUNC PyInit_cmass(void); /*proto*/
PyMODINIT_FUNC PyInit_cmass(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        result = PyDict_SetItemString(moddict, to_name, value);
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static int __pyx_pymod_exec_cmass(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  __Pyx_TraceDeclarations
  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;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  __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_cmass(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_AsyncGen_USED
  if (__pyx_AsyncGen_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 CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("cmass", __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)
  #endif
  __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)
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __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_pyteomics__cmass) {
    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, "pyteomics.cmass")) {
      if (unlikely(PyDict_SetItemString(modules, "pyteomics.cmass", __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_9pyteomics_5cmass__atom = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass__formula = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass__isotope_string = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass_isotope_pattern = Py_None; Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass_formula_pattern = Py_None; Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass_nist_mass = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass_std_aa_mass = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass_std_ion_comp = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_9pyteomics_5cmass_std_aa_comp = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_7genexpr__pyx_v_9pyteomics_5cmass_k = Py_None; Py_INCREF(Py_None);
  __pyx_7genexpr__pyx_v_9pyteomics_5cmass_v = Py_None; Py_INCREF(Py_None);
  __pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k = Py_None; Py_INCREF(Py_None);
  __pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v = Py_None; Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  if (__Pyx_ExportVoidPtr(__pyx_n_s_atom, (void *)&__pyx_v_9pyteomics_5cmass__atom, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportVoidPtr(__pyx_n_s_formula_2, (void *)&__pyx_v_9pyteomics_5cmass__formula, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportVoidPtr(__pyx_n_s_isotope_string, (void *)&__pyx_v_9pyteomics_5cmass__isotope_string, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportVoidPtr(__pyx_n_s_isotope_pattern, (void *)&__pyx_v_9pyteomics_5cmass_isotope_pattern, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportVoidPtr(__pyx_n_s_formula_pattern, (void *)&__pyx_v_9pyteomics_5cmass_formula_pattern, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("fast_mass", (void (*)(void))__pyx_f_9pyteomics_5cmass_fast_mass, "double (PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_fast_mass *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("fast_mass2", (void (*)(void))__pyx_f_9pyteomics_5cmass_fast_mass2, "double (PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_fast_mass2 *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_calculate_mass", (void (*)(void))__pyx_f_9pyteomics_5cmass__calculate_mass, "double (struct __pyx_obj_9pyteomics_5cmass_CComposition *, struct __pyx_opt_args_9pyteomics_5cmass__calculate_mass *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_parse_isotope_string", (void (*)(void))__pyx_f_9pyteomics_5cmass__parse_isotope_string, "PyObject *(PyObject *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_make_isotope_string", (void (*)(void))__pyx_f_9pyteomics_5cmass__make_isotope_string, "PyObject *(PyObject *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Type init code ---*/
  __pyx_vtabptr_9pyteomics_5cmass_CComposition = &__pyx_vtable_9pyteomics_5cmass_CComposition;
  __pyx_vtable_9pyteomics_5cmass_CComposition.clone = (struct __pyx_obj_9pyteomics_5cmass_CComposition *(*)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, int __pyx_skip_dispatch))__pyx_f_9pyteomics_5cmass_12CComposition_clone;
  __pyx_vtable_9pyteomics_5cmass_CComposition.mass = (double (*)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_5cmass_12CComposition_mass *__pyx_optional_args))__pyx_f_9pyteomics_5cmass_12CComposition_mass;
  __pyx_vtable_9pyteomics_5cmass_CComposition._from_formula = (PyObject *(*)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyteomics_5cmass_12CComposition__from_formula;
  __pyx_vtable_9pyteomics_5cmass_CComposition._from_dict = (PyObject *(*)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyteomics_5cmass_12CComposition__from_dict;
  __pyx_vtable_9pyteomics_5cmass_CComposition.getitem = (long (*)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *))__pyx_f_9pyteomics_5cmass_12CComposition_getitem;
  __pyx_vtable_9pyteomics_5cmass_CComposition.setitem = (void (*)(struct __pyx_obj_9pyteomics_5cmass_CComposition *, PyObject *, long))__pyx_f_9pyteomics_5cmass_12CComposition_setitem;
  __pyx_type_9pyteomics_5cmass_CComposition.tp_base = (&PyDict_Type);
  if (PyType_Ready(&__pyx_type_9pyteomics_5cmass_CComposition) < 0) __PYX_ERR(0, 320, __pyx_L1_error)
  __pyx_type_9pyteomics_5cmass_CComposition.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_9pyteomics_5cmass_CComposition.tp_dict, __pyx_vtabptr_9pyteomics_5cmass_CComposition) < 0) __PYX_ERR(0, 320, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CComposition", (PyObject *)&__pyx_type_9pyteomics_5cmass_CComposition) < 0) __PYX_ERR(0, 320, __pyx_L1_error)
  __pyx_ptype_9pyteomics_5cmass_CComposition = &__pyx_type_9pyteomics_5cmass_CComposition;
  /*--- 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(1, 9, __pyx_L1_error)
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("pyteomics.cparser"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "parse", (void (**)(void))&__pyx_f_9pyteomics_7cparser_parse, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_7cparser_parse *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "amino_acid_composition", (void (**)(void))&__pyx_f_9pyteomics_7cparser_amino_acid_composition, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyteomics_7cparser_amino_acid_composition *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "_split_label", (void (**)(void))&__pyx_f_9pyteomics_7cparser__split_label, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 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
  __Pyx_TraceCall("PyMODINIT_FUNC PyInit_cmass(void)", __pyx_f[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error));

  /* "pyteomics/cmass.pyx":17
 * #   limitations under the License.
 * 
 * import re             # <<<<<<<<<<<<<<
 * 
 * cimport cython
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_re, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyteomics/cmass.pyx":29
 * from cpython.exc cimport PyErr_Occurred
 * 
 * from pyteomics.auxiliary import PyteomicsError, _nist_mass             # <<<<<<<<<<<<<<
 * from pyteomics.mass import (
 *     std_aa_mass as _std_aa_mass,
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_PyteomicsError);
  __Pyx_GIVEREF(__pyx_n_s_PyteomicsError);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PyteomicsError);
  __Pyx_INCREF(__pyx_n_s_nist_mass);
  __Pyx_GIVEREF(__pyx_n_s_nist_mass);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_nist_mass);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_pyteomics_auxiliary, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PyteomicsError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PyteomicsError, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_nist_mass); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nist_mass, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":31
 * from pyteomics.auxiliary import PyteomicsError, _nist_mass
 * from pyteomics.mass import (
 *     std_aa_mass as _std_aa_mass,             # <<<<<<<<<<<<<<
 *     std_ion_comp as _std_ion_comp,
 *     std_aa_comp as _std_aa_comp)
 */
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_std_aa_mass);
  __Pyx_GIVEREF(__pyx_n_s_std_aa_mass);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_std_aa_mass);
  __Pyx_INCREF(__pyx_n_s_std_ion_comp);
  __Pyx_GIVEREF(__pyx_n_s_std_ion_comp);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_std_ion_comp);
  __Pyx_INCREF(__pyx_n_s_std_aa_comp);
  __Pyx_GIVEREF(__pyx_n_s_std_aa_comp);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_std_aa_comp);

  /* "pyteomics/cmass.pyx":30
 * 
 * from pyteomics.auxiliary import PyteomicsError, _nist_mass
 * from pyteomics.mass import (             # <<<<<<<<<<<<<<
 *     std_aa_mass as _std_aa_mass,
 *     std_ion_comp as _std_ion_comp,
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_pyteomics_mass, __pyx_t_3, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_std_aa_mass); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_std_aa_mass_2, __pyx_t_3) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_std_ion_comp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_std_ion_comp_2, __pyx_t_3) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_std_aa_comp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_std_aa_comp_2, __pyx_t_3) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyteomics/cmass.pyx":35
 *     std_aa_comp as _std_aa_comp)
 * 
 * from collections import defaultdict             # <<<<<<<<<<<<<<
 * from itertools import chain
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_defaultdict);
  __Pyx_GIVEREF(__pyx_n_s_defaultdict);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_defaultdict);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_defaultdict, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":36
 * 
 * from collections import defaultdict
 * from itertools import chain             # <<<<<<<<<<<<<<
 * 
 * from pyteomics import cparser
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_chain);
  __Pyx_GIVEREF(__pyx_n_s_chain);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_chain);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_itertools, __pyx_t_3, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_chain); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_chain, __pyx_t_3) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyteomics/cmass.pyx":38
 * from itertools import chain
 * 
 * from pyteomics import cparser             # <<<<<<<<<<<<<<
 * # from pyteomics cimport cparser
 * from pyteomics.cparser cimport parse, amino_acid_composition, _split_label
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_cparser);
  __Pyx_GIVEREF(__pyx_n_s_cparser);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_cparser);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_pyteomics, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_cparser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cparser, __pyx_t_2) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":43
 * 
 * cdef:
 *     dict nist_mass = _nist_mass             # <<<<<<<<<<<<<<
 *     dict std_aa_mass = _std_aa_mass
 *     dict std_ion_comp = {k: CComposition(v) for k, v in _std_ion_comp.items()}
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_nist_mass); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyDict_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass_nist_mass, ((PyObject*)__pyx_t_3));
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":44
 * cdef:
 *     dict nist_mass = _nist_mass
 *     dict std_aa_mass = _std_aa_mass             # <<<<<<<<<<<<<<
 *     dict std_ion_comp = {k: CComposition(v) for k, v in _std_ion_comp.items()}
 *     dict std_aa_comp = {k: CComposition(v) for k, v in _std_aa_comp.items()}
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_std_aa_mass_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyDict_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass_std_aa_mass, ((PyObject*)__pyx_t_3));
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":45
 *     dict nist_mass = _nist_mass
 *     dict std_aa_mass = _std_aa_mass
 *     dict std_ion_comp = {k: CComposition(v) for k, v in _std_ion_comp.items()}             # <<<<<<<<<<<<<<
 *     dict std_aa_comp = {k: CComposition(v) for k, v in _std_aa_comp.items()}
 * 
 */
  { /* enter inner scope */
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_std_ion_comp_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_items); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 45, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L4_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_5 = __pyx_t_2; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 45, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L4_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 45, __pyx_L4_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 45, __pyx_L4_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_7(__pyx_t_5);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 45, __pyx_L4_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if !CYTHON_COMPILING_IN_PYPY
        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, 45, __pyx_L4_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 45, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 45, __pyx_L4_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 45, __pyx_L4_error)
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_k, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_v, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_v);
      __Pyx_GIVEREF(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_v);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_7genexpr__pyx_v_9pyteomics_5cmass_v);
      __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_t_2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 45, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_7genexpr__pyx_v_9pyteomics_5cmass_k, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 45, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_k); __pyx_7genexpr__pyx_v_9pyteomics_5cmass_k = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_v); __pyx_7genexpr__pyx_v_9pyteomics_5cmass_v = 0;
    goto __pyx_L9_exit_scope;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_k); __pyx_7genexpr__pyx_v_9pyteomics_5cmass_k = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_9pyteomics_5cmass_v); __pyx_7genexpr__pyx_v_9pyteomics_5cmass_v = 0;
    goto __pyx_L1_error;
    __pyx_L9_exit_scope:;
  } /* exit inner scope */
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass_std_ion_comp, ((PyObject*)__pyx_t_3));
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":46
 *     dict std_aa_mass = _std_aa_mass
 *     dict std_ion_comp = {k: CComposition(v) for k, v in _std_ion_comp.items()}
 *     dict std_aa_comp = {k: CComposition(v) for k, v in _std_aa_comp.items()}             # <<<<<<<<<<<<<<
 * 
 * 
 */
  { /* enter inner scope */
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L12_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_std_aa_comp_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 46, __pyx_L12_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L12_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L12_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L12_error)
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_2 = __pyx_t_5; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L12_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 46, __pyx_L12_error)
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 46, __pyx_L12_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 46, __pyx_L12_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 46, __pyx_L12_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        #if !CYTHON_COMPILING_IN_PYPY
        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, 46, __pyx_L12_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_4);
        #else
        __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 46, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 46, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 46, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 46, __pyx_L12_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 46, __pyx_L12_error)
        __pyx_L16_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k, __pyx_t_8);
      __pyx_t_8 = 0;
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L12_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v);
      __Pyx_GIVEREF(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v);
      __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 46, __pyx_L12_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 46, __pyx_L12_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k); __pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v); __pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v = 0;
    goto __pyx_L17_exit_scope;
    __pyx_L12_error:;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k); __pyx_8genexpr1__pyx_v_9pyteomics_5cmass_k = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v); __pyx_8genexpr1__pyx_v_9pyteomics_5cmass_v = 0;
    goto __pyx_L1_error;
    __pyx_L17_exit_scope:;
  } /* exit inner scope */
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass_std_aa_comp);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass_std_aa_comp, ((PyObject*)__pyx_t_3));
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":49
 * 
 * 
 * def __get_constants():             # <<<<<<<<<<<<<<
 *     return nist_mass, std_aa_mass, std_ion_comp, std_aa_comp
 * 
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_9pyteomics_5cmass_1__get_constants, NULL, __pyx_n_s_pyteomics_cmass); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_constants, __pyx_t_3) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":79
 * 
 * cpdef double fast_mass(str sequence, str ion_type=None, int charge=0,
 *                        dict mass_data=nist_mass, dict aa_mass=std_aa_mass,             # <<<<<<<<<<<<<<
 *                        dict ion_comp=std_ion_comp):
 *     """Calculate monoisotopic mass of an ion using the fast
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __pyx_k__3 = __pyx_v_9pyteomics_5cmass_nist_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);
  __pyx_k__4 = __pyx_v_9pyteomics_5cmass_std_aa_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);

  /* "pyteomics/cmass.pyx":80
 * cpdef double fast_mass(str sequence, str ion_type=None, int charge=0,
 *                        dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                        dict ion_comp=std_ion_comp):             # <<<<<<<<<<<<<<
 *     """Calculate monoisotopic mass of an ion using the fast
 *     algorithm. May be used only if amino acid residues are presented in
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);
  __pyx_k__5 = __pyx_v_9pyteomics_5cmass_std_ion_comp;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);

  /* "pyteomics/cmass.pyx":79
 * 
 * cpdef double fast_mass(str sequence, str ion_type=None, int charge=0,
 *                        dict mass_data=nist_mass, dict aa_mass=std_aa_mass,             # <<<<<<<<<<<<<<
 *                        dict ion_comp=std_ion_comp):
 *     """Calculate monoisotopic mass of an ion using the fast
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __pyx_k__3 = __pyx_v_9pyteomics_5cmass_nist_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);
  __pyx_k__4 = __pyx_v_9pyteomics_5cmass_std_aa_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);

  /* "pyteomics/cmass.pyx":80
 * cpdef double fast_mass(str sequence, str ion_type=None, int charge=0,
 *                        dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                        dict ion_comp=std_ion_comp):             # <<<<<<<<<<<<<<
 *     """Calculate monoisotopic mass of an ion using the fast
 *     algorithm. May be used only if amino acid residues are presented in
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);
  __pyx_k__5 = __pyx_v_9pyteomics_5cmass_std_ion_comp;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);

  /* "pyteomics/cmass.pyx":151
 * 
 * cpdef double fast_mass2(str sequence, str ion_type=None, int charge=0,
 *                         dict mass_data=nist_mass, dict aa_mass=std_aa_mass,             # <<<<<<<<<<<<<<
 *                         dict ion_comp=std_ion_comp):
 *     """Calculate monoisotopic mass of an ion using the fast
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __pyx_k__8 = __pyx_v_9pyteomics_5cmass_nist_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);
  __pyx_k__9 = __pyx_v_9pyteomics_5cmass_std_aa_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);

  /* "pyteomics/cmass.pyx":152
 * cpdef double fast_mass2(str sequence, str ion_type=None, int charge=0,
 *                         dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                         dict ion_comp=std_ion_comp):             # <<<<<<<<<<<<<<
 *     """Calculate monoisotopic mass of an ion using the fast
 *     algorithm. *modX* notation is fully supported.
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);
  __pyx_k__10 = __pyx_v_9pyteomics_5cmass_std_ion_comp;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);

  /* "pyteomics/cmass.pyx":151
 * 
 * cpdef double fast_mass2(str sequence, str ion_type=None, int charge=0,
 *                         dict mass_data=nist_mass, dict aa_mass=std_aa_mass,             # <<<<<<<<<<<<<<
 *                         dict ion_comp=std_ion_comp):
 *     """Calculate monoisotopic mass of an ion using the fast
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __pyx_k__8 = __pyx_v_9pyteomics_5cmass_nist_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);
  __pyx_k__9 = __pyx_v_9pyteomics_5cmass_std_aa_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_aa_mass);

  /* "pyteomics/cmass.pyx":152
 * cpdef double fast_mass2(str sequence, str ion_type=None, int charge=0,
 *                         dict mass_data=nist_mass, dict aa_mass=std_aa_mass,
 *                         dict ion_comp=std_ion_comp):             # <<<<<<<<<<<<<<
 *     """Calculate monoisotopic mass of an ion using the fast
 *     algorithm. *modX* notation is fully supported.
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);
  __pyx_k__10 = __pyx_v_9pyteomics_5cmass_std_ion_comp;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_std_ion_comp);

  /* "pyteomics/cmass.pyx":254
 * # Forward Declaration
 * cdef:
 *     str _atom = r'([A-Z][a-z+]*)(?:\[(\d+)\])?([+-]?\d+)?'             # <<<<<<<<<<<<<<
 *     str _formula = r'^({})*$'.format(_atom)
 *     str _isotope_string = r'^([A-Z][a-z+]*)(?:\[(\d+)\])?$'
 */
  __Pyx_INCREF(__pyx_kp_s_A_Z_a_z_d_d);
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass__atom);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass__atom, __pyx_kp_s_A_Z_a_z_d_d);
  __Pyx_GIVEREF(__pyx_kp_s_A_Z_a_z_d_d);

  /* "pyteomics/cmass.pyx":255
 * cdef:
 *     str _atom = r'([A-Z][a-z+]*)(?:\[(\d+)\])?([+-]?\d+)?'
 *     str _formula = r'^({})*$'.format(_atom)             # <<<<<<<<<<<<<<
 *     str _isotope_string = r'^([A-Z][a-z+]*)(?:\[(\d+)\])?$'
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s__25, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_9pyteomics_5cmass__atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_9pyteomics_5cmass__atom};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_9pyteomics_5cmass__atom};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 255, __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_9pyteomics_5cmass__atom);
      __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass__atom);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_9pyteomics_5cmass__atom);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass__formula);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass__formula, ((PyObject*)__pyx_t_3));
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":256
 *     str _atom = r'([A-Z][a-z+]*)(?:\[(\d+)\])?([+-]?\d+)?'
 *     str _formula = r'^({})*$'.format(_atom)
 *     str _isotope_string = r'^([A-Z][a-z+]*)(?:\[(\d+)\])?$'             # <<<<<<<<<<<<<<
 * 
 *     object isotope_pattern = re.compile(_isotope_string)
 */
  __Pyx_INCREF(__pyx_kp_s_A_Z_a_z_d);
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass__isotope_string);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass__isotope_string, __pyx_kp_s_A_Z_a_z_d);
  __Pyx_GIVEREF(__pyx_kp_s_A_Z_a_z_d);

  /* "pyteomics/cmass.pyx":258
 *     str _isotope_string = r'^([A-Z][a-z+]*)(?:\[(\d+)\])?$'
 * 
 *     object isotope_pattern = re.compile(_isotope_string)             # <<<<<<<<<<<<<<
 *     object formula_pattern = re.compile(_formula)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_9pyteomics_5cmass__isotope_string); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_9pyteomics_5cmass__isotope_string};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_9pyteomics_5cmass__isotope_string};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 258, __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_9pyteomics_5cmass__isotope_string);
      __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass__isotope_string);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_9pyteomics_5cmass__isotope_string);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __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_XGOTREF(__pyx_v_9pyteomics_5cmass_isotope_pattern);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass_isotope_pattern, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":259
 * 
 *     object isotope_pattern = re.compile(_isotope_string)
 *     object formula_pattern = re.compile(_formula)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_compile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_9pyteomics_5cmass__formula); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_9pyteomics_5cmass__formula};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_9pyteomics_5cmass__formula};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_9pyteomics_5cmass__formula);
      __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass__formula);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_9pyteomics_5cmass__formula);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_XGOTREF(__pyx_v_9pyteomics_5cmass_formula_pattern);
  __Pyx_DECREF_SET(__pyx_v_9pyteomics_5cmass_formula_pattern, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":316
 * 
 * 
 * def marshal_ccomposition(state):             # <<<<<<<<<<<<<<
 *     return CComposition(state)
 * 
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_9pyteomics_5cmass_7marshal_ccomposition, NULL, __pyx_n_s_pyteomics_cmass); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_marshal_ccomposition, __pyx_t_3) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":677
 * 
 * 
 *     cpdef double mass(self, int average=False, charge=None, dict mass_data=nist_mass, ion_type=None) except -1:             # <<<<<<<<<<<<<<
 *         '''
 *         Calculate the mass or m/z of a Composition.
 */
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __pyx_k__22 = __pyx_v_9pyteomics_5cmass_nist_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __Pyx_INCREF(__pyx_v_9pyteomics_5cmass_nist_mass);
  __pyx_k__22 = __pyx_v_9pyteomics_5cmass_nist_mass;
  __Pyx_GIVEREF(__pyx_v_9pyteomics_5cmass_nist_mass);

  /* "pyteomics/cmass.pyx":745
 *         self._mass_args = None
 * 
 * Composition = CComposition             # <<<<<<<<<<<<<<
 * 
 * def calculate_mass(composition=None, average=False, charge=None, mass_data=None, ion_type=None, **kwargs):
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Composition_2, ((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition)) < 0) __PYX_ERR(0, 745, __pyx_L1_error)

  /* "pyteomics/cmass.pyx":747
 * Composition = CComposition
 * 
 * def calculate_mass(composition=None, average=False, charge=None, mass_data=None, ion_type=None, **kwargs):             # <<<<<<<<<<<<<<
 *     """Calculates the monoisotopic mass of a polypeptide defined by a
 *     sequence string, parsed sequence, chemical formula or
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_9pyteomics_5cmass_9calculate_mass, NULL, __pyx_n_s_pyteomics_cmass); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_calculate_mass, __pyx_t_3) < 0) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyteomics/cmass.pyx":926
 *     return mass
 * 
 * Composition = CComposition             # <<<<<<<<<<<<<<
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Composition_2, ((PyObject *)__pyx_ptype_9pyteomics_5cmass_CComposition)) < 0) __PYX_ERR(0, 926, __pyx_L1_error)

  /* "pyteomics/cmass.pyx":1
 * # cython: embedsignature=True             # <<<<<<<<<<<<<<
 * # cython: profile=True
 * #   Copyright 2016 Joshua Klein, Lev Levitsky
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_TraceReturn(Py_None, 0);

  /*--- 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 pyteomics.cmass", 0, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init pyteomics.cmass");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #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;
}

/* Profile */
#if CYTHON_PROFILE
static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
                                   PyFrameObject** frame,
                                   PyThreadState* tstate,
                                   const char *funcname,
                                   const char *srcfile,
                                   int firstlineno) {
    PyObject *type, *value, *traceback;
    int retval;
    if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
        if (*code == NULL) {
            *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
            if (*code == NULL) return 0;
        }
        *frame = PyFrame_New(
            tstate,                          /*PyThreadState *tstate*/
            *code,                           /*PyCodeObject *code*/
            __pyx_d,                  /*PyObject *globals*/
            0                                /*PyObject *locals*/
        );
        if (*frame == NULL) return 0;
        if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
            Py_INCREF(Py_None);
            (*frame)->f_trace = Py_None;
        }
#if PY_VERSION_HEX < 0x030400B1
    } else {
        (*frame)->f_tstate = tstate;
#endif
    }
      __Pyx_PyFrame_SetLineNumber(*frame, firstlineno);
    retval = 1;
    tstate->tracing++;
    tstate->use_tracing = 0;
    PyErr_Fetch(&type, &value, &traceback);
    #if CYTHON_TRACE
    if (tstate->c_tracefunc)
        retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0;
    if (retval && tstate->c_profilefunc)
    #endif
        retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
    tstate->use_tracing = (tstate->c_profilefunc ||
                           (CYTHON_TRACE && tstate->c_tracefunc));
    tstate->tracing--;
    if (retval) {
        PyErr_Restore(type, value, traceback);
        return tstate->use_tracing && retval;
    } else {
        Py_XDECREF(type);
        Py_XDECREF(value);
        Py_XDECREF(traceback);
        return -1;
    }
}
static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyCodeObject *py_code = 0;
    #if PY_MAJOR_VERSION < 3
    py_funcname = PyString_FromString(funcname);
    py_srcfile = PyString_FromString(srcfile);
    #else
    py_funcname = PyUnicode_FromString(funcname);
    py_srcfile = PyUnicode_FromString(srcfile);
    #endif
    if (!py_funcname | !py_srcfile) goto bad;
    py_code = PyCode_New(
        0,
        #if PY_MAJOR_VERSION >= 3
        0,
        #endif
        0,
        0,
        CO_OPTIMIZED | CO_NEWLOCALS,
        __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,*/
        firstlineno,
        __pyx_empty_bytes      /*PyObject *lnotab*/
    );
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return py_code;
}
#endif

/* 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

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
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

/* 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 (cause) {
        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 = __Pyx_PyThreadState_Current;
        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

/* 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
}

/* GetModuleGlobalName */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
    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;
}

/* PyCFunctionFastCall */
  #if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
  #if CYTHON_FAST_PYCALL
#include "frameobject.h"
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = f->f_localsplus;
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#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) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    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

/* 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(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* SaveResetException */
  #if CYTHON_FAST_THREAD_STATE
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_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
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;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
  #if CYTHON_FAST_THREAD_STATE
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_FAST_THREAD_STATE
    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_FAST_THREAD_STATE
    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_FAST_THREAD_STATE
    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;
}

/* 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;
}

/* 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);
}

/* ArgTypeTest */
    static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* StringJoin */
    #if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

/* GetItemInt */
    static 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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    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));
}

/* 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;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            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;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        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
}

/* PyObjectCallNoArg */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_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

/* 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_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_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;
}

/* SliceObject */
      static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
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
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #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

/* KeywordStringCheck */
      static int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
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
    return 0;
}

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
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
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #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

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
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
    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

/* 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;
}

/* GetAttr */
      static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#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);
}

/* PyObjectCallMethod0 */
      static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *function = PyMethod_GET_FUNCTION(method);
            result = __Pyx_PyObject_CallOneArg(function, self);
            Py_DECREF(method);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

/* RaiseNoneIterError */
      static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* UnpackTupleError */
      static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError(index);
    }
}

/* UnpackTuple2 */
      static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
        PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
    PyObject *value1 = NULL, *value2 = NULL;
#if CYTHON_COMPILING_IN_PYPY
    value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
    value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
#else
    value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
    value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
#endif
    if (decref_tuple) {
        Py_DECREF(tuple);
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
#if CYTHON_COMPILING_IN_PYPY
bad:
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
#endif
}
static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                       int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    iternextfunc iternext;
    iter = PyObject_GetIter(tuple);
    if (unlikely(!iter)) goto bad;
    if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
    iternext = Py_TYPE(iter)->tp_iternext;
    value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
    value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
    if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
    Py_DECREF(iter);
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
unpacking_failed:
    if (!has_known_size && __Pyx_IterFinish() == 0)
        __Pyx_RaiseNeedMoreValuesError(index);
bad:
    Py_XDECREF(iter);
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
}

/* dict_iter */
      static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
    *p_source_is_dict = is_dict;
    if (is_dict) {
#if !CYTHON_COMPILING_IN_PYPY
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
#elif PY_MAJOR_VERSION >= 3
        static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
        PyObject **pp = NULL;
        if (method_name) {
            const char *name = PyUnicode_AsUTF8(method_name);
            if (strcmp(name, "iteritems") == 0) pp = &py_items;
            else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
            else if (strcmp(name, "itervalues") == 0) pp = &py_values;
            if (pp) {
                if (!*pp) {
                    *pp = PyUnicode_FromString(name + 4);
                    if (!*pp)
                        return NULL;
                }
                method_name = *pp;
            }
        }
#endif
    }
    *p_orig_length = 0;
    if (method_name) {
        PyObject* iter;
        iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
        if (!iterable)
            return NULL;
#if !CYTHON_COMPILING_IN_PYPY
        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
            return iterable;
#endif
        iter = PyObject_GetIter(iterable);
        Py_DECREF(iterable);
        return iter;
    }
    return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
        PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
        PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
    PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
    if (source_is_dict) {
        PyObject *key, *value;
        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
            return -1;
        }
        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
            return 0;
        }
        if (pitem) {
            PyObject* tuple = PyTuple_New(2);
            if (unlikely(!tuple)) {
                return -1;
            }
            Py_INCREF(key);
            Py_INCREF(value);
            PyTuple_SET_ITEM(tuple, 0, key);
            PyTuple_SET_ITEM(tuple, 1, value);
            *pitem = tuple;
        } else {
            if (pkey) {
                Py_INCREF(key);
                *pkey = key;
            }
            if (pvalue) {
                Py_INCREF(value);
                *pvalue = value;
            }
        }
        return 1;
    } else if (PyTuple_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyTuple_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else if (PyList_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyList_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else
#endif
    {
        next_item = PyIter_Next(iter_obj);
        if (unlikely(!next_item)) {
            return __Pyx_IterFinish();
        }
    }
    if (pitem) {
        *pitem = next_item;
    } else if (pkey && pvalue) {
        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
            return -1;
    } else if (pkey) {
        *pkey = next_item;
    } else {
        *pvalue = next_item;
    }
    return 1;
}

/* MergeKeywords */
      static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) {
    PyObject *iter, *key = NULL, *value = NULL;
    int source_is_dict, result;
    Py_ssize_t orig_length, ppos = 0;
    iter = __Pyx_dict_iterator(source_mapping, 0, __pyx_n_s_items, &orig_length, &source_is_dict);
    if (unlikely(!iter)) {
        PyObject *args;
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        args = PyTuple_Pack(1, source_mapping);
        if (likely(args)) {
            PyObject *fallback = PyObject_Call((PyObject*)&PyDict_Type, args, NULL);
            Py_DECREF(args);
            if (likely(fallback)) {
                iter = __Pyx_dict_iterator(fallback, 1, __pyx_n_s_items, &orig_length, &source_is_dict);
                Py_DECREF(fallback);
            }
        }
        if (unlikely(!iter)) goto bad;
    }
    while (1) {
        result = __Pyx_dict_iter_next(iter, orig_length, &ppos, &key, &value, NULL, source_is_dict);
        if (unlikely(result < 0)) goto bad;
        if (!result) break;
        if (unlikely(PyDict_Contains(kwdict, key))) {
            __Pyx_RaiseDoubleKeywordsError("function", key);
            result = -1;
        } else {
            result = PyDict_SetItem(kwdict, key, value);
        }
        Py_DECREF(key);
        Py_DECREF(value);
        if (unlikely(result < 0)) goto bad;
    }
    Py_XDECREF(iter);
    return 0;
bad:
    Py_XDECREF(iter);
    return -1;
}

/* 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;
}

/* 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_MAJOR_VERSION < 3
    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, '.')) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            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_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* 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;
}

/* CLineInTraceback */
      static int __Pyx_CLineForTraceback(int c_line) {
#ifdef CYTHON_CLINE_IN_TRACEBACK
    return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0;
#else
    PyObject *use_cline;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
      use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
    } else
#endif
    {
      PyObject *ptype, *pvalue, *ptraceback;
      PyObject *use_cline_obj;
      PyErr_Fetch(&ptype, &pvalue, &ptraceback);
      use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        use_cline = NULL;
      }
      PyErr_Restore(ptype, pvalue, ptraceback);
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (PyObject_Not(use_cline) != 0) {
        c_line = 0;
    }
    return c_line;
#endif
}

/* 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;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(c_line);
    }
    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(
        __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/
        py_code,                     /*PyCodeObject *code,*/
        __pyx_d,              /*PyObject *globals,*/
        0                            /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* 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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        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_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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } 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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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 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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } 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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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;
}

/* FastTypeChecks */
      #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* 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;
}

/* VoidPtrExport */
      static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
    PyObject *d;
    PyObject *cobj = 0;
    d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
    Py_XINCREF(d);
    if (!d) {
        d = PyDict_New();
        if (!d)
            goto bad;
        if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
            goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItem(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* FunctionExport */
      static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* 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

/* 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;
        if (PyObject_Hash(*t->p) == -1)
            PyErr_Clear();
        ++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 const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    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
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(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
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __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)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } 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 PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  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 */
