[issue44244] protected members accessible in other modules

2021-05-26 Thread Dennis Sweeney
Dennis Sweeney added the comment: Being in different modules is irrelevant. Attribute names that start with double underscores and don't end with double underscores are "mangled" by the compiler to include the class name as well: >>> class MyClass: ...

[issue44223] := in comprehensions does not work

2021-05-24 Thread Dennis Sweeney
Dennis Sweeney added the comment: The parser rejects this ambiguity and requires parentheses: [ xxx for item in collection if (xxx := mutator(item)) is not None ] Example ambiguity: >>> [x for item in "abcdefabc" if x := item.upper() not in "ABC"

[issue44197] [request feature] Itertools extended combinations to limited number of repetition

2021-05-20 Thread Dennis Sweeney
Dennis Sweeney added the comment: How is proposed_function("abcd", max_repeat=3) any different from what you can currently spell as combinations("aaabbbcccddd") ? Or, more generally, def proposed_function(it, repeats) repeated = chain.from_iterable([x] * repeat for

[issue44160] speed up searching for keywords by using a dictionary

2021-05-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: Good catch -- with interning, the cutoff is more like 20-50, so it's probably not worth optimizing for. Before: 1 --> 1.67e-07 2 --> 1.77e-07 3 --> 1.90e-07 4 --> 2.05e-07 5 --> 2.14e-07 6 --> 2.35e-07 7 --> 2.51e-07 8 --> 2.

[issue44160] speed up searching for keywords by using a dictionary

2021-05-17 Thread Dennis Sweeney
Change by Dennis Sweeney : -- keywords: +patch pull_requests: +24817 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26200 ___ Python tracker <https://bugs.python.org/issu

[issue44160] speed up searching for keywords by using a dictionary

2021-05-17 Thread Dennis Sweeney
New submission from Dennis Sweeney : This patch ensures keyword-passing happens in linear time, fulfilling the 26-year-old TODO comment in ceval.c: XXX speed up searching for keywords by using a dictionary from time import perf_counter from itertools import repeat def bench(N): reps

[issue36876] [subinterpreters] Global C variables are a problem

2021-05-16 Thread Dennis Sweeney
Dennis Sweeney added the comment: I'm getting the following FutureWarning on a certain regular expression. I think it just needs "[]" to become "\[\]". 0:05:36 load avg: 0.00 [ 53/427] test_check_c_globals ...\Tools\c-analyzer\c_common\tables.py:236: FutureWarning:

[issue44144] Python window not opening

2021-05-15 Thread Dennis Sweeney
Dennis Sweeney added the comment: How are you trying to start the shell? Does "shell window" mean IDLE? What operating system are you using? What do you mean by "it glitches"? -- nosy: +Dennis Sweeney ___ Python tracker <

[issue40222] "Zero cost" exception handling

2021-05-10 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +24662 pull_request: https://github.com/python/cpython/pull/26012 ___ Python tracker <https://bugs.python.org/issue40

[issue40222] "Zero cost" exception handling

2021-05-09 Thread Dennis Sweeney
Dennis Sweeney added the comment: I tried some debugging code: diff --git a/Python/ceval.c b/Python/ceval.c index f745067069..a8668dbac2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4864,6 +4864,18 @@ get_exception_handler(PyCodeObject *code, int index) return res

[issue44080] Bias in random.choices(long_sequence)

2021-05-09 Thread Dennis Sweeney
Dennis Sweeney added the comment: Your suspicion looks correct, random() is faster: .\python.bat -m pyperf timeit -s "from random import choices" "choices(range(100), k=10_000)" Before int_choices.diff: Mean +- std dev: 1.49 ms +- 0.09 ms After int_choices.diff: Mean

[issue44080] Bias in random.choices(long_sequence)

2021-05-08 Thread Dennis Sweeney
New submission from Dennis Sweeney : Problem: Random.choices() never returns sequence entries at large odd indices. For example: >>> import random >>> [x % 2 for x in random.choices(range(2**53), k=20)] [0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1

[issue44071] Syntax error in Python3 documentation

2021-05-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: I think the docs are correct. For example: >>> import subprocess >>> subprocess.run("ls", check=True, stdout=subprocess.PIPE).stdout >>> subprocess.check_output("ls") -- nosy: +Dennis Sweeney ___

[issue44026] IDLE: print "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: I unfortunately don't have the time/internet access this week to do a PR. -- ___ Python tracker <https://bugs.python.org/issue44

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: Another idea: do what test_exceptions() does: try: f() except NameError as exc: with support.captured_stderr() as err: sys.__excepthook__(*sys.exc_info()) self.assertNotIn("a1", er

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: Indeed, this change enables the feature for IDLE, though I'm not sure what it breaks. diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 07e9a2bf9c..319b16f311 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -569,7 +569,7 @@ def runcode

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: It looks like Lib/idlelib/run.py : print_exception() re-implements the traceback, rather than relying on sys.excepthook -- ___ Python tracker <https://bugs.python.org/issue44

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: PyErr_Display() grabs the current sys.stderr and writes to that, but it looks like IDLE never gets to call PyErr_Display(). -- ___ Python tracker <https://bugs.python.org/issue44

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: I'm not sure if this helps, but this is the relevant tree of callers: suggestions.c: _Py_Offer_Suggestions() (the expected behavior) is only referenced by pythonrun.c: print_exception(), which is only referenced by pythonrun.c: print_exception_recursive

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-03 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +pablogsal ___ Python tracker <https://bugs.python.org/issue44026> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-03 Thread Dennis Sweeney
New submission from Dennis Sweeney : After bpo-38530, I get this in the python shell: Python 3.10.0b1 (tags/v3.10.0b1:ba42175, May 3 2021, 20:22:30) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more info

[issue38530] Offer suggestions on AttributeError and NameError

2021-05-01 Thread Dennis Sweeney
Dennis Sweeney added the comment: PR 25776 is a work in progress for what it might look like to do a few things: - Make case-swaps half the cost of any other edit - Refactor Levenshtein code to not use memory allocator, and to bail early on no match. - Add comments to Levenshtein distance

[issue38530] Offer suggestions on AttributeError and NameError

2021-05-01 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +24466 pull_request: https://github.com/python/cpython/pull/25776 ___ Python tracker <https://bugs.python.org/issue38

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-30 Thread Dennis Sweeney
Dennis Sweeney added the comment: Some research of other projects: LLVM [1][2] --- - Compute Levenshtein - Using O(n) memory rather than O(n^2) - Uses UpperBound = (len(typo) + 2) // 3 GCC [3] --- - Uses Damerau-Levenshtein distance - Counts transpositions like "

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-24 Thread Dennis Sweeney
Dennis Sweeney added the comment: I opened PR 25584 to fix this current behavior: >>> v Traceback (most recent call last): File "", line 1, in NameError: name 'v' is not defined. Did you mean: 'id'? >>> vv Traceback (most recent call last): File "&

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-24 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +Dennis Sweeney nosy_count: 8.0 -> 9.0 pull_requests: +24304 pull_request: https://github.com/python/cpython/pull/25584 ___ Python tracker <https://bugs.python.org/issu

[issue43884] Cannot cleanly kill a subprocess using high-level asyncio APIs

2021-04-19 Thread Dennis Sweeney
Dennis Sweeney added the comment: Running kill_subprocess.py on Windows 10, I get these results: Python 3.7.2 (tags/v3.7.2:9a3ffc0492) - raises NotImplementedError in base_events.py, _make_subprocess_transport Python 3.8.2 (tags/v3.8.2:7b3ab59) - Success Python 3.9.0 (tags/v3.9.0

[issue43751] await anext() returns None when default is given

2021-04-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: Okay, the PR should fix those problems now. I am still apprehensive about whether all of the corner cases are covered, so reviews are welcome, as are suggestions of more test cases. -- ___ Python tracker <ht

[issue31861] add aiter() and anext() functions

2021-04-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: A bug was reported in anext(): https://bugs.python.org/issue43751 -- nosy: +Dennis Sweeney ___ Python tracker <https://bugs.python.org/issue31

[issue43751] await anext() returns None when default is given

2021-04-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: That change fixes that bug, but I think there may be another bug involving when a custom async iterator is passed rather than an async generator. This is at the limit of my knowledge, so any guidance would be appreciated. The test I wrote in the PR

[issue43751] await anext() returns None when default is given

2021-04-06 Thread Dennis Sweeney
Change by Dennis Sweeney : -- keywords: +patch pull_requests: +23976 stage: -> patch review pull_request: https://github.com/python/cpython/pull/25238 ___ Python tracker <https://bugs.python.org/issu

[issue43751] await anext() returns None when default is given

2021-04-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: I can open a PR this evening, but I think this is close to the issue: PyIter_Next() already silences StopIteration, so checking for it afterward fails. diff --git a/Objects/iterobject.c b/Objects/iterobject.c index f0c6b79917..95f4659dc9 100644

[issue43683] Handle generator (and coroutine) state in the bytecode.

2021-04-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: Looks like we both opened PRs in the same minute. The MAGIC constant didn't get updated, but perhaps that can just be included in the Minor Corrections PR. I'd bet a CI check could be added to check that if the opcodes change then Python

[issue43683] Handle generator (and coroutine) state in the bytecode.

2021-04-06 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +Dennis Sweeney nosy_count: 1.0 -> 2.0 pull_requests: +23962 pull_request: https://github.com/python/cpython/pull/25225 ___ Python tracker <https://bugs.python.org/issu

[issue43719] Master build failure on Windows getting file system encoding

2021-04-03 Thread Dennis Sweeney
Dennis Sweeney added the comment: Correction: I opened GH-25172 -- ___ Python tracker <https://bugs.python.org/issue43719> ___ ___ Python-bugs-list mailin

[issue43719] Master build failure on Windows getting file system encoding

2021-04-03 Thread Dennis Sweeney
Dennis Sweeney added the comment: I could not successfully build even with deletion of __pycache__ in subfolders. I finally got the build to succeed after changing the magic number, so I opened GH-25069. -- ___ Python tracker <ht

[issue27129] Wordcode, part 2

2021-04-03 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +23913 pull_request: https://github.com/python/cpython/pull/25172 ___ Python tracker <https://bugs.python.org/issue27

[issue27129] Wordcode, part 2

2021-04-03 Thread Dennis Sweeney
Dennis Sweeney added the comment: I notice this in _bootstrap_external.py: the magic number did not get changed, only the comment: # Python 3.10a2 3433 (RERAISE restores f_lasti if oparg != 0) # Python 3.10a6 3434 (PEP 634: Structural Pattern Matching) # Python 3.10a7 3435 Use

[issue43719] Master build failure on Windows getting file system encoding

2021-04-03 Thread Dennis Sweeney
Dennis Sweeney added the comment: I ran into the same issue on Windows 10 and git bisected it to the same first bad commit, fcb55c0037baab6f98f91ee38ce84b6f874f034a The issue persists after rm .\Parser\__pycache__\* My .\Tools directory has no __pycache__. -- nosy: +Dennis Sweeney

[issue43686] re.match appears to hang with certain combinations of pattern and string

2021-03-31 Thread Dennis Sweeney
Dennis Sweeney added the comment: It's well-known that regular expressions can take exponential time. You can try searching this bug tracker for "re exponential". Common suggestions are to try a third-party module, or to write better regexes where possible. Note that the impo

[issue43685] __call__ not being called on metaclass

2021-03-31 Thread Dennis Sweeney
Dennis Sweeney added the comment: typing.cast doesn't actually do anything, it only exists as a hint for type-checkers. As William noted, using the 3-argument type(...) as you showed will only return a type, not a mcs. I think you may want super().__new__(mcs, name, bases, namespace

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-22 Thread Dennis Sweeney
Dennis Sweeney added the comment: > other attributes will not be copied The signature of wraps() is wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',)) Passing the updated=() will prevent the __dict__ from be

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-22 Thread Dennis Sweeney
Dennis Sweeney added the comment: Did you try adding updated=()? @functools.wraps(_internal_main_operation, updated=()) def external_main_operation(self, *args, **kwargs): -- ___ Python tracker <https://bugs.python.org/issue43

[issue43585] perf_counter() returns computers uptime

2021-03-21 Thread Dennis Sweeney
Dennis Sweeney added the comment: Can you explain why you think this is the wrong behavior, and what operating system and version of Python you're using? from https://docs.python.org/3/library/time.html#time.perf_counter Return the value (in fractional seconds) of a performance counter

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-13 Thread Dennis Sweeney
Dennis Sweeney added the comment: > the ABC wouldn't have any abstract methods, I was wrong about this since the @abstractmethod decorator adds 'f' to the __abstractmethods__ set of the ABC, but the rest of my comment stands. -- ___ Pyt

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-13 Thread Dennis Sweeney
Dennis Sweeney added the comment: I don't think changing @wraps is what you want. Even if you manually set `wrapper.__isabstractmethod__ = False`, you won't reach `print('f is called!')`, since f() is overridden by the child. And if you do that, the ABC wouldn't have any abstract methods

[issue41361] Converting collections.deque methods to Argument Clinic

2021-03-08 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +23564 pull_request: https://github.com/python/cpython/pull/24796 ___ Python tracker <https://bugs.python.org/issue41

[issue41361] Converting collections.deque methods to Argument Clinic

2021-03-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: If the argument clinic is too disruptive, would it be okay to inline the equivalent code like this? diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 90bafb0ea8..d75388abc8 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules

[issue41972] bytes.find consistently hangs in a particular scenario

2021-02-28 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +23457 pull_request: https://github.com/python/cpython/pull/24672 ___ Python tracker <https://bugs.python.org/issue41

[issue41972] bytes.find consistently hangs in a particular scenario

2021-02-27 Thread Dennis Sweeney
Dennis Sweeney added the comment: Any chance PR 22904 can make it into 3.10 before the May 03 feature freeze? The text document in that PR has some notes on how the algorithm works, so that may be a good place to start reviewing if anyone is interested

[issue43289] step bug in turtle's for loop

2021-02-21 Thread Dennis Sweeney
Dennis Sweeney added the comment: If I understand correctly, changing the -1 to a -2 does not actually make the program "crash" -- you just only see one black circle. The reason is that range(40, 0, -2) produces 40, 38, 36, etc., all of which are even numbers, so rad % 2 is always

[issue43280] additional argument for str.join()

2021-02-20 Thread Dennis Sweeney
Dennis Sweeney added the comment: This seems like a very specific use case. Too specific IMO for a method on all string objects for anyone using Python anywhere in the world. Why not just write a function like this? def my_join(strings, sep=", ", last_sep=", and &quo

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-10 Thread Dennis Sweeney
Dennis Sweeney added the comment: I bisected the change to here: https://github.com/python/cpython/pull/19881 commit 3dd2157febae5087cad24f69b6de9cbd13cd Author: Raymond Hettinger Date: Sun May 3 04:51:05 2020 -0700 Simplify set entry insertion logic. (GH-19881) ""&qu

[issue43151] is with literals in 3.8 release

2021-02-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: I think the strangeness is happening because sometimes, the warning is printed to stderr, while other times, IDLE's parser notices the "is " anti-pattern and raises a SyntaxError. See the attached screenshot for the IDLE output versus the cons

[issue43151] is with literals in 3.8 release

2021-02-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: There may be reason to re-open this. With Python 3.9.0, I see the inconsistent behavior that Gary describes only when using IDLE. So this is likely an IDLE issue. I attached a screenshot of the difference. -- Added file: https://bugs.python.org

[issue43151] is with literals in 3.8 release

2021-02-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: This was a very intentional change from the commit 3bcbedc9f1471d957a30a90f9d1251516b422416 It's not safe to check `x is y` when x and y are strings. You should always use `x == y` for strings instead. In CPython, if the names x and y both refer to the same

[issue43134] (list have item) instate (item in list)

2021-02-05 Thread Dennis Sweeney
Dennis Sweeney added the comment: You could express this as: a = [input() for i in range(10)] x = input() print(x in a) This is more clear IMO, because if you want to have something happen before something else, it's clearest to put them on separate lines, one after the other. I also

[issue43130] Should this construct throw an exception?

2021-02-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is the expected behavior. >From >https://docs.python.org/3/tutorial/introduction.html#first-steps-towards-programming """ In Python, like in C, any non-zero integer value is true; zero is false. The condition may also be a

[issue43078] Equality Errors when Unpickling and Pickling a Dictionary with a nan

2021-01-30 Thread Dennis Sweeney
Dennis Sweeney added the comment: I think this is the expected behavior. It is expected by IEEE 754 that nan != nan, so that behavior exists: >>> nan = float('nan') >>> nan2 = float('nan') >>> assert nan != nan2 >>> assert nan != nan However, for "p

[issue43057] Timezone 'Etc/GMT-5' functions as Timezone 'Etc/GMT+5'

2021-01-28 Thread Dennis Sweeney
Dennis Sweeney added the comment: I reproduced something similar in 3.9 with standard library modules: >>> from datetime import datetime >>> from zoneinfo import ZoneInfo >>> zone = ZoneInfo(key='Etc/GMT-3') >>> zone.tzname(datetime(2021, 1, 28)) '+0

[issue31356] Add context manager to temporarily disable GC

2021-01-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: https://bugs.python.org/issue41545 is a duplicate of this. In that report, there's an example of something that can go wrong with the save-a-boolean-per-context-manager approach even when threads are not used, but when concurrent generators are used, like

[issue41545] gc API requiring matching number of gc.disable - gc.enable calls

2021-01-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: It looks like this was a duplicate of https://bugs.python.org/issue31356 -- ___ Python tracker <https://bugs.python.org/issue41

[issue41972] bytes.find consistently hangs in a particular scenario

2021-01-17 Thread Dennis Sweeney
Dennis Sweeney added the comment: PR 22904 now adds a text document explaining how the Two-Way algorithm works in much more detail. I was looking at more benchmarking results, and I came to a couple of conclusions about cutoffs. There's a consistent benefit to using the two-way algorithm

[issue42808] Add PyType_Type.tp_vectorcall for type(obj) performance

2021-01-02 Thread Dennis Sweeney
Change by Dennis Sweeney : -- keywords: +patch pull_requests: +22892 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24058 ___ Python tracker <https://bugs.python.org/issu

[issue42808] Add PyType_Type.tp_vectorcall for type(obj) performance

2021-01-02 Thread Dennis Sweeney
New submission from Dennis Sweeney : # common case .\python.bat -m pyperf timeit "type(17)" Master: 49.9 ns +- 1.8 ns ---> PR: 33.3 ns +- 1.4 ns # uncommon case .\python.bat -m pyperf timeit "type('A', (object, ), {})" Master: 5.14 us +- 0.04 us ---&

[issue42804] Unable to compile the cpython code x86 windows

2021-01-01 Thread Dennis Sweeney
Dennis Sweeney added the comment: Were you able to run PCbuild\get_externals.bat ? -- ___ Python tracker <https://bugs.python.org/issue42804> ___ ___ Python-bug

[issue42804] Unable to compile the cpython code x86 windows

2021-01-01 Thread Dennis Sweeney
Dennis Sweeney added the comment: What commands did you enter? Are you following the instructions at https://devguide.python.org/setup/ ? -- nosy: +Dennis Sweeney ___ Python tracker <https://bugs.python.org/issue42

[issue42793] Bug of round function

2020-12-31 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is not a bug. See https://stackoverflow.com/a/10825998/11461120 -- nosy: +Dennis Sweeney ___ Python tracker <https://bugs.python.org/issue42

[issue42734] Outdated CodeType call in "bogus_code_obj.py"

2020-12-25 Thread Dennis Sweeney
Dennis Sweeney added the comment: To make it slightly more readable and future-proof so such things don't become outdated again in the future, you could use the CodeType.replace() method. See also https://bugs.python.org/issue42422 -- nosy: +Dennis Sweeney

[issue42632] Reassgining ZeroDivisionError will lead to bug in Except clause

2020-12-14 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is just how local/nonlocal/global/builtin variables work in Python. When you assign to a name anywhere inside of a function, all occurrences of that name refer by default to a local variable. So the line "ZeroDivisionError = 1" tells the foo(

[issue41972] bytes.find consistently hangs in a particular scenario

2020-12-12 Thread Dennis Sweeney
Change by Dennis Sweeney : Added file: https://bugs.python.org/file49674/twoway_demo.py ___ Python tracker <https://bugs.python.org/issue41972> ___ ___ Python-bugs-list m

[issue41972] bytes.find consistently hangs in a particular scenario

2020-12-12 Thread Dennis Sweeney
Change by Dennis Sweeney : Removed file: https://bugs.python.org/file49672/twoway_demo.py ___ Python tracker <https://bugs.python.org/issue41972> ___ ___ Python-bug

[issue41972] bytes.find consistently hangs in a particular scenario

2020-12-12 Thread Dennis Sweeney
Dennis Sweeney added the comment: For convenience, attached is a quick and dirty Tkinter GUI that lets you step through the Crochemore/Perrin Algorithm on your choice of inputs, just for play/discovery. A good illustration of the memory for periodic needles can be found by testing

[issue42422] Py_Decref on value crash the interpreter in Python/ceval.c:1104

2020-12-07 Thread Dennis Sweeney
Dennis Sweeney added the comment: Why not just fix bogus_code_obj.py? Something like this (using the replace method) would make it more future-proof to similar changes in the code object constructor signature (and be more readable!): import dis POP_TOP = dis.opmap['POP_TOP'] wordcode

[issue42575] Suggest to add an LinkedList data structure to python

2020-12-05 Thread Dennis Sweeney
Dennis Sweeney added the comment: I'll add that for 98% of the use cases of a linked list (where you just want fast access at the ends), you can use a `collections.deque` instead, and it will be faster (fewer dereferences) and more memory-efficient (fewer pointers to store

[issue42550] re库匹配问题

2020-12-02 Thread Dennis Sweeney
Dennis Sweeney added the comment: Maybe you're looking for re.fullmatch: https://docs.python.org/3/library/re.html#re.fullmatch -- nosy: +Dennis Sweeney ___ Python tracker <https://bugs.python.org/issue42

[issue42509] Recursive calls crash interpreter when checking exceptions

2020-11-30 Thread Dennis Sweeney
Dennis Sweeney added the comment: sys.getrecursionlimit() returns whatever was passed to the most recent call of sys.setrecursionlimit(...), with some system default (here 1000). Catching a RecursionError might be fine sometimes, but the issue is that Program 1 catches a RecursionError

[issue42509] Recursive calls crash interpreter when checking exceptions

2020-11-29 Thread Dennis Sweeney
Dennis Sweeney added the comment: This might be the expected behavior. See https://bugs.python.org/issue25222 If you already caught a RecursionError and you keep recursing anyway, once you go 50 levels beyond sys.getrecursionlimit(), the interpreter crashes regardless of what is `except`ed

[issue42422] Py_Decref on value crash the interpreter in Python/ceval.c:1104

2020-11-21 Thread Dennis Sweeney
Dennis Sweeney added the comment: >From >https://github.com/python/cpython/blob/master/Lib/test/crashers/bogus_code_obj.py > : """ Broken bytecode objects can easily crash the interpreter. This is not going to be fixed. It is generally agreed that there is no poi

[issue42358] Python 3.9.0 unable to detect ax_cv_c_float_words_bigendian value on nigendan system

2020-11-15 Thread Dennis Clarke
Dennis Clarke added the comment: I see : https://github.com/python/cpython/blob/master/Objects/exceptions.c#L2316 the void return has been fixed and really I should not be looked anywhere else other than the master sources on some oddball platform. I will start over

[issue42358] Python 3.9.0 unable to detect ax_cv_c_float_words_bigendian value on nigendan system

2020-11-14 Thread Dennis Clarke
Dennis Clarke added the comment: I gave up on trying to compile this code with C99. Trying C11 and hope that blows up in different places. -- ___ Python tracker <https://bugs.python.org/issue42

[issue42358] Python 3.9.0 unable to detect ax_cv_c_float_words_bigendian value on nigendan system

2020-11-14 Thread Dennis Clarke
New submission from Dennis Clarke : Seems related to issue42173 where the idea on the table was, simply to drop Solaris support and to quote Mr Stinner to "let the code slowly die". Regardless of this sort of neglect there are people who do try to use Python on big endian ri

[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread Dennis Sweeney
Dennis Sweeney added the comment: Here's an example: class A(complex): def __init__(self, *args, test): self.test = test def __new__(cls, *args, test): return super().__new__(cls, *args) >>> a = A(1, test="TEST") >>> a (1+0j) >>>

[issue42334] Subclassing int and complex with keyword arguments weird

2020-11-12 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is because int, str, and complex are immutable. If I have class MyInt(int): def __init__(self, stuff): pass then when I call MyInt("19"), the string "19" is passed to the constructor int.__new__ b

[issue41972] bytes.find consistently hangs in a particular scenario

2020-11-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: > Toward that end it would be fine to use "very high" cutoffs, and save tuning > for later. This feels reasonable to me -- I changed the cutoff to the more cautious `if (m >= 100 && n - m >= 5000)`, where the averages are v

[issue41972] bytes.find consistently hangs in a particular scenario

2020-11-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: I used the following script, and the raw results are attached. import pyperf runner = pyperf.Runner() ms = [12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536] ns = [2000, 3000, 4000, 6000, 8000, 12000

[issue41972] bytes.find consistently hangs in a particular scenario

2020-11-06 Thread Dennis Sweeney
Dennis Sweeney added the comment: I am attempting to better understand the performance characteristics to determine where a cutoff should go. Attached is a colorful table of benchmarks of the existing algorithm to the PR with the cutoff changed to `if (1)` (always two-way) or `if (0

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-23 Thread Dennis Sweeney
Dennis Sweeney added the comment: Here are those zipf-distributed benchmarks for PR 22904: https://pastebin.com/raw/qBaMi2dm Ignoring differences of <5%, there are 33 cases that get slower, but 477 cases that got faster. Here's a stringbench.py run for PR 22904: https://pastebin.com/

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-23 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is the approach in the PR: # JUMP_BOTH while ...: if haystack[j + cut] != needle[cut]: # Sunday skip j += table[haystack[j + len(needle)]] continue j += rest_of_the_two_way_algorithm() If I

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-22 Thread Dennis Sweeney
Dennis Sweeney added the comment: I attached a new PR, with a lot of the same ideas. The major differences between this and the last PR: * The first character to be checked at each alignment is the first character of the right half, rather than the last. * If that first character does

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-22 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +21836 pull_request: https://github.com/python/cpython/pull/22904 ___ Python tracker <https://bugs.python.org/issue41

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-19 Thread Dennis Sweeney
Dennis Sweeney added the comment: Unfortunately due to licensing issues, it looks like I'll have to ditch the PR and start from scratch: it was too heavily based on the glibc implementation, which has a stricter license. It may be take a good deal of time before I have a potential

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: I posted the example thinking that having a concrete walkthrough might be good for discussion, and it looks like it was. ;-) This makes me curious how a simplified-but-not-as-simplified-as-the-status-quo Sunday algorithm would fare: using the Sunday

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: > Dennis, I think that's expected, right? Two-way on its own can exploit > nothing about individual characters - it only preprocesses the needle to > break the possibility for quadratic-time behavior due to periods in the > needle. Yes, th

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: FWIW, one of the "# Made the spaces line up" is actually a "skip ahead by the needle length". -- ___ Python tracker <https://bug

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: Below is one of the tests that got run when I happened to import something, and I thought it was a good illustration of the Boyer-Moore bad character shift table. It's worth noting in particular that the table is the dominant force for speed in some common

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-17 Thread Dennis Sweeney
Dennis Sweeney added the comment: > But there _also_ seem to be real (but much smaller) benefits > for the "search backward" cases, which I don't recall seeing > when I tried it. Do you have a guess as to why? I did change `skip = mlast - 1;` to `skip = mlast;` as you

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-17 Thread Dennis Sweeney
Dennis Sweeney added the comment: I added the cutoff for strings >= 10 characters, and I converted the PR from a draft to "Ready to Review." When running stringbench.py before and after the PR, I get these results: Summary: Unicode Before: 81.82 Bytes Before: 92.62

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-16 Thread Dennis Sweeney
Dennis Sweeney added the comment: I'm doing a couple more timing tests to try to understand exactly when the cutoff should be applied (based on some combination of needle and haystack lengths). Can the rolling hash algorithm be made to go sublinear like O(n/m)? It looked like it was pretty

[issue41972] bytes.find consistently hangs in a particular scenario

2020-10-14 Thread Dennis Sweeney
Dennis Sweeney added the comment: The most recent batch of commits added a jump table. Between master and PR 22679 now, there are 151 cases slower than master and 463 that faster than master. The slower cases are at most twice as slow, but the faster cases are often 10-20x faster. I could

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