[issue8947] Provide as_integer_ratio() method to Decimal

2018-03-13 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

This issue has been superseded by #25928.

--
resolution: rejected -> duplicate
stage: patch review -> resolved
superseder:  -> Add Decimal.as_integer_ratio()

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2018-03-13 Thread Mark Dickinson

Mark Dickinson  added the comment:

Apologies: the title change was accidental. Reverted.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2018-03-13 Thread Mark Dickinson

Change by Mark Dickinson :


--
title: as_integer_ratio Decimal -> Provide as_integer_ratio() method to Decimal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-29 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

After discussions on IRC, I'm going to close this as rejected.  Convergence of 
the float and Decimal APIs is a nice idea, but in this case it's not clear that 
it really works.  In particular, for duck typing to be sensible, int and 
Fraction would also have to grow an as_integer_ratio method.  And that seems a 
superfluous when those two types already have the same functionality in the 
form of .numerator and .denominator attributes.

I also agree with Raymond that we shouldn't be fattening the decimal API 
without good reason.

Alexander:  wouldn't conversion to Fraction solve the issue in this case?  The 
Fraction constructor accepts floats, Decimal instances and ints directly.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-25 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Raymond, do you have any thoughts on this proposal?

--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-25 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

-0  I don't think we really need this (we've already got a reasonable 
conversion to Fraction).

In general, we should have a aversion to adding any methods to the decimal API 
because it is already very fat.  Adding more methods makes it harder to figure 
out which one is the right one to use.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-25 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

Raymond,

conversion to Fraction does not really help in my use case of supporting 
timedelta * Decimal by duck typing.  I can think of many other use cases where 
it will be helpful to accept either float or decimal without loss of precision. 
 Is there an alternative way to achieve that which does not require importing 
the decimal module first?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-11 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Updated patch, taking into account comments from merwok and exarkun on 
#python-dev:

 - remove doctests for infinity and nan, replace with a sentence
   explaining what happens for such inputs.
 - replace 'snAN' with saner spelling 'snan'.

--
Added file: http://bugs.python.org/file17627/issue8947_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-11 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

Nice implementation.  I wonder if the /5 loop can be eliminated by noting that 
/5 is *2 followed by decimal shift. (Probably not without fast decimal 
arithmetics.)

A few documentation nits:

1. In Decimal methods there is no consistency in referring to self.  I see  
given Decimal, the number, and the argument in three entries around 
as_integer_ratio().

2. Is there a reason that docstring is more detailed than manual entry?  I 
think the manual should describe exceptions.

3. Is there a reason to use different language for float.as_integer_ratio() and 
Decimal.as_integer_ratio()?

I know, A foolish consistency is the hobgoblin of little minds... - feel 
free to ignore my observations.

A tiny code nit: to me it would be clearer to start with d2 = d5 = -self._exp 
after the # Find d2, d5 ... comment.  For a moment I was puzzled why you 
promise d2 and d5, but then process d5 only.

Also, by the time of the if not self check, special case has been eliminated, 
so you can simply check self._int == 0.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-09 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-08 Thread Alexander Belopolsky

New submission from Alexander Belopolsky belopol...@users.sourceforge.net:

Here is my use case: recently implemented timedelta * float operation starts 
with converting float to an int ratio.  The same algorithm can be used for 
decimals, but they don't support as_integer_ratio().

--
components: Extension Modules
messages: 107345
nosy: belopolsky
priority: normal
severity: normal
status: open
title: Provide  as_integer_ratio() method to Decimal
type: feature request
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

This seems like a reasonable request to me;  I'd like to see a little bit of 
convergence between the float and Decimal APIs.

One difference between the two types that's worth noting is that the 
float.as_integer_ratio() method can never take a ridiculous amount of time or 
memory, whereas Decimal.as_integer_ratio() could:  e.g., consider 
Decimal('1e9').as_integer_ratio().  But I don't really see that as a 
problem.

--
nosy: +mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8947] Provide as_integer_ratio() method to Decimal

2010-06-08 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
assignee:  - mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8947
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com