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.
Created on 2010年12月08日 13:56 by skrah, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue10650.diff | skrah, 2012年08月25日 15:15 | review | ||
| Messages (10) | |||
|---|---|---|---|
| msg123603 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2010年12月08日 13:56 | |
I'm not sure if this is a documentation issue or a bug. If watchexp=0,
quantize() also allows any number of digits:
>>> x = Decimal("6885998238912213556789006667970467609814")
>>> y = Decimal("1e2")
>>> x.quantize(y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/decimal.py", line 2488, in quantize
'quantize result has too many digits for current context')
File "/usr/local/lib/python3.2/decimal.py", line 3925, in _raise_error
raise error(explanation)
decimal.InvalidOperation: quantize result has too many digits for current context
>>>
>>> x.quantize(y, watchexp=0)
Decimal('6.8859982389122135567890066679704676098E+39')
|
|||
| msg123607 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2010年12月08日 14:36 | |
NaNs, however, are decapitated:
>>> x = Decimal("NaN5357671565858315212612021522416387828577")
>>> y = 0
>>> x.quantize(y, watchexp=0)
Decimal('NaN8315212612021522416387828577')
|
|||
| msg164429 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2012年06月30日 21:56 | |
Ping. We have to decide if we need watchexp in _decimal. I've left it out so far since all I can gather from the docs is that it somehow behaves like _rescale. Can we deprecate it and replace it by a proper rescale? |
|||
| msg164430 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2012年06月30日 22:03 | |
I'd be happy to see watchexp deprecated. It feels like a leftover implementation artefact; its behaviour isn't properly defined anywhere, and as far as I can tell it has only a single testcase. |
|||
| msg164439 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2012年07月01日 00:40 | |
Does anyone know why watchexp was put there in the first place? http://speleotrove.com/decimal/daops.html#refquant If no motivation for this can be found, I agree with Mark that it should be deprecated and removed. |
|||
| msg164467 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2012年07月01日 09:42 | |
watchexp was available in rescale() from the beginning ... http://svn.python.org/view/sandbox/trunk/decimal/Decimal.py?revision=40721&view=markup ... and rescale() was renamed to quantize() in http://svn.python.org/view/sandbox/trunk/decimal/Decimal.py?revision=40909&view=markup rescale() was once part of the specification, but had identical semantics to quantize(), which is not specified to allow unlimited rescaling. I suppose the original rescale() in the sandbox had watchexp for convenience, in order to avoid two separate functions. watchexp made it into quantize(), probably because people thought there is a need for unlimited rescaling. This may be true, but I'd really prefer to expose rescale() as the unlimited version then. While it's unusual to just drop an API without deprecation, I think it's OK in this instance: Virtually all decimal code I saw needs to be cleaned up anyway because it uses tons of underscore methods from decimal.py. The only thing that worries me is that there might be code which *really* needs unlimited rescaling. Such code could of course also use a temporary context. So I propose this: Deprecate watchexp and leave it in the Python version for one release. The C version won't have watchexp from the start. After all, PEP-399 allows accelerator modules to implement a subset of the functionality of the Python version -- sometimes PEPs are a wonderful thing :). |
|||
| msg169141 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2012年08月25日 15:14 | |
Here's a patch deprecating watchexp. |
|||
| msg169448 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年08月30日 10:39 | |
New changeset 7db16ff9f5fd by Stefan Krah in branch 'default': Closes #10650: Deprecate the watchexp parameter of Decimal.quantize(). http://hg.python.org/cpython/rev/7db16ff9f5fd |
|||
| msg170085 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年09月09日 09:18 | |
New changeset e4ca4edee8bd by Stefan Krah in branch 'default': Closes #10650: Deprecate the watchexp parameter of Decimal.quantize(). http://hg.python.org/cpython/rev/e4ca4edee8bd |
|||
| msg217631 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年04月30日 17:16 | |
New changeset c2f827af02a2 by Stefan Krah in branch 'default': Issue #10650: Remove the non-standard 'watchexp' parameter from the http://hg.python.org/cpython/rev/c2f827af02a2 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:09 | admin | set | github: 54859 |
| 2014年04月30日 17:16:20 | python-dev | set | messages: + msg217631 |
| 2012年09月09日 09:18:53 | python-dev | set | messages: + msg170085 |
| 2012年08月30日 10:39:41 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg169448 resolution: fixed stage: resolved |
| 2012年08月25日 15:15:34 | skrah | set | files:
+ issue10650.diff keywords: + patch |
| 2012年08月25日 15:14:56 | skrah | set | messages: + msg169141 |
| 2012年07月01日 09:42:29 | skrah | set | messages: + msg164467 |
| 2012年07月01日 00:40:48 | rhettinger | set | messages: + msg164439 |
| 2012年06月30日 22:03:04 | mark.dickinson | set | messages: + msg164430 |
| 2012年06月30日 21:56:08 | skrah | set | nosy:
+ georg.brandl messages: + msg164429 |
| 2010年12月08日 14:36:13 | skrah | set | messages: + msg123607 |
| 2010年12月08日 13:56:10 | skrah | create | |