New submission from Serhiy Storchaka:

Proposed patch makes following things:

1. Rewrite error messages in float.as_integer_ratio() and Python implementation 
of Decimal.as_integer_ratio() in more general form, not mentioning 
as_integer_ratio(), as in C implementation of Decimal.as_integer_ratio().

2. Use Decimal.as_integer_ratio() to convert Decimal to Fraction.

3. Get rid of additional checks in Fraction constructor that raise errors with 
appropriate messages, since new error messages from as_integer_ratio() are 
appropriate enough.

This speeds up creating a Fraction from float and Decimal 2 to 3 times.

----------
components: Interpreter Core, Library (Lib)
files: fraction_from_floating.patch
keywords: patch
messages: 257145
nosy: facundobatista, mark.dickinson, rhettinger, serhiy.storchaka, skrah
priority: normal
severity: normal
stage: patch review
status: open
title: Optimize converting float and Decimal to Fraction
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file41442/fraction_from_floating.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25971>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to