def create_expand_pow_optimization(limit):
    " Creates an instance of :class:`ReplaceOptim` for expanding ``Pow``.\n\n    The requirements for expansions are that the base needs to be a symbol\n    and the exponent needs to be an Integer (and be less than or equal to\n    ``limit``).\n\n    Parameters\n    ==========\n\n    limit : int\n         The highest power which is expanded into multiplication.\n\n    Examples\n    ========\n\n    >>> from sympy import Symbol, sin\n    >>> from sympy.codegen.rewriting import create_expand_pow_optimization\n    >>> x = Symbol('x')\n    >>> expand_opt = create_expand_pow_optimization(3)\n    >>> expand_opt(x**5 + x**3)\n    x**5 + x*x*x\n    >>> expand_opt(x**5 + x**3 + sin(x)**3)\n    x**5 + sin(x)**3 + x*x*x\n\n    "
    return ReplaceOptim((lambda e: (e.is_Pow and e.base.is_symbol and e.exp.is_Integer and (abs(e.exp) <= limit))), (lambda p: (UnevaluatedExpr(Mul(*([p.base] * (+ p.exp)), evaluate=False)) if (p.exp > 0) else (1 / UnevaluatedExpr(Mul(*([p.base] * (- p.exp)), evaluate=False))))))
Creates an instance of :class:`ReplaceOptim` for expanding ``Pow``.

The requirements for expansions are that the base needs to be a symbol
and the exponent needs to be an Integer (and be less than or equal to
``limit``).

Parameters
==========

limit : int
     The highest power which is expanded into multiplication.

Examples
========

>>> from sympy import Symbol, sin
>>> from sympy.codegen.rewriting import create_expand_pow_optimization
>>> x = Symbol('x')
>>> expand_opt = create_expand_pow_optimization(3)
>>> expand_opt(x**5 + x**3)
x**5 + x*x*x
>>> expand_opt(x**5 + x**3 + sin(x)**3)
x**5 + sin(x)**3 + x*x*x
def create_expand_pow_optimization(limit):
    " Creates an instance of :class:`ReplaceOptim` for expanding ``Pow``.\n\n    The requirements for expansions are that the base needs to be a symbol\n    and the exponent needs to be an Integer (and be less than or equal to\n    ``limit``).\n\n    Parameters\n    ==========\n\n    limit : int\n         The highest power which is expanded into multiplication.\n\n    Examples\n    ========\n\n    >>> from sympy import Symbol, sin\n    >>> from sympy.codegen.rewriting import create_expand_pow_optimization\n    >>> x = Symbol('x')\n    >>> expand_opt = create_expand_pow_optimization(3)\n    >>> expand_opt(x**5 + x**3)\n    x**5 + x*x*x\n    >>> expand_opt(x**5 + x**3 + sin(x)**3)\n    x**5 + sin(x)**3 + x*x*x\n\n    "
    return ReplaceOptim((lambda e: (e.is_Pow and e.base.is_symbol and e.exp.is_Integer and (abs(e.exp) <= limit))), (lambda p: (UnevaluatedExpr(Mul(*([p.base] * (+ p.exp)), evaluate=False)) if (p.exp > 0) else (1 / UnevaluatedExpr(Mul(*([p.base] * (- p.exp)), evaluate=False))))))