Dennis Sweeney added the comment:
This is essentially the same issue, but with sorted():
https://bugs.python.org/issue36095
The trouble is that the implementation of min() is roughly equivalent to:
iterable = iter(iterable)
current_min = next(iterable)
for x in iterable:
if x
Dennis Sweeney added the comment:
implantation --> implementation
--
___
Python tracker
<https://bugs.python.org/issue44370>
___
___
Python-bugs-list mai
Dennis Sweeney added the comment:
This issue is probably a duplicate of https://bugs.python.org/issue42575 .
In almost all use cases, a linked list can be replaced by a collections.deque,
which already uses a double linked list of blocks internally. Is there
something you need a linked list
Change by Dennis Sweeney :
--
keywords: +patch
pull_requests: +25282
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/26697
___
Python tracker
<https://bugs.python.org/issu
Dennis Sweeney added the comment:
Here are some benchmarks:
PS C:\Users\sween\Source\Repos\cpython2\cpython> .\python.bat -m pyperf
compare_to .\main.json .\PR-26697.json
Running Release|x64 interpreter...
1: Mean +- std dev: [main] 117 us +- 4 us -> [PR-26697] 122 us +- 3 us: 1.04x
Dennis Sweeney added the comment:
This is the intended behavior. Use s.removeprefix() and s.removesuffix()
instead.
--
nosy: +Dennis Sweeney
___
Python tracker
<https://bugs.python.org/issue44
Dennis Sweeney added the comment:
I'm +-0 on this. I would write something like this instead:
assert whatever.startswith(prefix)
result = whatever.removeprefix(prefix)
Note that if this were to change, the corresponding methods would also have to
change on bytes, bytearray
Dennis Sweeney added the comment:
For what it's worth, using collections.OrderedDict gives constant-time behavior
you're looking for.
--
nosy: +Dennis Sweeney
___
Python tracker
<https://bugs.python.o
Dennis Sweeney added the comment:
> Can https://bugs.python.org/issue32623 be a fix (or mitigation) of this issue?
If such a change is implemented and dictionaries shrink when their fill falls
below 1/8, the behavior of `while d: del d[next(iter(d))]` will remain
quadradic: there will
Dennis Sweeney added the comment:
Alternate idea: the dict could shrink, if required, on the iter() call,
whenever a keys/values/items iterator is initialized.
--
___
Python tracker
<https://bugs.python.org/issue44
Dennis Sweeney added the comment:
OrderedDict already uses a linked list alongside a dictionary and meets all of
your timing expectations, but has a higher memory usage, as linked lists
generally do.
Since so many Python objects use dictionaries under the hood, it would probably
not be
Change by Dennis Sweeney :
--
pull_requests: +25639
pull_request: https://github.com/python/cpython/pull/27091
___
Python tracker
<https://bugs.python.org/issue41
Dennis Sweeney added the comment:
In "Fast String Searching" (1991), A. Hume and D. Sunday emphasize that most of
the runtime of string-search algorithms occurs in a code path that skips over
immediately-disqualified alignments. As such, that paper recommends extracting
a hot
Dennis Sweeney added the comment:
The one twist is that if type(b) is a strict subtype of type(a), then "a < b"
first calls type(b).__gt__(b, a), then falls back to type(a).__lt__(a, b).
Example:
>>> class Int(int):
... def __gt__(self, other):
.
Dennis Sweeney added the comment:
This code...
match my_maybe:
case Maybe.empty:
print('FIRST CASE')
case _:
print('DEFAULT CASE')
... is roughly equivalent to this code:
if my_maybe == Maybe.empty:
print(
Dennis Sweeney added the comment:
>From https://www.python.org/dev/peps/pep-0635/#value-patterns :
"""We therefore only adopted the rule that any dotted name (i.e., attribute
access) is to be interpreted as a value pattern, for example HttpStatus.OK
above. This preclu
Dennis Sweeney added the comment:
I don't know what behavior you were expecting, but *args means "the rest of the
positional arguments", not "all of the positional arguments."
See
https://docs.python.org/3/tutorial/controlflow.html?highlight=variadic
Dennis Sweeney added the comment:
> While attempting to run an application
How are you starting this application? It looks like you're using Python 3.9
standard library files (like _collections_abc.py in the traceback you posted),
but is it possible that you're accidentally run
Dennis Sweeney added the comment:
If I understand correctly, this shows the behavior you're objecting to:
>>> class A:
... def __getitem__(self, key):
... print(f"{key = }")
... return "apple"
...
...
>>> '{0[1]}
Change by Dennis Sweeney :
--
title: String formatting -> Can't subscript objects with the string "1" using
str.format()
___
Python tracker
<https://bugs.
Change by Dennis Sweeney :
--
keywords: +patch
nosy: +Dennis Sweeney
nosy_count: 1.0 -> 2.0
pull_requests: +25825
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27281
___
Python tracker
<https://bugs.p
Dennis Sweeney added the comment:
I opened a PR. It looks like frozenset.__hash__ changed in GH-5194 and GH-5235,
but Set._hash wasn't updated accordingly.
--
___
Python tracker
<https://bugs.python.org/is
Dennis Sweeney added the comment:
### Simplified crasher
from weakref import ref
def f():
ref(lambda: 0, [])
f()
f()
Running this in debug mode, I got a failed assertion at traceback.c,
line 746, `assert(source_line);`.
If that assertion is commented out
Dennis Sweeney added the comment:
bpo-44719 managed to make the `assert(source_line);` fail
--
nosy: +Dennis Sweeney
___
Python tracker
<https://bugs.python.org/issue43
Change by Dennis Sweeney :
--
keywords: +patch
nosy: +Dennis Sweeney
nosy_count: 1.0 -> 2.0
pull_requests: +25862
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27316
___
Python tracker
<https://bugs.p
Dennis Sweeney added the comment:
Here's a simpler reproducer:
not_an_iterator = lambda: 0
class A:
def __iter__(self):
return weakref.proxy(not_an_iterator)
a = A()
list(a)
I opened a PR.
--
title: Finding stri
Dennis Sweeney added the comment:
I think GH-27313 will fix this
--
___
Python tracker
<https://bugs.python.org/issue44719>
___
___
Python-bugs-list mailin
Dennis Sweeney added the comment:
Indeed, I got no crash on main after GH-27313.
I also got no crash on 3.10 after GH-23568. Its backport to 3.9 (GH-24501)
would have fixed this, but broke the stable ABI and was reverted. This was
related to bpo-42500.
I'm closing this "fixed&q
Dennis Sweeney added the comment:
I replicated the issue: downloading the "Windows Help File" (python396.chm)
from the release page https://www.python.org/downloads/release/python-396/ ,
opening it, and entering a search term (e.g., "tuple") into the search tab
resulted
Change by Dennis Sweeney :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Dennis Sweeney added the comment:
The [square brackets] are used to denote *optional* arguments throughout the
documentation. A tutorial page
(https://docs.python.org/3/tutorial/controlflow.html#id1) has this to say:
list.pop([i])
Remove the item at the given position in the list
Change by Dennis Sweeney :
--
keywords: +patch
pull_requests: +25931
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27398
___
Python tracker
<https://bugs.python.org/issu
Dennis Sweeney added the comment:
This is a good idea for languages where integers are bounded, but in Python,
integers can be as large as you want, so there's no reason to worry about
overflow:
>>> lo = 1 * 10**100
>>> hi = 2 * 10*
Dennis Sweeney added the comment:
Thanks for the concern, but I'll close this as "not a bug". Feel free to
re-open if you can give an example where the current code fails.
--
resolution: -> not a bug
stage: -> resolved
s
Dennis Sweeney added the comment:
Opcodes change from one version to another. You linked the Python 3.9
documentation. Python 3.9 opcodes are listed here:
https://github.com/python/cpython/blob/3.9/Lib/opcode.py (and you can browse
the branches and commit history for that file).
3.9 has
Change by Dennis Sweeney :
--
keywords: +patch
pull_requests: +25935
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27402
___
Python tracker
<https://bugs.python.org/issu
Dennis Sweeney added the comment:
GH-24334 already applied the necessary change for 3.10.
--
nosy: +iritkatriel
___
Python tracker
<https://bugs.python.org/issue42
Dennis Sweeney added the comment:
Do you have a particular use case for this? This is a backwards-incompatible
change, and the existing behavior (the only false-y float being 0.0) is very
old and well-established.
If this change was implemented, I suspect almost every use of it would
Dennis Sweeney added the comment:
Related (regarding od.popitem()): https://bugs.python.org/issue27275
--
nosy: +Dennis Sweeney
___
Python tracker
<https://bugs.python.org/issue44
Dennis Sweeney added the comment:
To be specific, is this about the fact that .arg is a member of `struct _arg`
(typedef'ed as `arg_ty`), while at the same time arg() is a macro?
as in:
https://github.com/python/cpython/blob/0f42b726c87f72d522893f927b4cb592b8875641/Parser/pegen/pegen.
Dennis Sweeney added the comment:
Indeed, this behavior is documented at
https://docs.python.org/3/library/sys.html?highlight=setrecursionlimit#sys.setrecursionlimit
: "a too-high limit can lead to a crash".
I'd recommend refactoring to use iteration rather than recursion:
Change by Dennis Sweeney :
--
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue42026>
___
___
Python-bugs-list mailing list
Unsubscrib
Dennis Sweeney added the comment:
bpo-44782 was opened about the `class LRU(OrderedDict)` in the OrderedDict
docs, and its pop() method failing.
I think Serhiy's patch here (before revert) may be a good idea (to re-apply).
I think it is reasonable to ignore user-implemented dunder me
Dennis Sweeney added the comment:
Are you still able to `import heapq` or `import sys`?
`requests` and `filetype` are not part of the Python standard library, and must
be installed separately. You can check out the tutorial here:
https://packaging.python.org/tutorials/installing-packages
Dennis Sweeney added the comment:
It was mentioned in bpo-40327 that although copy() makes the situation much
better, it doesn't solve the problem entirely, since the memory allocation of
the copy() call can release the GIL. I don't know enough to know whether it
would be worth
Dennis Sweeney added the comment:
Using _PyObject_GetMethod similarly to the way that LOAD_METHOD/CALL_METHOD
does seems like a reasonable idea to me -- do you want to make a pull request?
It would also be nice to see some microbenchmarks for the change once it's
ready.
--
Dennis Sweeney added the comment:
For what it's worth, in my benchmarks on 3.11, methodcaller was already a bit
faster than lambda:
Builtin calls
PS > .\python.bat -m pyperf timeit -s "from operator import methodcaller as mc"
-
Dennis Sweeney added the comment:
You typed `int_y = int(2.8)`, so you passed the floating point number 2.8,
which the int() function rounds down to 2.
On the other hand when y had the string value '2.8'. The int(y) call tried to
parse an integer out of the string, but failed s
Change by Dennis Sweeney :
--
resolution: -> not a bug
stage: -> resolved
status: pending -> closed
___
Python tracker
<https://bugs.python.or
Dennis Sweeney added the comment:
Perhaps it would be better to convert existing such tests to @cpython_only,
since as far as I know, id() and `is` are implementation-defined for immutable
objects.
--
nosy: +Dennis Sweeney
___
Python tracker
Dennis Sweeney added the comment:
This is not a bug, see the tutorial page here:
https://docs.python.org/3.9/tutorial/floatingpoint.html
Also, in the future, it's best to report bugs by thoroughly describing the
actual/expected behavior in text and copy/pasting code, rather than
New submission from Dennis Sweeney :
## Below are my benchmarks for this change.
from operator import itemgetter, attrgetter
from pyperf import Runner
class MyClass:
__slots__ = "a", "b"
namespace = {'itemgetter': itemgetter,
'attrgetter&
Change by Dennis Sweeney :
--
keywords: +patch
pull_requests: +26293
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27828
___
Python tracker
<https://bugs.python.org/issu
Dennis Sweeney added the comment:
Is there documentation anywhere for the semantics of am_send? I only see the
signature followed by "See PyIter_Send for details", but the doc for
PyIter_Send doesn't mention am_send.
In particular, it would be nice to document the relat
Dennis Sweeney added the comment:
It did get added to the correct docs:
https://docs.python.org/3.10/c-api/typeobj.html#c.PyAsyncMethods.am_send
(the 3.10 and 3.11 docs, not the 3.9 docs ;-)
But as I mentioned, I feel that there could be more details about the
semantics/contract
Dennis Sweeney added the comment:
Is it worth removing the len field as well and lazily using get_len_of_range()
as needed?
Then the hot function can look something like:
static PyObject *
rangeiter_next(rangeiterobject *r)
{
long result = r->start
if (result < r->stop) {
Dennis Sweeney added the comment:
Hi Stefan,
`from __future__ import annotations` only affects annotations -- just the
things after the colon. It makes it so that annotations are never evaluated, so
things like this work:
>>> from __future__ import annotations
>&g
Dennis Sweeney added the comment:
I benchmarked GH-27986 and GH-28176 on "for i in range(1): pass" and found
that GH-27986 was faster for this (likely most common) case of relatively small
integers.
Mean +- std dev: [main] 204 us +- 5 us -> [GH-27986] 194 us +- 4 us: 1.05x
Dennis Sweeney added the comment:
This is the expected behavior, documented here:
https://docs.python.org/3/reference/expressions.html#comparisons
That page says:
* The comparison operators are "<" | ">" | "==" | ">=" | "<="
Dennis Sweeney added the comment:
I did more benchmarks on my Windows laptop, and it seems the difference goes
away after using PGO.
The benchmarking program:
#
from pyperf import Runner
runner = Runner()
for n in [10, 100, 1000, 10_000, 100_000
Dennis Sweeney added the comment:
Can you describe your use-case more? In particular, why use
memoryview(a).tolist() instead of a.tolist()? Or some other numpy operations
like a.flat or a.view()? Or even numpy.array(memoryview(a)) to recover a numpy
array from a memoryview?
If this were
Dennis Sweeney added the comment:
How is Counter(numbers, key=abs) any better than Counter(map(abs, numbers))?
It seems to me that "apply a function to each thing" (map) and "count the
numbers of each thing" (Counter) are two orthogonal concepts, and there's no
Dennis Sweeney added the comment:
The values of a Counter are generally integers, not lists. Maybe you want:
items_by_keyfunc = defaultdict(list)
for x in all_the_items:
items_by_keyfunc[keyfunc(x)].append(x)
Then items_by_keyfunc[42] is a list of the things with key 42
Dennis Sweeney added the comment:
According to https://docs.python.org/3/library/math.html#math.log :
"""With two arguments, return the logarithm of x to the given base, calculated
as log(x)/log(base)."""
Indeed, this is consistent with that:
>&g
Dennis Sweeney added the comment:
It turns out that the current implementation is already very good, within 1ulp
in 99.85% of cases and perfect (as good as floats can get) in 65% of cases. So
my thinking would be to leave the implementation as is
Change by Dennis Sweeney :
--
nosy: +mark.dickinson, rhettinger
___
Python tracker
<https://bugs.python.org/issue45348>
___
___
Python-bugs-list mailin
Dennis Sweeney added the comment:
One standard way of preventing this is copying the dictionary whenever there's
risk of it changing out from under you, as in:
modules = sys.modules.copy()
for key, value in modules.items():
...
--
nosy: +Dennis Sw
New submission from Dennis Sweeney :
I'm having trouble setting up a rigorous benchmark (Windows doesn't want to
install greenlet for pyperformance), but just running a couple of individual
files, I got this:
Mean +- std dev: [nbody_main] 208 ms +- 2 ms -> [nbody_specialized] 18
Change by Dennis Sweeney :
--
keywords: +patch
pull_requests: +27074
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/28727
___
Python tracker
<https://bugs.python.org/issu
Change by Dennis Sweeney :
--
nosy: +Dennis Sweeney
nosy_count: 8.0 -> 9.0
pull_requests: +27076
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/28727
___
Python tracker
<https://bugs.python.org/i
Dennis Sweeney added the comment:
Hm the above was not PGO. I tried again with PGO and it is not so good:
Mean +- std dev: [nbody_main_pgo] 177 ms +- 4 ms -> [nbody_specialized_pgo] 190
ms +- 2 ms: 1.07x slower
Mean +- std dev: [pidigits_main_pgo] 208 ms +- 1 ms ->
[pidigits_specializ
Change by Dennis Sweeney :
--
resolution: -> not a bug
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Dennis Sweeney :
--
pull_requests: -27076
___
Python tracker
<https://bugs.python.org/issue41682>
___
___
Python-bugs-list mailing list
Unsubscribe:
Dennis Sweeney added the comment:
I was also unable to replicate on any of 3.7-3.11, including 3.9.6. Is it
possible that one of your Python stdlib source files was modified? Does this
still happen with a fresh install of Python?
Does your problem still happen if you run the file using a
Change by Dennis Sweeney :
--
components: +Library (Lib)
status: open -> pending
type: crash -> behavior
___
Python tracker
<https://bugs.python.org/i
Change by Dennis Sweeney :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Dennis Sweeney added the comment:
Oh yeah -- Py_EnterRecursiveCall/Py_LeaveRecursiveCall in abstract_get_bases
would be simpler. Also, the set approach also probably still c-stack overflows
on
class C:
def __getattr__(self, attr):
class A: pass
class B: pass
A
New submission from Dennis Sweeney :
I ran on WSL with PGO and got "1.00x faster":
https://gist.github.com/sweeneyde/41a76356e875e2a98d16ce5410ab41c0
My benchmarking doesn't seem particularly reliable, so someone else should
probably verify.
Great specialization stats, e
Change by Dennis Sweeney :
--
keywords: +patch
pull_requests: +27297
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/29024
___
Python tracker
<https://bugs.python.org/issu
Dennis Sweeney added the comment:
>From
>https://github.com/python/cpython/blob/main/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
Change by Dennis Sweeney :
--
pull_requests: +27319
pull_request: https://github.com/python/cpython/pull/29048
___
Python tracker
<https://bugs.python.org/issue30
Dennis Sweeney added the comment:
The PR changes behavior slightly:
def f():
class A:
def __lt__(self, other):
nonlocal x
x += 100
return True
a = A()
x = 1
print(a < x < 10)
x = 1
print(a < x and x < 10)
Dennis Sweeney added the comment:
Jacob wrote:
a[[0, *[0, 0], 0]]
which passes the *list* [0, 0, 0, 0] into __getitem__. In numpy, passing lists
into __getitem__ does things like array([1, 10, 100])[[2, 1]] --> array([100,
10]).
But I think Peter is requesting that the following w
New submission from Dennis Sweeney :
See the issue here for lots of data from before specializing:
https://github.com/faster-cpython/ideas/issues/105
See https://gist.github.com/sweeneyde/91855e50feb9992b604ddda2d4f1511e for
specialization data, pyperformance benchmarks, and microbenchmarks
Change by Dennis Sweeney :
--
keywords: +patch
pull_requests: +27484
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/29221
___
Python tracker
<https://bugs.python.org/issu
Dennis Sweeney added the comment:
Yes, I don't believe the PEP is suggesting any changes to list.__getitem__. If
you want to suggest such enhancements, I would suggest first sending a message
to the python-ideas mailing list or on discuss.pytho
Dennis Sweeney added the comment:
I was unable to replicate this. I see the correct article
"The Perils of Floating Point" at lahey.com/float.htm. Is the site still
incorrect for you, or did the Lahey site fix the issue?
--
assignee: -> docs@python
components: +Docum
Change by Dennis Sweeney :
--
pull_requests: +27505
pull_request: https://github.com/python/cpython/pull/29242
___
Python tracker
<https://bugs.python.org/issue45
Change by Dennis Sweeney :
--
pull_requests: +27522
pull_request: https://github.com/python/cpython/pull/29258
___
Python tracker
<https://bugs.python.org/issue30
Dennis Sweeney added the comment:
I think this broke some buildbots.
https://buildbot.python.org/all/#/builders/256/builds/264
https://buildbot.python.org/all/#/builders/370/builds/263
I opened a PR to temporarily decrease the recursion limit so that the C stack
doesn't overflow in
Dennis Sweeney added the comment:
Hopefully this was fixed by https://github.com/python/cpython/pull/29258
--
nosy: +Dennis Sweeney
___
Python tracker
<https://bugs.python.org/issue45
Dennis Sweeney added the comment:
It's been a couple of weeks, so I'm closing this. Feel free to re-open if you
figure out that this is a bug that you can reliably reproduce on a fresh
install of cpython.
--
resolution: -> not a bug
stage: -> resolved
status: p
Dennis Sweeney added the comment:
Hi Arthur,
I agree that the line about "name ::= othername" could be more helpful.
I think an affirmative example would be better than a warning against depending
on variable names, because the top of the page mentions that BNF is being used
an
Dennis Sweeney added the comment:
Looks like the pickletester bug hasn't happened since the fix, so I'll go ahead
and close this.
--
resolution: -> fixed
stage: -> resolved
status: open -> closed
___
Python tracker
<h
Dennis Sweeney added the comment:
Feel free to use anything I wrote in a PR and make any revisions/edits you want.
--
___
Python tracker
<https://bugs.python.org/issue45
Dennis Sweeney added the comment:
Interesting. It seems like several call sites already check the equality case:
setobject.h:
#define PyFrozenSet_Check(ob) \
(Py_IS_TYPE(ob, &PyFrozenSet_Type) || \
PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
Dennis Sweeney added the comment:
>From https://docs.python.org/3/library/functions.html#exec :
"modifications to the default locals dictionary should not be attempted. Pass
an explicit locals dictionary if you need to see effects of the code on locals
after function exec() returns.
Dennis Sweeney added the comment:
Thanks for the report, but this is the intended behavior.
>From https://docs.python.org/3/library/functions.html#round :
"""values are rounded to the closest multiple of 10 to the power minus ndigits;
if two multiples are equally close
Dennis Sweeney added the comment:
IIUC you're looking for --huntrleaks/-R, not the unrelated --findleaks/-l:
In that -m test -h menu:
-l, --findleaks deprecated alias to --fail-env-changed
-R RUNCOUNTS, --huntrleaks RUNCOUNTS
search for reference
New submission from Dennis Sweeney :
In bpo-30570, David Bolen noticed that "py -3.9 -m test test_pickle"
consistently crashes on Windows (even though other methods of running that test
do not crash, and the test succeeds when failed tests are retried).
Curiously, it seems that ad
201 - 300 of 516 matches
Mail list logo