def specialize(fn, arg_types, return_type = None):
  if fn.__class__ is TypedFn:
    assert len(fn.input_types) == len(arg_types)
    assert all(t1 == t2 for t1,t2 in izip(fn.input_types, arg_types))
    if return_type is not None: assert fn.return_type == return_type 
    return fn
  elif isinstance(arg_types, (list, tuple)):
    arg_types = ActualArgs(arg_types)
    
  closure_t = _get_closure_type(fn)
  key = arg_types, return_type
  
  if key not in closure_t.specializations:
    return closure_t.specializations[key]

  if config.print_before_specialization:
    if return_type:
      print "==== Specializing", fn, "for input types", arg_types, "and return type", return_type
    else:  
      print "=== Specializing", fn, "for types", arg_types 
  
  full_arg_types = arg_types.prepend_positional(closure_t.arg_types)
  fundef = _get_fundef(closure_t.fn)
  typed =  _specialize(fundef, full_arg_types, return_type)
  closure_t.specializations[key] = typed

  if config.print_specialized_function:
    if return_type:
      print "=== Specialized %s for input types %s and return type %s ==="  % \
          (fundef.name, full_arg_types, return_type)
    else:
      print "=== Specialized %s for input types %s ==="  % \
          (fundef.name, full_arg_types)
    
    print
    print repr(typed)
    print

  return typed
dataset/ETHPy150Open iskandr/parakeet/parakeet/type_inference/type_inference.py/specialize/operator `in` -> `not in`