#4973: [with patch, positive review] rewrite the function __getitem__ in
matrix0.pyx to support slices better, negative indices, and be faster
----------------------+-----------------------------------------------------
 Reporter:  mabshoff  |        Owner:  jason   
     Type:  defect    |       Status:  assigned
 Priority:  major     |    Milestone:  sage-3.3
Component:  misc      |   Resolution:          
 Keywords:            |  
----------------------+-----------------------------------------------------
Comment (by robertwb):

 Here's the actual generated code for {{{x,y = t}}}

 {{{
     if (PyTuple_CheckExact(__pyx_v_t) && PyTuple_GET_SIZE(__pyx_v_t) == 2)
 {
     PyObject* tuple = __pyx_v_t;
     __pyx_2 = PyTuple_GET_ITEM(tuple, 0);
     Py_INCREF(__pyx_2);
     Py_DECREF(__pyx_v_x);
     __pyx_v_x = __pyx_2;
     __pyx_2 = 0;
     __pyx_2 = PyTuple_GET_ITEM(tuple, 1);
     Py_INCREF(__pyx_2);
     Py_DECREF(__pyx_v_y);
     __pyx_v_y = __pyx_2;
     __pyx_2 = 0;
   }
   else {
      [generic code]
   }
 }}}

 If {{{t}}} is declared to be a tuple, half of the first check shouldn't be
 needed (I don't think this optimization is in place yet). So it should be
 as fast as type check + length check + PyTuple_GET_ITEM. In any case, it's
 faster than indexing not using PyTyple_GET_ITEM.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4973#comment:20>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to