[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters
Tim Peters added the comment: @Batuhan, fine by me if you want to take this on! It should be relatively easy. But Mark wrote the code, so it's really up to him. While I doubt this, he may even argue that it's working correct

[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters
Tim Peters added the comment: Yup, you have a point there! :-) I guess I'm just not used to 0 being a multiplicative identity. Don't know what other systems do. Playing with Maxima, modulo 1 it seems to think 0 is the inverse of everything _except_ for 0. `inv_mod(0, 1)` retur

[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters
Tim Peters added the comment: Mark, to save you the hassle, I'm closing this myself now. Thanks for the feedback! -- assignee: -> tim.peters resolution: -> not a bug stage: patch review -> resolved status: open -> closed _

[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters
Tim Peters added the comment: I don't have a problem with the trivial ring - I wasn't being that high-minded ;-) I was testing a different inverse algorithm, and in the absence of errors checked that minv(a, m) * a % m == 1 for various a and m >= 0. Of course that faile

[issue37810] ndiff reports incorrect location when diff strings contain tabs

2019-08-21 Thread Tim Peters
Change by Tim Peters : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue37454] Clarify docs for math.log1p()

2019-08-23 Thread Tim Peters
Tim Peters added the comment: > Sometimes you guys make me feel dumb as a rock. I expect we all do that favor for each other at times ;-) -- ___ Python tracker <https://bugs.python.org/issu

[issue37945] test_locale failing

