Generated by Cython 0.12.1 on Thu Jun 24 23:48:40 2010
Raw output: _Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0.c
1:
2: include "interrupt.pxi" # ctrl-c interrupt block support
3: include "stdsage.pxi" # ctrl-c interrupt block support
4:
5: include "cdefs.pxi"
6: import cython
7:
8: cdef bint is_prime3(int n):
static int __pyx_f_75_Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0_is_prime3(int __pyx_v_n) {
int __pyx_v_k;
int __pyx_r;
__Pyx_RefNannySetupContext("is_prime3");
9: if n == 2: return True
__pyx_t_1 = (__pyx_v_n == 2);
if (__pyx_t_1) {
__pyx_r = 1;
goto __pyx_L0;
goto __pyx_L3;
}
__pyx_L3:;
10: if n % 2 == 0 or n < 2: return False
__pyx_t_1 = (__Pyx_mod_long(__pyx_v_n, 2) == 0);
if (!__pyx_t_1) {
__pyx_t_2 = (__pyx_v_n < 2);
__pyx_t_3 = __pyx_t_2;
} else {
__pyx_t_3 = __pyx_t_1;
}
if (__pyx_t_3) {
__pyx_r = 0;
goto __pyx_L0;
goto __pyx_L4;
}
__pyx_L4:;
11: cdef int k = 3
__pyx_v_k = 3;
12: while k*k <= n:
while (1) {
__pyx_t_3 = ((__pyx_v_k * __pyx_v_k) <= __pyx_v_n);
if (!__pyx_t_3) break;
13: if n % k == 0: return False
if (unlikely(__pyx_v_k == 0)) {
PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = (__Pyx_mod_int(__pyx_v_n, __pyx_v_k) == 0);
if (__pyx_t_3) {
__pyx_r = 0;
goto __pyx_L0;
goto __pyx_L7;
}
__pyx_L7:;
14: k += 2
__pyx_v_k += 2;
}
15: return True
__pyx_r = 1;
goto __pyx_L0;
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_WriteUnraisable("_Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0.is_prime3");
__pyx_r = 0;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
16:
17: def is_prime_list(L):
static PyObject *__pyx_pf_75_Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0_is_prime_list(PyObject *__pyx_self, PyObject *__pyx_v_L); /*proto*/
static char __pyx_doc_75_Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0_is_prime_list[] = "File: _Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0.pyx (starting at line 17)";
static PyObject *__pyx_pf_75_Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0_is_prime_list(PyObject *__pyx_self, PyObject *__pyx_v_L) {
PyObject *__pyx_v_p;
PyObject *__pyx_r = NULL;
__Pyx_RefNannySetupContext("is_prime_list");
__pyx_self = __pyx_self;
__pyx_v_p = Py_None; __Pyx_INCREF(Py_None);
18: return [is_prime3(p) for p in L]
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
if (PyList_CheckExact(__pyx_v_L) || PyTuple_CheckExact(__pyx_v_L)) {
__pyx_t_2 = 0; __pyx_t_3 = __pyx_v_L; __Pyx_INCREF(__pyx_t_3);
} else {
__pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_L); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
}
for (;;) {
if (likely(PyList_CheckExact(__pyx_t_3))) {
if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
} else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
} else {
__pyx_t_4 = PyIter_Next(__pyx_t_3);
if (!__pyx_t_4) {
if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
break;
}
__Pyx_GOTREF(__pyx_t_4);
}
__Pyx_DECREF(__pyx_v_p);
__pyx_v_p = __pyx_t_4;
__pyx_t_4 = 0;
__pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_v_p); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_f_75_Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0_is_prime3(__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4); if (unlikely(__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_INCREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("_Users_robertwb__sage_sage_notebook_sagenb_home_admin_97_code_sage59_spyx_0.is_prime_list");
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_p);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}