[issue32683] isinstance is calling ob.__getattribute__ as a fallback instead of object.__class__.__get__

2021-12-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Changing the way isinstance works internally might prove > beneficial for such tools. ISTM you're advocating a design change rather than discussing a bug report. The python-ideas mail list would be a better forum than the tracker.

[issue46041] Add reference counting micro-optimizations to listobject.c

2021-12-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: The OP self-closed the PR. -- nosy: +rhettinger resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue46068] Change use of warnings.warn to logging.warning in a few places

2021-12-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: > The downside of making this change is that it may break 3rd party unit tests. I don’t see any upside. The modules in question have been stable for a good while. There’s no benefit to changing them. Also, there is no strong agreement that the stand

[issue46068] Change use of warnings.warn to logging.warning in a few places

2021-12-13 Thread Raymond Hettinger
Change by Raymond Hettinger : -- Removed message: https://bugs.python.org/msg408512 ___ Python tracker <https://bugs.python.org/issue46068> ___ ___ Python-bug

[issue46068] Change use of warnings.warn to logging.warning in a few places

2021-12-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: > The downside of making this change is that it may break 3rd party unit tests. I don’t see any upside. The modules in question have been stable for a good while. There’s no benefit to changing them. Also, there is no strong agreement that the stand

[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2021-12-14 Thread Raymond Hettinger
Change by Raymond Hettinger : -- status: pending -> closed ___ Python tracker <https://bugs.python.org/issue25864> ___ ___ Python-bugs-list mailing list Un

[issue46086] Add ratio_min() function to the difflib library

2021-12-15 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> tim.peters ___ Python tracker <https://bugs.python.org/issue46086> ___ ___ Python-bugs-list mailing list Un

[issue46085] OrderedDict iterator allocates di_result unnecessarily

2021-12-15 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +eric.snow ___ Python tracker <https://bugs.python.org/issue46085> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2021-12-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: This seems to be a temporary outage, expected to be restored in the first half of 2022. Source: https://www.usno.navy.mil/USNO/time/master-clock I'll look for an alternative time source that is currently online. -- assignee: docs@p

[issue45959] Teach pprint about dict views

2021-12-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: More accurate to say that it aspires to print in a single line ONLY if the content fits in the specified width. Otherwise, it prints vertically with appropriate indentation. Indeed, that is the entire purpose of the module; otherwise, we would just use

[issue46081] Document the msg argument for assertRaises

2021-12-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Eric that the current presentation is reasonable and better than adding boilerplate to every entry. It suffices that the docs cover the *msg* argument once and that each entry includes *msg* in its signature. Elsewhere in the docs we

[issue46092] Fix/update missing parameters in function signatures for Built-in Functions documentation.

2021-12-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: My understanding is that we're holding off on adding the slash notation to the main docs. The reason is that they are mostly unintelligible to the average user. -- nosy: +rhettinger ___ Python tracker &

[issue46095] Warning about iterate/modify has unwarranted detail

2021-12-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think this note can be removed. The tutorial now has coverage of mutating while iterating. That is the correct place for discussion of looping techniques. The part about the "internal counter" needs to be rewritten and moved to stdtypes.r

[issue46095] Improve SeqIter documentation

2021-12-17 Thread Raymond Hettinger
Change by Raymond Hettinger : -- title: Warning about iterate/modify has unwarranted detail -> Improve SeqIter documentation type: enhancement -> versions: +Python 3.11 ___ Python tracker <https://bugs.python.org/i

[issue37295] Possible optimizations for math.comb()

2021-12-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: For the small cases (say n < 50), we can get faster code by using a small (3Kb) table of factorial logarithms: double lf[50] = [log2(factorial(n)) for n in range(50)]; Then comb() and perm() can be computed quickly and in constant time using the

[issue37295] Possible optimizations for math.comb()

2021-12-18 Thread Raymond Hettinger
Change by Raymond Hettinger : -- Removed message: https://bugs.python.org/msg408865 ___ Python tracker <https://bugs.python.org/issue37295> ___ ___ Python-bug

[issue37295] Possible optimizations for math.comb()

2021-12-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: For the small cases (say n < 50), we can get faster code by using a small (3Kb) table of factorial logarithms: double lf[50] = [log2(factorial(n)) for n in range(50)]; Then comb() and perm() function can be computed quickly and in constant time us

[issue33567] Explicitly mention bytes and other buffers in the documentation for float()

2021-12-18 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue33567> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset aeb9ef4c7287fe367b6e9adcf1c5f994d5bc1a09 by Alex Waygood in branch 'main': bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109) https://github.com/python/cpyt

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for the PR. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue46131] Add PyType_FastSubclass for float

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for the suggestion, but I also concur with Serhiy. -- nosy: +rhettinger resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bug