2019-08-25 Thread Tim Golden
New submission from Tim Golden : On a Win10 machine I'm consistently seeing test_locale (and test__locale) fail. I'll attach pythoninfo. == ERROR: test_getsetlocale_issue1813 (test.test_locale.TestMis

[issue37945] test_locale failing

2019-08-25 Thread Tim Golden
Tim Golden added the comment: Ok; so basically this doesn't work: import locale locale.setlocale(locale.LC_CTYPE, locale.getdefaultlocale()) It gives "locale.Error: unsupported locale setting" which comes from https://github.com/python/cpython/blob/master/Modules/_loca

[issue37945] test_locale failing

2019-08-25 Thread Tim Golden
Tim Golden added the comment: Just to save you looking, the code in https://github.com/python/cpython/blob/master/Modules/_localemodule.c#L107 converts the 2-tuple to lang.encoding form so the C module is seeing "en_GB.cp1252" --

[issue37945] test_locale failing

2019-08-25 Thread Tim Golden
Tim Golden added the comment: Thanks, Eryk. Your explanation is as clear as always. But my question is, then: why is my machine failing this test [the only one which uses this two-part locale] and not the buildbots or (presumably) any other Windows developer

[issue37945] test_locale failing

2019-08-26 Thread Tim Golden
Tim Golden added the comment: I agree that that could be a fix. And certainly, if it turns out that this could never have (recently) worked as Eryk is suggesting, then let's go for it. But I still have this uneasy feeling that it's not failing on the buildbots and I can't se

[issue37945] test_locale failing

2019-08-26 Thread Tim Golden
Tim Golden added the comment: This feels like one of those changes where what's in place is clearly flawed but any change seems like it'll break stuff which people have had in place for years. I'll try to look at a least-breaking change but I'm honestly not sure what t

[issue37992] Change datetime.MINYEAR to allow for negative years

2019-08-31 Thread Tim Peters
Tim Peters added the comment: This just isn't going to happen. There's no agreement to be had. For example, the proleptic Gregorian calendar _does_ have a "year 0", and so also does ISO 8601. Version 1.0 of the XML schema spec did not have a year 0, but _claimed_ to

[issue38012] Python Fuction min is case sentive ?

2019-09-02 Thread Tim Peters
Tim Peters added the comment: This has nothing in particular do with `min()`. As strings, 'I' < 'i', and 'F' < 'I'. For example, >>> 'I' < 'i' True >>> sorted("InFinity") ['F', '

[issue38012] Python Fuction min is case sentive ?

2019-09-02 Thread Tim Peters
Tim Peters added the comment: > Also, THE min("Infinity") is priniting "I". Practically, > the minimum value is "e" right ? Sorry, I have no idea what "practically" means to you. It's just a fact that all uppercase ASCII letters compare l

[issue38033] Use After Free: PyObject_Free (valgrind)

2019-09-04 Thread Tim Peters
Tim Peters added the comment: You're probably chasing ghosts ;-) Please read about what needs to be done to use valgrind successfully with Python: https://github.com/python/cpython/blob/master/Misc/README.valgrind -- nosy: +tim.peters title: Use After Free: PyObject_Free -

[issue24416] Have date.isocalendar() return a structseq instance

2019-09-06 Thread Tim Peters
Tim Peters added the comment: I favor making this a structseq, primarily based on Paul's attempt to find actual use cases, which showed that named member access would be most useful most often. I have no intuition for that myself, because while I wrote the original functions here,

[issue24416] Have date.isocalendar() return a structseq instance

2019-09-07 Thread Tim Peters
Change by Tim Peters : -- assignee: -> rhettinger ___ Python tracker <https://bugs.python.org/issue24416> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue38060] precedence (relational, logical operator)not working with single value

2019-09-08 Thread Tim Peters
Tim Peters added the comment: It's working fine. What do you expect? For example, 9 or 7 > "str" groups as 9 or (7 > "str") 9 is evaluated for "truthiness" first, and since it's not 0 it's considered to be true. That

[issue38060] precedence (relational, logical operator)not working with single value

2019-09-08 Thread Tim Peters
Tim Peters added the comment: I'm sorry you're not satisfied with the answer, but I'm a bona fide expert on this and you're not going to get anyone to agree with your confusion here ;-) But the bug tracker is not the right place for tutorials. Please take this up

[issue38060] precedence (relational, logical operator)not working with single value

2019-09-09 Thread Tim Peters
Tim Peters added the comment: @sangeetamchauhan, the reply you got in the image you attached was in error - kind of. Section "6.16. Operator precedence" defines Python's operator precedence: https://docs.python.org/3/reference/expressions.html#index-92 """

[issue38060] precedence (relational, logical operator)not working with single value

2019-09-09 Thread Tim Peters
Tim Peters added the comment: BTW, the docs also spell out that "and" and "or" ALWAYS evaluate their left operand before their right operand, and don't evaluate the right operand at all if the result of evaluating the left operand is true (for "or&quo

[issue38060] precedence (relational, logical operator)not working with single value

2019-09-10 Thread Tim Peters
Tim Peters added the comment: Ah, so you were expecting an error! That helps. But that's not how the language works, or how it's documented to work, as has been explained in quite some detail already. In general, precedence _constrains_ evaluation order, but does not _define

[issue38096] Clean up the "struct sequence" / "named tuple" docs

2019-09-10 Thread Tim Peters
New submission from Tim Peters : The Glossary has this entry: """ struct sequence A tuple with named elements. Struct sequences expose an interface similar to named tuple in that elements can be accessed either by index or as an attribute. However, they do not have any of

[issue38060] precedence (relational, logical operator)not working with single value

2019-09-10 Thread Tim Peters
Tim Peters added the comment: I don't believe that would improve the docs, but suit yourself. This is hardly a FAQ, but instead a peculiar case where, for whatever reason, someone is saying "I'm puzzled by what `or` does, but didn't read the docs for `or`". Mo

[issue38096] Clean up the "struct sequence" / "named tuple" docs

2019-09-11 Thread Tim Peters
Tim Peters added the comment: Paul, please heed what Raymond said: it's not good to merge another core dev's PR unless they ask you to. Besides what Raymond said, a core dev may well check in incomplete work for any number of reasons (e.g., to see how the automated test run

[issue36274] http.client cannot send non-ASCII request lines

2019-09-11 Thread Tim Burke
Tim Burke added the comment: Fair enough. Seems kinda related to https://bugs.python.org/issue30458 -- looks like it was a fun one ;-) I think either approach would work for me; my existing work-around doesn't preclude either, particularly since I want it purely for testing purposes.

[issue37945] test_locale failing

2019-09-11 Thread Tim Lyons
Change by Tim Lyons : -- nosy: +guy.linton ___ Python tracker <https://bugs.python.org/issue37945> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38105] hash collision when hash(x) == -2 causes many calls to __eq__

2019-09-11 Thread Tim Peters
Tim Peters added the comment: Note that you can contrive similar cases with positive hash codes too. For example, force both hash codes to 2**60 - 2. The salient points are that 0 * 5 is congruent to 0 mod any power of 2, while -2 * 5 = -10 is congruent to -2 mod 8, so they're

[issue38105] hash collision when hash(x) == -2 causes many calls to __eq__

2019-09-12 Thread Tim Peters
Tim Peters added the comment: Something that may be slightly worth pursuing: in j = (5*j + 1) % 2**power to get a full-period sequence hitting every integer in range(2**power) exactly once, the multiplier (5) is a bit delicate (it has to be congruent to 1 mod 4), but the addend (1

[issue38105] hash collision when hash(x) == -2 causes many calls to __eq__

2019-09-12 Thread Tim Peters
Tim Peters added the comment: A more principled change would be to replace instances of this: i = (i*5 + perturb + 1) & mask; with this: i = (i*5 + (perturb << 1) + 1) & mask; The latter spelling has no fixed points. That's easy to see: `(perturb << 1)

[issue38105] hash collision when hash(x) == -2 causes many calls to __eq__

2019-09-12 Thread Tim Peters
Tim Peters added the comment: Following up, at least under Visual Studio for x86 "it's free" to change the code to add in `perturb` shifted left. The C source: perturb >>= PERTURB_SHIFT; i = (i*5 + (perturb << 1) + 1) & mask; compiles to this, wher

[issue30701] Exception parsing certain invalid email address headers

2019-09-12 Thread Tim Bell
Tim Bell added the comment: This appears to be the same issue as subsequently reported in #34155. -- ___ Python tracker <https://bugs.python.org/issue30

[issue24416] Have date.isocalendar() return a structseq instance

2019-09-13 Thread Tim Peters
Tim Peters added the comment: I agree with Raymond here: using collections.namedtuple is fine in the pure Python version. Since Raymond checked in doc changes to purge the phrase "struct sequences" (thanks again for that!), it's consistent with everything else now for t

[issue38105] hash collision when hash(x) == -2 causes many calls to __eq__

2019-09-13 Thread Tim Peters
Tim Peters added the comment: Some results of the "add perturb shifted left 1 instead" approach. These come from using an old pile of Python code I have that allows for easy investigation of different collision probe strategies. - As expected, because it has no fixed points, th

[issue38194] Consistently add exist_ok / missing_ok parameters to directory creation/deletion functions

2019-09-16 Thread Tim Hoffmann
New submission from Tim Hoffmann : The following functions accept exist_ok/missing_ok parameters: - Path.mkdir(exist_ok) - os.makedirs(exist_ok) - shutil.copytree(dirs_exist_ok) - (https://bugs.python.org/issue20849) - Path.unlink(missing_ok) - (https://bugs.python.org/issue33123) For

[issue38200] Adding itertools.pairwise to the standard library?

2019-09-18 Thread Tim Peters
Tim Peters added the comment: There's an eternal culture clash here: functional languages have a long history of building in just about everything of plausible use, regardless of how trivial to build on other stuff. This started when LISP was barely released before (cadr x) was intro

[issue38216] Fix for issue30458 prevents crafting invalid requests

2019-09-18 Thread Tim Burke
Change by Tim Burke : -- nosy: +tburke ___ Python tracker <https://bugs.python.org/issue38216> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)

2019-09-19 Thread Tim Peters
Tim Peters added the comment: Sorry, but there was nothing wrong with the CHECK_SMALL_INT macro, to my eyes, to begin with - except that it was burdened with an over-elaborate "do ... while(0)" wrapper. Not all macros are _intended_ to be "cheap functions". Lik

[issue38216] Fix for issue30458 prevents crafting invalid requests

2019-09-20 Thread Tim Burke
Tim Burke added the comment: > Since at least one project is known to have been impacted, it's not > unreasonable to expect that more will be. I can confirm at least one other: OpenStack Swift's stable jobs have been broken by https://github.com/python/cpython/commit/bb80

[issue38216] Fix for issue30458 (HTTP Header Injection) prevents crafting invalid requests

2019-09-20 Thread Tim Burke
Tim Burke added the comment: Something like this for 3.7, say? I should probably go add some tests in test_httplib.py (for example, to demonstrate that http.client can still send a raw #, even if urllib appropriately drops the fragment), but I wanted some feedback on whether this is even an

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-27 Thread Tim Peters
Tim Peters added the comment: tp_clear implementations are necessary to reclaim trash cycles. They're always best practice for objects that may be in trash cycles. tuples are just "cute rebels" that way ;-) Best guess is that the (some) extension isn't playing by t

[issue38305] https://2.python-requests.org/ missing TLS certicate

2019-09-28 Thread Tim Laurence
New submission from Tim Laurence : I am unsure how to route this given the recent transition of Requests to PSF so my apologies if this is the wrong spot. The page where I think most people look for Requests documentation appears to be broken https://2.python-requests.org/ When I look

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-28 Thread Tim Peters
Tim Peters added the comment: > call_func and remove are part of a reference cycle. A forced garbage > collection breaks the cycle and removes the two objects, but they are > not removed in the expected order: > > * first: call_func > * then: remove > > The crash

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-29 Thread Tim Peters
Tim Peters added the comment: Sorry, this is very hard for me - broke an arm near the shoulder on Tuesday, and between bouts of pain and lack of good sleep, concentration is nearly impossible. Typing with one hand just makes it worse :-( We must know that F is trash, else we never would

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-29 Thread Tim Peters
Tim Peters added the comment: Fleshing out something I left implicit: if there's a trash object T with a finalizer but we don't KNOW it's trash, we won't force-run its finalizer before delete_garbage starts either. Then, really the same thing: we may tp_clear som

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-29 Thread Tim Peters
Tim Peters added the comment: > Note that my flags show that W *is* in 'unreachable'. It has > to be otherwise F would not have tp_clear called on it. Right! W holds a strong reference to F, so if W were thought to be reachable, F would be too. But F isn't. >

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-29 Thread Tim Peters
Tim Peters added the comment: > I see that handle_weakrefs() calls _PyWeakref_ClearRef() and that > will clear the weakref even if it doesn't have callback. So, I > think that takes care for the hole I was worried about. I.e. a > __del__ method could have a weakref to an

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-29 Thread Tim Peters
Tim Peters added the comment: Ah, nevermind my last comment - yes. handle_weakrefs will clear all weakrefs to the objects we know are trash. -- ___ Python tracker <https://bugs.python.org/issue38

[issue38324] [Windows] test_locale and test__locale failures on Windows

2019-09-30 Thread Tim Golden
Tim Golden added the comment: This is the existing issue https://bugs.python.org/issue37945 which I haven't had time to progress. Please feel free to follow up -- ___ Python tracker <https://bugs.python.org/is

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-30 Thread Tim Peters
Tim Peters added the comment: > Would the attached rough patch (gc_disable_wr_callback.txt) > be a possible fix? When we find W inside handle_weakrefs(), > we mark it as trash and will not execute the callback. It's semantically correct since we never wanted to execute a c

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-30 Thread Tim Peters
Tim Peters added the comment: Neil, how about this alternative: leave the weakref implementation alone. If we find a trash weakref, simply clear it instead. That would prevent callbacks too, & would also prevent the weakref from being used to retrieve its possibly-trash-too refe

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-30 Thread Tim Peters
Tim Peters added the comment: Neil, my brief msg 10 minutes before yours suggested the same thing (just clear the weakref), so it must be right ;-) -- ___ Python tracker <https://bugs.python.org/issue38

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-30 Thread Tim Peters
Tim Peters added the comment: FWIW, I agree with Neil in all respects about the release: his patch is the best approach, plugs segfaulting holes that have been there for many years, and the earlier patches aren't needed anymore. -- ___ P

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-30 Thread Tim Peters
Tim Peters added the comment: It's unclear to me whether BPO-33418 was a bug or a contrived annoyance :-) If someone believes it was worth addressing, then what it did is the only way to fix it, so should be restored now. -- ___ Python tr

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-30 Thread Tim Peters
Tim Peters added the comment: Yes, it's better to have tp_clear than not for a variety of reasons (including setting examples of best practice). Best I can tell, the patch for BPO-33418 was reverted _only_ to worm around the crash in _this_ report. That's no longer needed. Or

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-09-30 Thread Tim Peters
Tim Peters added the comment: Ɓukasz, all type objects have tp_clear slots, and always did. The patch in question put something useful in the function object's tp_clear slot instead of leaving it NULL. No interface, as such, changes eithe

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-10-01 Thread Tim Peters
Tim Peters added the comment: Neil, about this comment: # - ct is not yet trash (it actually is but the GC doesn't know because of # the missing tp_traverse method). I believe gc should know ct is trash. ct is in the cf list, and the latter does have tp_traverse. What gc won&#

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-10-03 Thread Tim Peters
Tim Peters added the comment: Loose ends. Telegraphic because typing is hard. 1. Docs should be changed to encourage implementing the full gc protocol for "all" containers. Spell out what can go wrong if they don't. Be upfront about that history has, at times, proved us

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-10-03 Thread Tim Peters
Tim Peters added the comment: My understanding is that the CFFI types at issue don't even have Py_TPFLAGS_HAVE_GC. They're completely invisible to gc. As Armin says in the CFFI issue report (linked to earlier), he never got the impression from the docs that he needed to implemen

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-10-04 Thread Tim Peters
Tim Peters added the comment: BTW, the phrase "missing tp_traverse" is misleading. If an object with a NULL tp_traverse appears in a gc generation, gc will blow up the next time that generation is collected. That's always been so - gc doesn't check whether tp_trave

[issue38373] List overallocation strategy

2019-10-04 Thread Tim Peters
Tim Peters added the comment: WRT pymalloc, it will always copy on growing resize in this context. A pymalloc pool is dedicated to blocks of the same size class, so if the size class increases (they're 16 bytes apart now), the data must be copied to a different pool (dedicated to bloc

[issue38373] List overallocation strategy

2019-10-04 Thread Tim Peters
Tim Peters added the comment: Don't know. Define "the problem" ;-) As soon as the allocation is over 512 bytes (64 pointers), it's punted to the system malloc family. Before then, do a relative handful of relatively small memcpy's really matter? pymalloc is f

[issue38379] finalizer resurrection in gc

2019-10-05 Thread Tim Peters
New submission from Tim Peters : While people are thinking about gc, zleak.py shows a small bug, and a possible opportunity for improvement, in the way gc treats finalizers that resurrect objects. The bug: the stats keep claiming gc is collecting an enormous number of objects, but in fact

[issue38379] finalizer resurrection in gc

2019-10-06 Thread Tim Peters
Tim Peters added the comment: Just noting that check_garbage() currently only determines which trash objects are now directly reachable from outside. To be usable for the intended purpose, it would need to go on to compute which trash objects are reachable from those too. Maybe a new

[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-10-06 Thread Tim Peters
Tim Peters added the comment: I don't have a problem with the current behavior (early out on zero, even if later arguments are senseless). So: > * Just document that there is an early-out for zero. -- ___ Python tracker <https://bugs

[issue38379] finalizer resurrection in gc

2019-10-08 Thread Tim Peters
Change by Tim Peters : -- keywords: +patch pull_requests: +16241 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/16658 ___ Python tracker <https://bugs.python.org/issu

[issue38379] finalizer resurrection in gc

2019-10-08 Thread Tim Peters
Tim Peters added the comment: PR 16658 aims to repair the stats reported. -- ___ Python tracker <https://bugs.python.org/issue38379> ___ ___ Python-bugs-list m

[issue38379] finalizer resurrection in gc

2019-10-09 Thread Tim Peters
Tim Peters added the comment: New changeset ecbf35f9335b0420cb8adfda6f299d6747a16515 by Tim Peters in branch 'master': bpo-38379: don't claim objects are collected when they aren't (#16658) https://github.com/python/cpython/commit/ecbf35f9335b0420cb8a

[issue38379] finalizer resurrection in gc

2019-10-09 Thread Tim Peters
Tim Peters added the comment: I checked the stat fix into master, but GH failed to backport to 3.7 or 3.8 and I'm clueless. More info in the PR. Does someone else here know how to get a backport done? -- stage: patch review -> backport needed versions: +Python 3.7, Py

[issue38437] Set GC_DEBUG for debug builds of the interpreter

2019-10-10 Thread Tim Peters
Tim Peters added the comment: +1. This code got quite brittle when they decided to fit two pointers, a fat integer, and 3 flags into a struct with room for only the two pointers ;-) It's a mine field now. Enabling one of the few automated mine detectors is thoroughly sen

[issue38379] finalizer resurrection in gc

2019-10-13 Thread Tim Peters
Tim Peters added the comment: Everything here has been addressed, so closing this. zleak.py can apparently run forever now without leaking a byte :-) -- resolution: -> fixed stage: patch review -> resolved status: open -> closed _

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-10-14 Thread Tim Peters
Tim Peters added the comment: > I'm often amazed it works at all, let alone perfectly. ;-P Indeed! Every time I take a break from gc and come back, I burn another hour wondering why it doesn't recycle _everything_ ;-) > But what happens if the GC doesn't see that W

[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

2019-10-14 Thread Tim Peters
Tim Peters added the comment: > While Neil & I haven't thought of ways that can go wrong now > beyond that a "surprise finalizer" may get run any number of > times ... Speaking of which, I no longer believe that's true. Thanks to the usual layers of baffli

[issue38490] statistics: add covariance and Pearson's correlation

2019-10-17 Thread Tim Peters
Tim Peters added the comment: I'm in favor of adding all of this (covariance, coefficient, linear regression). It's still at the level of elementary statistics, and even taught in watered down "business statistics" classes. It's about the minimum that can be do

[issue38590] argparse unexpected behavior with argument group inside mutually exclusive group

2019-10-25 Thread Tim Sanders
New submission from Tim Sanders : argparse allows adding argument_groups inside of mutually_exclusive_groups, but the behavior is unintuitive and a bit buggy. Demo: import argparse parser = argparse.ArgumentParser() single_group = parser.add_argument_group(title='single_

[issue38626] small change at bisect_left function for easy understanding

2019-10-28 Thread Tim Peters
Tim Peters added the comment: So as far as possible, CPython only uses __lt__ ("<") element comparisons for its order-sensitive algorithms. This is documented for list.sort(), but the bisect and heapq modules strive to do the same. The point is to minimize the number of compa

[issue43420] Optimize rational arithmetics

2021-03-12 Thread Tim Peters
Tim Peters added the comment: Terry, we could do that, but the opposition here isn't strong, and is pretty baffling anyway ;-) : the suggested changes are utterly ordinary for implementations of rationals, require very little code, are not delicate, and are actually straightforward t

[issue43420] Optimize rational arithmetics

2021-03-21 Thread Tim Peters
Tim Peters added the comment: New changeset 690aca781152a498f5117682524d2cd9aa4d7657 by Sergey B Kirpichev in branch 'master': bpo-43420: Simple optimizations for Fraction's arithmetics (GH-24779) https://github.com/python/cpython/commit/690aca781152a498f51176825

[issue43420] Optimize rational arithmetics

2021-03-21 Thread Tim Peters
Tim Peters added the comment: Thanks, all! This has been merged now. If someone wants to continue pursuing things left hanging, I'd suggest opening a different BPO report. -- resolution: -> fixed stage: patch review -> resolved status: ope

[issue43420] Optimize rational arithmetics

2021-03-21 Thread Tim Peters
Tim Peters added the comment: If experience is any guide, nothing about anything here will go smoothly ;-) For example, setting up a module global `_gcd` name for `math.gcd` is a very standard, widespread kind of micro-optimization. But - if that's thought to be valuable (who knows?

[issue43420] Optimize rational arithmetics

2021-03-22 Thread Tim Peters
Tim Peters added the comment: This report is closed. Please open a different report. We've already demonstrated that, as predicted, nothing can be said here without it being taken as invitation to open-ended discussion. So it goes, but it doesn't belong on _this_ repo

[issue43618] random.shuffle loses most of the elements

2021-03-24 Thread Tim Peters
Tim Peters added the comment: Are you sure it's "a list"? At least print out `type(questions_element)`. `random.shuffle()` doesn't contain any code _capable_ of changing a list's length. It only does indexed accessing of the list: ... for i in reversed(range(1,

[issue43676] Doctest ELLIPSIS explanation hard to follow when they're missing

2021-03-30 Thread Tim Hatch
New submission from Tim Hatch : The doctest docs try to explain directives like ELLIPSIS but those directives are absent from the rendered html. Where? Most of the code blocks in the Directives section, and https://docs.python.org/3/library/doctest.html#directives and the one introduced by

[issue43593] pymalloc is not aware of Memory Tagging Extension (MTE) and crashes

2021-03-31 Thread Tim Peters
Tim Peters added the comment: I'm skeptical ;-) If MTE is actually being used, system software assigns "random" values to 4 of the higher-order bits. When obmalloc punts to the system malloc, presumably those bits will be randomized in the addresses returned by malloc. The

[issue43684] Add combined opcodes

2021-04-02 Thread Tim Peters
Tim Peters added the comment: """ My philosophy here (which I learned from Tim Peters in the early 2000s) is that even though each individual improvement has no measurable effect on a general benchmark (as shown in the same comment), the combined effect of a number of tiny i

[issue43689] difflib: mention other "problematic" characters in documentation

2021-04-02 Thread Tim Peters
Tim Peters added the comment: Lines beginning with "?" are entirely synthetic: they were not present in either input. So that's what that part means. I'm not clear on what else could be materially clearer without greatly bloating the text. For example, >>> d

[issue43593] pymalloc is not aware of Memory Tagging Extension (MTE) and crashes

2021-04-03 Thread Tim Peters
Tim Peters added the comment: Can't really know without a system to try it on, but my best guess is that these asserts are the only thing that will fail with tagging enabled. The obvious "fix" is indeed just to skip them on a platform with tagging enabled. They're mea

[issue43593] pymalloc is not aware of Memory Tagging Extension (MTE) and crashes

2021-04-03 Thread Tim Peters
Tim Peters added the comment: BTW, your cache WIP https://github.com/python/cpython/pull/25130/files partly moves to tracking pool (instead of byte) addresses, but any such attempt faces a subtlety: it's not necessarily the case that a pool is entirely "owned" by obmalloc o

[issue43593] pymalloc is not aware of Memory Tagging Extension (MTE) and crashes

2021-04-04 Thread Tim Peters
Tim Peters added the comment: I think it's time to change what address_in_range() tries to answer. It currently gives a precise answer to "is this byte address in a region obmalloc owns?". But that's stronger than what it needs to do its job: the real question is &quo

[issue43689] difflib: mention other "problematic" characters in documentation

2021-04-05 Thread Tim Peters
Tim Peters added the comment: Terry, your suggested replacement statement looks like an improvement to me. Perhaps the longer explanation could be placed in a footnote. Note that I'm old ;-) I grew up on plain old ASCII, decades & decades ago, and tabs are in fact the only "ch

[issue43475] Worst-case behaviour of hash collision with float NaN

2021-04-10 Thread Tim Peters
Tim Peters added the comment: I agree hashing a NaN acting like the generic object hash (return rotated address) is a fine workaround, although I'm not convinced it addresses a real-world problem ;-) But why not? It might. But that's for CPython. I'm loathe to guarantee anyt

[issue43927] Remove IOError references from the tutorial

2021-04-23 Thread Tim Huegerich
New submission from Tim Huegerich : Although IOError has been merged into OSError since version 3.3, Section 8.5 of the Tutorial still uses it in examples. The Python 9.4 version of the tutorial features an example raising an IOError, which is then output as OSError, raising potential

[issue43955] Test Failures on Windows 10

2021-04-27 Thread Tim Peters
Tim Peters added the comment: I expect parallelism is a red herring: early in the test output attached to this report: 0:00:04 Run tests sequentially and there's no other evidence in the output that multiple tests are running simultaneously. Also on Win10, the 4 failing tests here

[issue43955] Test Failures on Windows 10

2021-04-27 Thread Tim Peters
Tim Peters added the comment: Shreyan Avigyan: > And the "(Pdb) continue (...) actually is manually entered by me. Victor Stinner: Do you mean that you modified the Python source code? Me: Doubt it. For me, with more words: the "(Pdb) " prompt appears all by itself, by m

[issue37387] test_compileall fails randomly on Windows when tests are run in parallel

2021-04-29 Thread Tim Peters
Tim Peters added the comment: @Sheyvan, whether it's possible to delete (rename, etc) an open file is a property not of Python, but of the operating system. Windows doesn't allow it; Linux (for example) does. It's generally considered to be "a bug" in CPython

[issue37387] test_compileall fails randomly on Windows when tests are run in parallel

2021-04-29 Thread Tim Peters
Tim Peters added the comment: A "good" solution would be one that runs the test in such a way that it doesn't fail only on Windows ;-) There are presumably many ways that could be accomplished, including ugly ones. For example, if test_compileall is in the collection of tests

[issue37387] test_compileall fails randomly on Windows when tests are run in parallel

2021-04-30 Thread Tim Peters
Tim Peters added the comment: Yes, test_compileall can still fail for this reason on Windows. From a run just now with -j0 (same as -j10 on this box, which has 8 logical cores: a -j value <= 0 is treated the same as "2 + number of logical cores"): """ Comp

[issue44034] Incorrect type casting of float into int

2021-05-04 Thread Tim Peters
Tim Peters added the comment: Please study the docs first: https://docs.python.org/3/tutorial/floatingpoint.html That will give you the background to understand why `int()` has nothing to do with this. >>> 1. 2.0 That is, `int()` was passed 2.0 to begin with, be

[issue44054] 2**53+1 != float(2**53+1)

2021-05-06 Thread Tim Peters
Tim Peters added the comment: [Stefan] > I found it surprising that a comparison uses a different > method of conversion than the (obvious) user-side > conversion, with a different outcome. This seems to be > implementation details leaking into the user side. It's "spir

<    1   2   3   4   5   6   7   8   9   10   >