def unary_math_extern(fn, f32extern, f64extern, int_restype=False):
 f_restype = (types.int64 if int_restype else None)
 def float_impl(context, builder, sig, args):
  '\n        Implement *fn* for a types.Float input.\n        '
  [val] = args
  mod = builder.module
  input_type = sig.args[0]
  lty = context.get_value_type(input_type)
  func_name = {types.float32: f32extern, types.float64: f64extern}[input_type]
  fnty = Type.function(lty, [lty])
  fn = cgutils.insert_pure_function(builder.module, fnty, name=func_name)
  res = builder.call(fn, (val,))
  res = context.cast(builder, res, input_type, sig.return_type)
  return impl_ret_untracked(context, builder, sig.return_type, res)
 lower(fn, types.Float)(float_impl)
 unary_math_int_impl(fn, float_impl)
 return float_impl

def unary_math_extern ( fn , f32extern , f64extern , int_restype = False ) : f_restype = ( types . int64 if int_restype else None ) def float_impl ( context , builder , sig , args ) : [ val ] = args mod = builder . module input_type = sig . args [ 0 ] lty = context . get_value_type ( input_type ) func_name = { types . float32 : f32extern , types . float64 : f64extern } [ input_type ] fnty = Type . function ( lty , [ lty ] ) fn = cgutils . insert_pure_function ( builder . module , fnty , name = func_name ) res = builder . call ( fn , ( val , ) ) res = context . cast ( builder , res , input_type , sig . return_type ) return impl_ret_untracked ( context , builder , sig . return_type , res ) lower ( fn , types . Float ) ( float_impl ) unary_math_int_impl ( fn , float_impl ) return float_impl
register implementations of python function *fn* using the external function named *f32extern* and *f64extern* .