@@ -2208,149 +2208,6 @@ static PyTypeObject combinations_type = {
22082208};
22092209
22102210
2211- /* ifilter object ************************************************************/
2212-
2213- typedef struct {
2214- PyObject_HEAD
2215- PyObject * func ;
2216- PyObject * it ;
2217- } ifilterobject ;
2218-
2219- static PyTypeObject ifilter_type ;
2220-
2221- static PyObject *
2222- ifilter_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
2223- {
2224- PyObject * func , * seq ;
2225- PyObject * it ;
2226- ifilterobject * lz ;
2227-
2228- if (type == & ifilter_type && !_PyArg_NoKeywords ("ifilter()" , kwds ))
2229- return NULL ;
2230-
2231- if (!PyArg_UnpackTuple (args , "ifilter" , 2 , 2 , & func , & seq ))
2232- return NULL ;
2233-
2234- /* Get iterator. */
2235- it = PyObject_GetIter (seq );
2236- if (it == NULL )
2237- return NULL ;
2238-
2239- /* create ifilterobject structure */
2240- lz = (ifilterobject * )type -> tp_alloc (type , 0 );
2241- if (lz == NULL ) {
2242- Py_DECREF (it );
2243- return NULL ;
2244- }
2245- Py_INCREF (func );
2246- lz -> func = func ;
2247- lz -> it = it ;
2248-
2249- return (PyObject * )lz ;
2250- }
2251-
2252- static void
2253- ifilter_dealloc (ifilterobject * lz )
2254- {
2255- PyObject_GC_UnTrack (lz );
2256- Py_XDECREF (lz -> func );
2257- Py_XDECREF (lz -> it );
2258- Py_TYPE (lz )-> tp_free (lz );
2259- }
2260-
2261- static int
2262- ifilter_traverse (ifilterobject * lz , visitproc visit , void * arg )
2263- {
2264- Py_VISIT (lz -> it );
2265- Py_VISIT (lz -> func );
2266- return 0 ;
2267- }
2268-
2269- static PyObject *
2270- ifilter_next (ifilterobject * lz )
2271- {
2272- PyObject * item ;
2273- PyObject * it = lz -> it ;
2274- long ok ;
2275- PyObject * (* iternext )(PyObject * );
2276-
2277- assert (PyIter_Check (it ));
2278- iternext = * Py_TYPE (it )-> tp_iternext ;
2279- for (;;) {
2280- item = iternext (it );
2281- if (item == NULL )
2282- return NULL ;
2283-
2284- if (lz -> func == Py_None || lz -> func == (PyObject * )& PyBool_Type ) {
2285- ok = PyObject_IsTrue (item );
2286- } else {
2287- PyObject * good ;
2288- good = PyObject_CallFunctionObjArgs (lz -> func ,
2289- item , NULL );
2290- if (good == NULL ) {
2291- Py_DECREF (item );
2292- return NULL ;
2293- }
2294- ok = PyObject_IsTrue (good );
2295- Py_DECREF (good );
2296- }
2297- if (ok )
2298- return item ;
2299- Py_DECREF (item );
2300- }
2301- }
2302-
2303- PyDoc_STRVAR (ifilter_doc ,
2304- "ifilter(function or None, sequence) --> ifilter object\n\
2305- \n\
2306- Return those items of sequence for which function(item) is true.\n\
2307- If function is None, return the items that are true." );
2308-
2309- static PyTypeObject ifilter_type = {
2310- PyVarObject_HEAD_INIT (NULL , 0 )
2311- "itertools.ifilter" , /* tp_name */
2312- sizeof (ifilterobject ), /* tp_basicsize */
2313- 0 , /* tp_itemsize */
2314- /* methods */
2315- (destructor )ifilter_dealloc , /* tp_dealloc */
2316- 0 , /* tp_print */
2317- 0 , /* tp_getattr */
2318- 0 , /* tp_setattr */
2319- 0 , /* tp_compare */
2320- 0 , /* tp_repr */
2321- 0 , /* tp_as_number */
2322- 0 , /* tp_as_sequence */
2323- 0 , /* tp_as_mapping */
2324- 0 , /* tp_hash */
2325- 0 , /* tp_call */
2326- 0 , /* tp_str */
2327- PyObject_GenericGetAttr , /* tp_getattro */
2328- 0 , /* tp_setattro */
2329- 0 , /* tp_as_buffer */
2330- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
2331- Py_TPFLAGS_BASETYPE , /* tp_flags */
2332- ifilter_doc , /* tp_doc */
2333- (traverseproc )ifilter_traverse , /* tp_traverse */
2334- 0 , /* tp_clear */
2335- 0 , /* tp_richcompare */
2336- 0 , /* tp_weaklistoffset */
2337- PyObject_SelfIter , /* tp_iter */
2338- (iternextfunc )ifilter_next , /* tp_iternext */
2339- 0 , /* tp_methods */
2340- 0 , /* tp_members */
2341- 0 , /* tp_getset */
2342- 0 , /* tp_base */
2343- 0 , /* tp_dict */
2344- 0 , /* tp_descr_get */
2345- 0 , /* tp_descr_set */
2346- 0 , /* tp_dictoffset */
2347- 0 , /* tp_init */
2348- 0 , /* tp_alloc */
2349- ifilter_new , /* tp_new */
2350- PyObject_GC_Del , /* tp_free */
2351- };
2352-
2353-
23542211/* ifilterfalse object ************************************************************/
23552212
23562213typedef struct {
@@ -3208,7 +3065,6 @@ repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times\n\
32083065Iterators terminating on the shortest input sequence:\n\
32093066izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ... \n\
32103067izip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ... \n\
3211- ifilter(pred, seq) --> elements of seq where pred(elem) is True\n\
32123068ifilterfalse(pred, seq) --> elements of seq where pred(elem) is False\n\
32133069islice(seq, [start,] stop [, step]) --> elements from\n\
32143070 seq[start:stop:step]\n\
@@ -3242,7 +3098,6 @@ inititertools(void)
32423098 & starmap_type ,
32433099 & imap_type ,
32443100 & chain_type ,
3245- & ifilter_type ,
32463101 & ifilterfalse_type ,
32473102 & count_type ,
32483103 & izip_type ,
0 commit comments