[issue46131] Add PyType_FastSubclass for float

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 2ef06d412531d1163dbc72877c88aedf3ed82a25 by Matti Picus in branch 'main': bpo-46131: add fastpath for PyFloat_Check() (#30200) https://github.com/python/cpython/commit/2ef06d412531d1163dbc72877c88ae

[issue46131] Add PyType_FastSubclass for float

2021-12-19 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: +28429 pull_request: https://github.com/python/cpython/pull/30208 ___ Python tracker <https://bugs.python.org/issue46

[issue46131] Add PyType_FastSubclass for float

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 29ea68bd1dcf30842c2ed908a6d815bc1d90f484 by Raymond Hettinger in branch 'main': Revert "bpo-46131: add fastpath for PyFloat_Check() (GH-30200)" (GH-30208) https://github.com/python/cpython/commit/29ea68bd1dcf30842c2e

[issue46131] Add PyType_FastSubclass for float

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: That would not change that slot space is at a premium and that we prefer to use that space for high payoff optimizations. -- ___ Python tracker <https://bugs.python.org/issue46

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset d7537ac8e3a3ef15d2c5f3fe90e998618b6a97b9 by Miss Islington (bot) in branch '3.10': bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109) (GH-30206) https://github.com/python/cpyt

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 8bfb11a791679a33024c9857e082afed0d71e0b4 by Miss Islington (bot) in branch '3.9': bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109) (GH-30207) https://github.com/python/cpyt

[issue46132] Consider adding __slots__ to enums?

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: > In which case: consider this a feature request to > consider adding __slots__ ... A few thoughts: * Enumerations tend to be small, so a space savings likely isn't relevant. * In Python 3.11, the speed advantage of slots is now much smaller.

[issue37295] Possible optimizations for math.comb()

2021-12-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: > The problem here is that C gives no guarantees about accuracy of either log2 > or exp2 * The input table has hard-wired constants so there is no dependency on log2(). The inputs can be as exact as pi, tau, and e. * The C library's exp2

[issue37295] Possible optimizations for math.comb()

2021-12-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Stand by. I think I can implement this using only bit integer arithmetic. Will post tomorrow. -- ___ Python tracker <https://bugs.python.org/issue37

[issue37295] Possible optimizations for math.comb()

2021-12-20 Thread Raymond Hettinger
Change by Raymond Hettinger : -- Removed message: https://bugs.python.org/msg408963 ___ Python tracker <https://bugs.python.org/issue37295> ___ ___ Python-bug

[issue37295] Possible optimizations for math.comb()

2021-12-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Just curious about why the focus on the newer exp2 and log2? No particular reason, those happened to give slighy best results on macOS. Across compilers, plain exp() is likely the most mature. The quality of log() is irrelevant because it isn

[issue37295] Possible optimizations for math.comb()

2021-12-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Finv = [pow(fodd, -1, 2**64) for fodd in Fodd] This is a good trick. I had already experimented with separating factorials into an odd component and a shift count, but failed to get a speed-up because the divisions were slow. Having a table

