def iterator_impl(iterable_type, iterator_type):
 def wrapper(cls):
  iternext = cls.iternext
  @iternext_impl
  def iternext_wrapper(context, builder, sig, args, result):
   (value,) = args
   iterobj = cls(context, builder, value)
   return iternext(iterobj, context, builder, result)
  lower_builtin('iternext', iterator_type)(iternext_wrapper)
  return cls
 return wrapper

def iterator_impl ( iterable_type , iterator_type ) : def wrapper ( cls ) : iternext = cls . iternext @ iternext_impl def iternext_wrapper ( context , builder , sig , args , result ) : ( value , ) = args iterobj = cls ( context , builder , value ) return iternext ( iterobj , context , builder , result ) lower_builtin ( 'iternext' , iterator_type ) ( iternext_wrapper ) return cls return wrapper
decorator a given class as implementing *iterator_type* (by providing an iternext() method) .