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 2008年03月25日 15:37 by phd, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg64488 - (view) | Author: Oleg Broytman (phd) * | Date: 2008年03月25日 15:37 | |
Decimal(u'123').to_eng_string() returns unicode in Python 2.5.2. That's probably due to the optimization in decimal module, after which decimal stores coefficient (mantissa) as a str, and doesn't coerce input to str. See the thread at http://mail.python.org/pipermail/python-dev/2008-March/078189.html |
|||
| msg64490 - (view) | Author: Facundo Batista (facundobatista) * (Python committer) | Date: 2008年03月25日 15:51 | |
Decimal needs to grow something like the following near the top of the module: try: _bytes = bytes except NameError: # 2.5 or earlier _bytes = str and then use _bytes instead of str as appropriate throughout the rest of the module. This will solve the actual problem, and scales well with 2.6 and 3k. |
|||
| msg64504 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2008年03月25日 18:41 | |
I'm not sure that converting to bytes for Python 3.0 is going to be a simple change. For one thing, most of the arithmetic functions have to do the reverse conversion (int -> str/bytes) at some point. At the moment, an int -> bytes conversion has to go through unicode (I think); something like bytes(str(n), 'ascii'), so it's not 100% clear that replacing str with bytes is going to produce a speed gain. For now, I'll get the fix for the 2.5/2.6 problem in (it only involves changing 3 lines in decimal.py, along with adding a few extra tests). Changing str -> bytes in 3.0 needs more careful thought, and some benchmarking. |
|||
| msg64505 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2008年03月25日 19:02 | |
str -> unicode regression fixed in r61904, r61906. (I backported the fix to 2.5; it's not absolutely clear that it's worth it, but this *is* a bug, and it seems worth not letting the various decimal.py versions diverge too much.) |
|||
| msg64522 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2008年03月25日 21:38 | |
The original bug here is fixed, so I'm closing this issue. I've opened a separate issue (issue 2486) for discussing changing the Decimal coefficient from str to bytes. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:32 | admin | set | github: 46734 |
| 2008年03月25日 21:38:31 | mark.dickinson | set | status: open -> closed resolution: fixed messages: + msg64522 |
| 2008年03月25日 19:02:43 | mark.dickinson | set | messages: + msg64505 |
| 2008年03月25日 18:41:54 | mark.dickinson | set | messages: + msg64504 |
| 2008年03月25日 15:51:08 | facundobatista | set | nosy:
+ facundobatista messages: + msg64490 |
| 2008年03月25日 15:42:08 | mark.dickinson | set | assignee: mark.dickinson nosy: + mark.dickinson versions: + Python 2.6 |
| 2008年03月25日 15:37:13 | phd | create | |