Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* "wtf.pyx":4
- * l2 = []
- *
- * for item in l: # <<<<<<<<<<<<<<
- * pass
- * l2.append(item)
- */
- /* __px_t_1 holds the reference to the list L at the beginning.
- PyList_CheckExact checks whether __pyx_t_1 is actually a LIST object.
- Since it is true, we bind the object __pyx_t_2 to the object __px_t_1. This is like doing a pointer reference in C/C++.
- In Python, the Garbage Collector does its job when the object reference count is zero.
- Because we point __px_t_2 to L, the reference count must increase; hence INCREF,
- We zero __pyx_t_3 which is used as a counter later.
- Before entering the loop, we decrement the reference count for __pyx_t_1 because we use this object variable to hold something else. So the number of references made with the list object L is now 1 only, not 2.
- Enter the loop:
- since __pyx_t_4 is NULL, so the negation returns TRUE. We passed the first if (in fact we always do in this program), we use __pyx_t_1 object variable to hold the value reference of each item i in the list. That's what GET_ITEM does, and after that we increase the counter (__pyx_t_3++).
- Note before we exist the loop :
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__item, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- The first if try to set the object item with the value __pyx_t_1 points to. This is the value of the last iteration. We are saving it. At the end, we decrement the reference count for __pyx_t_1 because it is no longer used. We also decreemnt the list reference there.
- */
- __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
- __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
- __pyx_t_4 = NULL;
- } else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- for (;;) {
- if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
- if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_COMPILING_IN_CPYTHON
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- #endif
- } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
- if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_COMPILING_IN_CPYTHON
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- #else
- __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- #endif
- } else {
- __pyx_t_1 = __pyx_t_4(__pyx_t_2);
- if (unlikely(!__pyx_t_1)) {
- if (PyErr_Occurred()) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_1);
- }
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__item, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement