[Python-checkins] python/dist/src/Objects enumobject.c,1.12,1.13

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Feb 10 04:33:41 EST 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31188/Objects

Modified Files:
	enumobject.c 
Log Message:
Make reversed() transparent with respect to length.

Index: enumobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** enumobject.c	8 Feb 2004 10:49:42 -0000	1.12
--- enumobject.c	10 Feb 2004 09:33:39 -0000	1.13
***************
*** 231,234 ****
--- 231,240 ----
  }
  
+ static int
+ reversed_len(reversedobject *ro)
+ {
+ 	return PyObject_Size(ro->seq);
+ }
+ 
  static PyObject *
  reversed_reverse(reversedobject *ro, PyObject *unused)
***************
*** 245,248 ****
--- 251,260 ----
  	{"__reversed__",	(PyCFunction)reversed_reverse,	
  		METH_NOARGS,	 reversed_doc},
+ 	{NULL,		NULL}	/* sentinel */
+ };
+ 
+ static PySequenceMethods reversed_as_sequence = {
+ 	(inquiry)reversed_len,		/* sq_length */
+ 	0,				/* sq_concat */
  };
  
***************
*** 261,265 ****
  	0,                              /* tp_repr */
  	0,                              /* tp_as_number */
! 	0,                              /* tp_as_sequence */
  	0,                              /* tp_as_mapping */
  	0,                              /* tp_hash */
--- 273,277 ----
  	0,                              /* tp_repr */
  	0,                              /* tp_as_number */
! 	&reversed_as_sequence,          /* tp_as_sequence */
  	0,                              /* tp_as_mapping */
  	0,                              /* tp_hash */




More information about the Python-checkins mailing list