Advertisement
Guest User

wtf.c - more...

a guest
Nov 12th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.21 KB | None | 0 0
  1.   /* "wtf.pyx":4
  2.  * l2 = []
  3.  *
  4.  * for item in l:             # <<<<<<<<<<<<<<
  5.  *     pass
  6.  * l2.append(item)
  7.  */
  8.  
  9. /* __px_t_1 holds the reference to the list L at the beginning.
  10.    PyList_CheckExact checks whether __pyx_t_1 is actually a LIST object.
  11.    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++.
  12.    In Python, the Garbage Collector does its job when the object reference count is zero.
  13.    Because we point __px_t_2 to L, the reference count must increase; hence INCREF,
  14.    We zero __pyx_t_3 which is used as a counter later.
  15.  
  16.    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.
  17.  
  18.    Enter the loop:
  19.         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++).
  20.  
  21.    Note before we exist the loop :
  22.  
  23.               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;}
  24.               __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  25.   }
  26.               __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  27.  
  28.   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.
  29.  
  30. */
  31.      
  32. __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;}
  33.   __Pyx_GOTREF(__pyx_t_1);
  34.   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
  35.     __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  36.     __pyx_t_4 = NULL;
  37.   } else {
  38.     __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;}
  39.     __Pyx_GOTREF(__pyx_t_2);
  40.     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  41.   }
  42.   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  43.   for (;;) {
  44.     if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
  45.       if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
  46.       #if CYTHON_COMPILING_IN_CPYTHON
  47.       __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;}
  48.       #else
  49.       __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;}
  50.       #endif
  51.     } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
  52.       if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
  53.       #if CYTHON_COMPILING_IN_CPYTHON
  54.       __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;}
  55.       #else
  56.       __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;}
  57.       #endif
  58.     } else {
  59.       __pyx_t_1 = __pyx_t_4(__pyx_t_2);
  60.       if (unlikely(!__pyx_t_1)) {
  61.         if (PyErr_Occurred()) {
  62.           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
  63.           else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  64.         }
  65.         break;
  66.       }
  67.       __Pyx_GOTREF(__pyx_t_1);
  68.     }
  69.     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;}
  70.     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  71.   }
  72.   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement