This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skreft
Recipients skreft
Date 2011-11-07.05:14:43
SpamBayes Score 9.427087e-09
Marked as misclassified No
Message-id <1320642884.85.0.545330791342.issue13364@psf.upfronthosting.co.za>
In-reply-to
Content
By using tools like clonedigger is possible to spot some repeated code.
One file that caught my attention is Lib/decimal.py. It has many portions of duplicated code. 

Here is an example:
def logical_or(self, other, context=None):
        """Applies an 'or' operation between self and other's digits."""
        if context is None:
            context = getcontext()

        other = _convert_other(other, raiseit=True)

        if not self._islogical() or not other._islogical():
            return context._raise_error(InvalidOperation)

        # fill to context.prec
        (opa, opb) = self._fill_logical(context, self._int, other._int)

        # make the operation, and clean starting zeroes
        result = "".join([str(int(a)|int(b)) for a,b in zip(opa,opb)])
        return _dec_from_triple(0, result.lstrip('0') or '0', 0)

    def logical_xor(self, other, context=None):
        """Applies an 'xor' operation between self and other's digits."""
        if context is None:
            context = getcontext()

        other = _convert_other(other, raiseit=True)

        if not self._islogical() or not other._islogical():
            return context._raise_error(InvalidOperation)

        # fill to context.prec
        (opa, opb) = self._fill_logical(context, self._int, other._int)

        # make the operation, and clean starting zeroes
        result = "".join([str(int(a)^int(b)) for a,b in zip(opa,opb)])
        return _dec_from_triple(0, result.lstrip('0') or '0', 0)


What's the posture about this? Should this be fixed?

ps: Even more duplicated code is found in python 2.7.
History
Date User Action Args
2011-11-07 05:14:44skreftsetrecipients: + skreft
2011-11-07 05:14:44skreftsetmessageid: <1320642884.85.0.545330791342.issue13364@psf.upfronthosting.co.za>
2011-11-07 05:14:44skreftlinkissue13364 messages
2011-11-07 05:14:43skreftcreate