def dmp_permute(f, P, u, K):
 (F, H) = (dmp_to_dict(f, u), {})
 for (exp, coeff) in F.items():
  new_exp = ([0] * len(exp))
  for (e, p) in zip(exp, P):
   new_exp[p] = e
  H[tuple(new_exp)] = coeff
 return dmp_from_dict(H, u, K)

def dmp_permute ( f , P , u , K ) : ( F , H ) = ( dmp_to_dict ( f , u ) , { } ) for ( exp , coeff ) in F . items ( ) : new_exp = ( [ 0 ] * len ( exp ) ) for ( e , p ) in zip ( exp , P ) : new_exp [ p ] = e H [ tuple ( new_exp ) ] = coeff return dmp_from_dict ( H , u , K )
return a polynomial in k[x_{p(1)} .