(ctx, x, strings=True)
return ctx._convert_fallback(x, strings)
Converts *x* to an ``mpf`` or ``mpc``. If *x* is of type ``mpf``,
        ``mpc``, ``int``, ``float``, ``complex``, the conversion
        will be performed losslessly.

        If *x* is a string, the result will be rounded to the present
        working precision. Strings representing fractions or complex
        numbers are permitted.

            >>> from sympy.mpmath import *
            >>> mp.dps = 15; mp.pretty = False
            >>> mpmathify(3.5)
            mpf('3.5')
            >>> mpmathify('2.1')
            mpf('2.1000000000000001')
            >>> mpmathify('3/4')
            mpf('0.75')
            >>> mpmathify('2+3j')
            mpc(real='2.0', imag='3.0')
Converts *x* to an ``mpf`` or ``mpc``. If *x* is of type ``mpf``,
        ``mpc``, ``int``, ``float``, ``complex``, the conversion
        will be performed losslessly.
Converts * x * to an mpf or mpc . If * x * is of type mpf mpc int float complex the conversion will be performed losslessly .
def convert(ctx, x, strings=True):
        """
        Converts *x* to an ``mpf`` or ``mpc``. If *x* is of type ``mpf``,
        ``mpc``, ``int``, ``float``, ``complex``, the conversion
        will be performed losslessly.

        If *x* is a string, the result will be rounded to the present
        working precision. Strings representing fractions or complex
        numbers are permitted.

            >>> from sympy.mpmath import *
            >>> mp.dps = 15; mp.pretty = False
            >>> mpmathify(3.5)
            mpf('3.5')
            >>> mpmathify('2.1')
            mpf('2.1000000000000001')
            >>> mpmathify('3/4')
            mpf('0.75')
            >>> mpmathify('2+3j')
            mpc(real='2.0', imag='3.0')

        """
        if type(x) in ctx.types: return x
        if isinstance(x, int_types): return ctx.make_mpf(from_int(x))
        if isinstance(x, float): return ctx.make_mpf(from_float(x))
        if isinstance(x, complex):
            return ctx.make_mpc((from_float(x.real), from_float(x.imag)))
        prec, rounding = ctx._prec_rounding
        if isinstance(x, rational.mpq):
            p, q = x._mpq_
            return ctx.make_mpf(from_rational(p, q, prec))
        if strings and isinstance(x, basestring):
            try:
                _mpf_ = from_str(x, prec, rounding)
                return ctx.make_mpf(_mpf_)
            except ValueError:
                pass
        if hasattr(x, '_mpf_'): return ctx.make_mpf(x._mpf_)
        if hasattr(x, '_mpc_'): return ctx.make_mpc(x._mpc_)
        if hasattr(x, '_mpmath_'):
            return ctx.convert(x._mpmath_(prec, rounding))
        return ctx._convert_fallback(x, strings)
def convert ( ctx , x , strings = True ) : if type ( x ) in ctx . types : return x if isinstance ( x , int_types ) : return ctx . make_mpf ( from_int ( x ) ) if isinstance ( x , float ) : return ctx . make_mpf ( from_float ( x ) ) if isinstance ( x , complex ) : return ctx . make_mpc ( ( from_float ( x . real ) , from_float ( x . imag ) ) ) prec , rounding = ctx . _prec_rounding if isinstance ( x , rational . mpq ) : p , q = x . _mpq_ return ctx . make_mpf ( from_rational ( p , q , prec ) ) if strings and isinstance ( x , basestring ) : try : _mpf_ = from_str ( x , prec , rounding ) return ctx . make_mpf ( _mpf_ ) except ValueError : pass if hasattr ( x , '_mpf_' ) : return ctx . make_mpf ( x . _mpf_ ) if hasattr ( x , '_mpc_' ) : return ctx . make_mpc ( x . _mpc_ ) if hasattr ( x , '_mpmath_' ) : return ctx . convert ( x . _mpmath_ ( prec , rounding ) ) return ctx . _convert_fallback ( x , strings )