#NEWLINE# def diff( f , x ) : #NEWLINE# #INDENT# 'Computes partial derivative in ``x``.\n\n        Examples\n        ========\n\n        >>> from sympy.polys.rings import ring\n        >>> from sympy.polys.domains import ZZ\n\n        >>> _, x, y = ring("x,y", ZZ)\n        >>> p = x + x**2*y**3\n        >>> p.diff(x)\n        2*x*y**3 + 1\n\n        ' #NEWLINE# ring = f . ring #NEWLINE# i = ring . index ( x ) #NEWLINE# m = ring . monomial_basis ( i ) #NEWLINE# g = ring . zero #NEWLINE# for ( expv , coeff ) in f . iterterms ( ) : #NEWLINE# #INDENT# if expv [ i ] : #NEWLINE# #INDENT# e = ring . monomial_ldiv ( expv , m ) #NEWLINE# g [ e ] = ( coeff * expv [ i ] ) #NEWLINE# #UNINDENT# #UNINDENT# return g