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 2015年01月12日 22:40 by abarnert, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| stdtypes.rst.diff | abarnert, 2015年01月12日 22:40 | Docs diff | review | |
| stdtypes.rst.diff | abarnert, 2015年01月12日 23:22 | based on review | review | |
| Messages (5) | |||
|---|---|---|---|
| msg233893 - (view) | Author: Andrew Barnert (abarnert) * | Date: 2015年01月12日 22:40 | |
In a recent thread on python-ideas (https://mail.python.org/pipermail/python-ideas/2015-January/030817.html), it was concluded that Python should not have a range-like type for floats in the stdlib, but there should be some simple discussion of the alternatives in the docs. The attached diff describes the issues, demonstrates the simplest reasonable algorithm, and links to a recipe on ActiveState (which builds the same algorithm into a lazy sequence, and links to other recipes with different alternatives). |
|||
| msg233897 - (view) | Author: Andrew Barnert (abarnert) * | Date: 2015年01月12日 23:22 | |
As suggested by the review: removing unnecessary parenthetical, changing "ulp" to "digit", and fixing the recipe link. |
|||
| msg234006 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2015年01月14日 05:48 | |
This is too much. Try for a brief reference. This section of the docs is primarily about how range() works. Linspace() is at best a tangential discussion and shouldn't interfere with the usability of range() docs (a tool we actually have and that is in common use). |
|||
| msg234009 - (view) | Author: Andrew Barnert (abarnert) * | Date: 2015年01月14日 06:45 | |
So something like the first version below? Or should even the example be inline, as in the second version below? (Apologies if the formatting gets screwed up pasting from docs to bugs.) --- Range objects are inappropriate for non-integral types, especially inexact types such as :class:`float`. In most cases, for such types, it is better to specify a count of numbers or intervals instead of a step size. For example: >>> start, stop, num = 0, 10, 11 >>> step = (stop-start)/(num-1) >>> [start + i*step for i in range(num)] [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] .. seealso:: * `linspace recipe <http://code.activestate.com/recipes/579000/>`_ for an example lazy sequence built on this algorithm, and links to alternatives. --- Range objects are inappropriate for non-integral types, especially inexact types such as :class:`float`. In most cases, it is better to specify a count of numbers or intervals instead of a step size, as in `[start + i*(stop-start)/(num-1) for i in range(num)]`. .. seealso:: * `linspace recipe <http://code.activestate.com/recipes/579000/>`_ for an example lazy sequence built on this algorithm, and links to alternatives. |
|||
| msg274667 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年09月06日 23:36 | |
New changeset bb8fe61d78a4 by Raymond Hettinger in branch 'default': Issue #23226: Add linspace() recipe to the docs https://hg.python.org/cpython/rev/bb8fe61d78a4 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:11 | admin | set | github: 67415 |
| 2016年09月06日 23:36:31 | rhettinger | set | status: open -> closed resolution: fixed |
| 2016年09月06日 23:36:06 | python-dev | set | nosy:
+ python-dev messages: + msg274667 |
| 2015年01月14日 16:11:52 | mark.dickinson | set | nosy:
+ mark.dickinson |
| 2015年01月14日 06:45:55 | abarnert | set | messages: + msg234009 |
| 2015年01月14日 05:48:10 | rhettinger | set | assignee: docs@python -> rhettinger messages: + msg234006 nosy: + rhettinger |
| 2015年01月12日 23:22:33 | abarnert | set | files:
+ stdtypes.rst.diff messages: + msg233897 |
| 2015年01月12日 22:40:48 | abarnert | create | |