[issue37295] Possible optimizations for math.comb()

2021-12-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: Am I correct in my understanding the 64 bits are always available, that 128 bit ints aren't universal, and that #ifdefs would be needed to extend the range of the table for systems that suppo

[issue46148] Optimize pathlib

2021-12-22 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +pitrou ___ Python tracker <https://bugs.python.org/issue46148> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46167] Parse assert (x == y, "Descriptive text") as statement params instead of a tuple

2021-12-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: > can we finally get rid of this language wart Yes, please. This is a pretty bad pitfall. I've seen this happen to people who've been conditioned by other languages to think of assert() as a macro or function: assert(sometest

[issue37295] Possible optimizations for math.comb()

2021-12-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Mark] > Should I code up my suggestion in a PR, Yes, go for it. -- ___ Python tracker <https://bugs.python.org/issu

[issue46182] `super` and descriptor clarification

2021-12-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: > "a base class ``B`` following ``A``" shouldn't it be "the base > class"? . After all, there is at most one base class following ``A`` No. There can be other classes in the chain. The first to match the lookup wins.

[issue46182] `super` and descriptor clarification

2021-12-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm reluctant to give any more space to the least important case, one that rarely arises in practice. The text in the PR is wordy and IMO creates more confusion that it solves. Per the dev-guide, we mostly avoid "preachy" text. No, &qu

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2021-12-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I believe that the behavior is so deeply ingrained in how argparse > works that it can't be changed. I think so as well. Handling arguments with a dash prefiew could be viewed as fundamental design flaw except for the fact that the module

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2021-12-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: > we should undo the deprecation of optparse in the documentation > (https://bugs.python.org/issue37103), since the stated justification > for that deprecation was that optparse will not be developed further. While optparse that it isn't b

[issue46187] Optionally support rounding for math.isqrt()

2021-12-27 Thread Raymond Hettinger
New submission from Raymond Hettinger : By default, isqrt(n) gives the floor of the exact square of n. It would be nice to have a flag to give a rounded result: y = isqrt(n, round=True) Alternatively, set a mode argument to one of {'floor', 'round', 'ceil&

[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: It's a little late, but I had a thought that code could be made more general, slightly faster, and much easier to understand if the popcount logic were to be replaced with a table that records how many bits of the factorial were shifted out to ma

[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: The shift table is an array of uint8_t, so it would be tiny (nearly fitting in one cache line). -- ___ Python tracker <https://bugs.python.org/issue37

[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: Also, it would help Serhiy's divide and conquer algorithm if the fast cases included the sides of Pascal's triangle rather than just the top: if n < TableSize and k < limits[n]: return comb_small(n, k) return comb_slow(n, k)

[issue46187] Optionally support rounding for math.isqrt()

2021-12-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Sweet! New one on me Tim already knows this but for the record the derivation is isn't tricky. With y=isqrt(x), then next root is at y+1 and the half way point is y+1/2 which isn't an integer. The corresponding squares are y**2, (y+1/2)*

[issue46190] Omit k in random.sample()

2021-12-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: If all you want is a sample where k==1, then use choice(). That is clearer and more efficient. The sample() function is for sampling without replacement which only makes sense when k > 1; otherwise, choice() or choices() is usually what you w

[issue46190] Omit k in random.sample()

2021-12-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: Okay. Thank for the quick response and the suggestion. I'm going to mark this one as closed. AFAICT, it distracts users from better solutions. I did a quick code search for sample(). The k==1 case is rare and in most cases the code should have

[issue46190] Omit k in random.sample()

2021-12-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: > My suggestion is not to set k=1 when omitted but to assign it a random value Sorry, I think that is just bizarre. Also, some populations are *very* large, so a minor user accident of omitting a parameter would result in a large unexpected out

[issue46190] Omit k in random.sample()

2021-12-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: The use case isn't bizarre. But having an API where that is the default behavior would be. From the point of view of most users, such an API would be unusual and surprising (I don't know of any other random package that has such

[issue46187] Optionally support rounding for math.isqrt()

2021-12-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: > So use decimal's ROUND_CEILING, ROUND_FLOOR, and ROUND_HALF_EVEN It think is would suck to have to type those out. Sorry, I think you're headed down the path of foolish consistency with an unrelated module and a more complicated topic.

[issue43639] Do not raise AttributeError on instance attribute update/deletion if data descriptor with missing __set__/__delete__ method found on its type

2021-12-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm going to decline this one. * It is arguable whether or not this behavior should have been designed in originally. However, changing it now is risky (as noted by Brett and Ethan). * Personally, I disagree with the notion of allowing a partial

[issue43639] Do not raise AttributeError on instance attribute update/deletion if data descriptor with missing __set__/__delete__ method found on its type

2021-12-29 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <https://bugs.python.org/issue43639> ___ ___ Python-bugs-list mailing list Un

[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: - if comb(n, k) != comb_small(n, k): + if comb(n, k) != comb_small(n, k) % Modulus: -- ___ Python tracker <https://bugs.python.org/issue37

[issue37295] Possible optimizations for math.comb()

2021-12-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Did you try running that? Yes. The table size was extended beyond what we have now. See attached file. -- Added file: https://bugs.python.org/file50526/comb_with_side_limits.py ___ Python tracker <

[issue37295] Possible optimizations for math.comb()

2021-12-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I'd be happy to change the implementation to use the trailing > zero counts as suggested. Thanks. I think that is a portability win and will made the code a lot easier to explain. -- ___ Pyt

[issue46187] Optionally support rounding for math.isqrt()

2021-12-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I'd similarly prefer to see recipes in the docs. Can you elaborate on why you prefer having this in the docs rather than as built-in functionality? For me, the rounded case would be the most common. I don't think I'm better-off writ

[issue46187] Optionally support rounding for math.isqrt()

2021-12-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: So, are you going to reject my feature request? I don't understand why. Both Mark and I have had valid use cases. The implementation is straight-forward and simple. The workaround is slow and non-obvious. The default remains the same so

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2021-12-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm thinking of this an a replacement example: >>> import json >>> import urllib.request >>> url = "http://worldtimeapi.org/api/timezone/America/Los_Angeles"; >>> with urllib.request.urlopen(url)

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2021-12-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: This is a little closer to the current code. Also it has a simpler and more universal url. from urllib.request import urlopen url = 'http://worldtimeapi.org/api/timezone/etc/UTC.txt' with urlopen(url) as request: for line in request:

[issue25478] Consider adding a normalize() method to collections.Counter()

2021-12-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: Withdrawing the suggestions for scaled_to() and scaled_by(). Am thinking that people are mostly better off with a dict comprehension where they can control the details of rounding and type conversions. -- resolution: -> rejected stage: pa

[issue45670] New .mapping attribute is broken for some existing uses of dict views

2021-12-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: To the list of four options I suggested for bidict, you can add one more. Create a feature request for a C implementation of collections.abc.KeyView. ISTM that your core issue is that bidict won't use the intended and guaranteed solution becaus

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2021-12-31 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +28532 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30315 ___ Python tracker <https://bugs.python.org/issu

[issue46095] Improve SeqIter documentation

2021-12-31 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +28533 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30316 ___ Python tracker <https://bugs.python.org/issu

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2022-01-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset ac4eea21722d9ed1604c9c30a8d29ae2ce74f1b2 by Raymond Hettinger in branch 'main': bpo-46079: Replace external link that is down for maintenance. (GH-30315) https://github.com/python/cpython/commit/ac4eea21722d9ed1604c9c30a8d29a

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2022-01-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 2bd73546959619b2519a7a830b3aaf190abeaf78 by Miss Islington (bot) in branch '3.10': bpo-46079: Replace external link that is down for maintenance. (GH-30315) (GH-30328) https://github.com/python/cpyt

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2022-01-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 72ffcb02f3ea6efcd3afe368996dc3ee89701898 by Miss Islington (bot) in branch '3.9': bpo-46079: Replace external link that is down for maintenance. (GH-30315) (GH-30329) https://github.com/python/cpyt

[issue46079] [doc] Broken URL in "Brief Tour of the Standard Library"

2022-01-01 Thread Raymond Hettinger
Change by Raymond Hettinger : -- priority: low -> normal resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python

[issue46095] Improve SeqIter documentation

2022-01-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset a09bc3a404befca197b5d9959a9c62110ee61d77 by Raymond Hettinger in branch 'main': bpo-46095: Improve SeqIter documentation. (GH-30316) https://github.com/python/cpython/commit/a09bc3a404befca197b5d9959a9c62

[issue46095] Improve SeqIter documentation

2022-01-01 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue46095] Improve SeqIter documentation

2022-01-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset e9783d6434f28dfb0b531c6760f7642fc7ede278 by Miss Islington (bot) in branch '3.10': bpo-46095: Improve SeqIter documentation. (GH-30316) (GH-30330) https://github.com/python/cpython/commit/e9783d6434f28dfb0b531c6760f764

[issue46224] doc: Fix bisect example using mutable function default

2022-01-02 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: docs@python -> rhettinger ___ Python tracker <https://bugs.python.org/issue46224> ___ ___ Python-bugs-list mai

[issue46224] doc: Fix bisect example using mutable function default

2022-01-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm going to decline this one. It seems that you're applying a stylistic guideline to a case where it isn't needed and where it doesn't improve the example. In this case, the example doesn't mutate the input, so the code

[issue46228] argparse docs: default for prog= in ArgumentParser() should be basename of argv[0], not argv[0], to match behaviour

2022-01-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thank you for the PR. -- nosy: +rhettinger resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue46187] Optionally support rounding for math.isqrt()

2022-01-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: > divmod() allows easy emulation of any division rounding mode It could be used that way, but generally isn't. Please consider my original request. Adding a keyword argument is easy, clear, and has almost no mental overhead. It reads very

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2022-01-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think this is a door we should open: >>> Fraction(3.5, 2.5) Fraction(7, 5) This currently raises a useful exception: TypeError: both arguments should be Rational instances That is especially helpful in avoiding c

[issue46182] `super` and descriptor clarification

2022-01-02 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: docs@python -> rhettinger resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python

[issue46257] Convert statistics sum of squares to a single pass algorithm

2022-01-04 Thread Raymond Hettinger
New submission from Raymond Hettinger : The existing code makes two passes, one to compute the mean and another to compute the sum of squared differences from the mean. A consequence of making two passes is that iterator inputs must be converted to a list before processing. This throws

[issue46257] Convert statistics sum of squares to a single pass algorithm

2022-01-04 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +28611 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30403 ___ Python tracker <https://bugs.python.org/issu

[issue46259] float formatting error?

2022-01-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: The two numbers you gave become the same when rounded to the limited internal precision used by floats. >>> 1.12345678901234 == 1.123456789011 True When it comes to displaying the number, Python tries to show the shortest possible memb

[issue46257] Convert statistics sum of squares to a single pass algorithm

2022-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 43aac29cbbb8a963a22c334b5b795d1e43417d6b by Raymond Hettinger in branch 'main': bpo-46257: Convert statistics._ss() to a single pass algorithm (GH-30403) https://github.com/python/cpython/commit/43aac29cbbb8a963a22c334b5b795d

[issue46257] Convert statistics sum of squares to a single pass algorithm

2022-01-05 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue46266] Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`

2022-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think these were intended to be public. like "January" and "February", they were for internal use. Presumably, this is because the names vary across languages. In the absence of some demonstrated user need, w

[issue46266] Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`

2022-01-05 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue46266] Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`

2022-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: > The problem is they are documented here: > https://docs.python.org/3/library/calendar.html#calendar.setfirstweekday Well, that does make them public, so we have to go forward. -- resolution: rejected -> status: close

[issue46270] Comparison operators in Python Tutorial 5.7

2022-01-05 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: docs@python -> rhettinger nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue46270> ___ ___ Python-

[issue46272] Fix bitwise and logical terminology in python.gram

2022-01-05 Thread Raymond Hettinger
New submission from Raymond Hettinger : In the section "Comparison operators", all mentions of "bitwise" should be "binary". The section "Logical operators" should be retitled "Bitwise operators". See: https://docs.python.org/3/re

[issue46270] Comparison operators in Python Tutorial 5.7

2022-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: It may seem weird, but a "membership operator" is a kind of "comparison operator".¹ They can even participate in chaining, 'a < b in s < c` is equivalent to `(a < b) and (b in s) and (b < c)`. I'm propose

[issue46266] Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`

2022-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset e5894ca8fd05e6a6df1033025b9093b68baa718d by Nikita Sobolev in branch 'main': bpo-46266: Add calendar day of week constants to __all__ (GH-30412) https://github.com/python/cpython/commit/e5894ca8fd05e6a6df1033025b9093

[issue46266] Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`

2022-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for the PR. Sorry that I missed the one public reference in the docs. -- resolution: -> fixed status: open -> closed versions: -Python 3.10, Python 3.9 ___ Python tracker <https://bugs.p

[issue46270] Comparison operators in Python Tutorial 5.7

2022-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: Container is correct. Containers are defined as being anything that supports the "in" and "not in" operators. That includes sequences (str, list, tuple, bytes, bytearray), mappings (dict, ChainMap, defaultdict), and sets (froz

[issue46272] Fix bitwise and logical terminology in python.gram

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: > comparison::= or_expr (comp_operator or_expr)* So, the meaning of these names like this is, "lt followed by an optional bitwise_or expression"? compare_op_bitwise_or_pair[CmpopExprPair*]: | eq_bitwise_or | not

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: #244 is a false positive. The value of new_state[i] on line 454 was initialized on line 442 with: new_state[i] = (uint32_t)element. #387 is also a false positive. There is an assertion on the previous line that the item != NULL. That assertion passes

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: #324 and #325 are false positives. The result variable is initialized in the preceding lines: if (len_a == length) { left = *((volatile const unsigned char**)&a); result = 0; } if (len_a != length) { left

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: #382 is false positive. The "iterable" variable is only accessed when known to not be NULL. # Line 970 if (iterable != NULL) { if (set_update_internal(so, iterable)) { Py_DECREF(so); r

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: #420 and #421 are false positives. The value of "c" is initialized a few lines before use. for (;;) { c = tok_nextc(tok); ... } ... tok_backup(tok, c); if (c == '#

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: The dead store notices for all the DISPATCH calls in ceval.c are false positives. The "oparg" value is used in many of the case statements. The dead store notices the clinic generated code all relate to "!--noptargs" which is sometim

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: #511 and #512 are false positives. The "kind" variable is indeed uninitialized in the bytes_writer case: else if (bytes_writer) { *bytes_str = _PyBytesWriter_Prepare(bytes_writer, *bytes_str, strlen); if (*bytes_s

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: #533, #534, #535, and #536 are false positives for the same reason as #511 and #512. The two "dead stores" in 533 and 534 match the "uninitialized variables" in 535 and 536. -- ___ Py

[issue46280] About vulnerabilities in Cpython native code

2022-01-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: #584 and #585: The code is correct but there are dead stores only when the asserts are turned off: 2635. carry = v_lshift(w->ob_digit, w1->ob_digit, size_w, d); 2636. assert(carry == 0); Elsewhere we use ifdefs around code like t

  1   2   3   4   5   6   7   8   9   10   >