Change by Raymond Hettinger :
--
keywords: +patch
pull_requests: +26643
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/28218
___
Python tracker
<https://bugs.python.org/issu
Change by Raymond Hettinger :
--
keywords: +patch
pull_requests: +26635
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/28210
___
Python tracker
<https://bugs.python.org/issu
Raymond Hettinger added the comment:
This adds cost to our most critical code paths. For example, type_call() will
now be slower for every single object instantiation.
--
nosy: +rhettinger
___
Python tracker
<https://bugs.python.org/issue38
Raymond Hettinger added the comment:
I would be happy with just "instance of cls". Elsewhere in the docs, that
phrasing almost always means "instance of a cls or instance of a subclass of
cls". Also, it is consistent with the meaning of isinstance(inst, cls) unless
ove
Raymond Hettinger added the comment:
The document out of date when it was removed and is now another dozen years
older. Since then no one has expresses any interest with this and other tools
have emerged to deal with code formatting.
--
resolution: -> out of date
st
Raymond Hettinger added the comment:
Perhaps these critical code sections should have been left as macros. It is
difficult to assuring system wide inlining across modules.
--
nosy: +rhettinger
___
Python tracker
<https://bugs.python.
Raymond Hettinger added the comment:
It would be nice if exception pickling was more friendly to subclasses.
Perhaps, the default should be to store and restore all state including args
and a __dict__ if any.
--
___
Python tracker
<ht
Change by Raymond Hettinger :
--
resolution: not a bug ->
status: closed -> open
___
Python tracker
<https://bugs.python.org/issue45112>
___
___
Pyth
Change by Raymond Hettinger :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Raymond Hettinger added the comment:
Pickling customized subclasses can be tricky. The essential details are here:
https://docs.python.org/3/library/pickle.html#object.__reduce__
Here's some code to get you started.
class ExcA(Exception):
def __init__(self, want):
Raymond Hettinger added the comment:
I don't agree this should be changed. The repetition helps improve
understanding because not everyone would assume that a METAVAR shown once would
automatically also apply to its long form.
Also, showing the METAVAR more than one is a norm.
Raymond Hettinger added the comment:
Note, I'm not proposing a create_function() decorator. That is just for the
proof of concept. The actual logic would go into normal function creation, the
same place that __annotations__ gets added.
Also, there may be a better place than
Change by Raymond Hettinger :
--
title: Teach help about typing.overload() -> Improve help() by making
typing.overload() information accessible at runtime
versions: +Python 3.11
___
Python tracker
<https://bugs.python.org/issu
Raymond Hettinger added the comment:
> The two @overload definitions will be overwritten by
> the non-overload one at runtime, and hence will ever
> been seen by help().
We can fix this by adding an __overloads__ attribute. The overload decorator
can accumulate the chain in an
Change by Raymond Hettinger :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Raymond Hettinger added the comment:
New changeset 91be41ad933e24bff26353a19f56447e17fb6367 by Raymond Hettinger in
branch 'main':
bpo-44571: Add itertool recipe for a variant of takewhile() (GH-28167)
https://github.com/python/cpython/commit/91be41ad933e24bff26353a19f5644
Change by Raymond Hettinger :
--
keywords: +patch
pull_requests: +26596
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/28167
___
Python tracker
<https://bugs.python.org/issu
New submission from Raymond Hettinger :
Python's help() function does not display overloaded function signatures.
For example, this code:
from typing import Union
class Smudge(str):
@overload
def __getitem__(self, index: int) -
Change by Raymond Hettinger :
--
Removed message: https://bugs.python.org/msg401022
___
Python tracker
<https://bugs.python.org/issue45093>
___
___
Python-bug
Raymond Hettinger added the comment:
-1 The dict API is too important to be burdened with a mostly useless and
rarely needed method. Besides we already have simple ways to do it, for
example:
assert list(d.items()) == list(e.items())
or:
assert OrderedDict(d) == OrderedDict(e
Raymond Hettinger added the comment:
-1 The dict API is to important to be burdened with a mostly useless and rarely
needed method. Besides we already have simple ways to do it, for example:
assert list(d.items()) == list(e.items())
or:
assert OrderedDict(d) == OrderedDict(e
Raymond Hettinger added the comment:
> I want the order of priority to fall back to the defaults,
> if no value is specified in the config file. And if an argument
> is passed via argv, then that value should take precedence
> over what is set in the config file.
from collec
Raymond Hettinger added the comment:
> then you can't show the defaults in the help message.
1) The --help option doesn't normally show defaults.
2) Why would you show defaults in help, if you're going to ignore them in favor
the values in config whenever they aren't
Raymond Hettinger added the comment:
> With a config file loaded as part of the program,
> overwrite the values loaded from the config file
> if the argument was encountered in the argument vector.
It seems to me that default values can already be used for this purpose:
from
Raymond Hettinger added the comment:
The docs need to clarify which ABCs can satisfy isinstance() based solely on
hasattr() logic and which ABCs require registration or direct subclassing.
The docs should also explain why the more complex ABCs can't reliably be
recognized based o
Raymond Hettinger added the comment:
To get a better insight into what is going on, see
https://docs.python.org/3/howto/descriptor.html#invocation-from-an-instance
The relevant text is, "So if __getattr__() exists, it is called whenever
__getattribute__() raises AttributeError (e
Change by Raymond Hettinger :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Raymond Hettinger added the comment:
New changeset 793f55bde9b0299100c12ddb0e6949c6eb4d85e5 by Raymond Hettinger in
branch 'main':
bpo-39218: Improve accuracy of variance calculation (GH-27960)
https://github.com/python/cpython/commit/793f55bde9b0299100c12ddb0e6949
Change by Raymond Hettinger :
--
nosy: +bob.ippolito
___
Python tracker
<https://bugs.python.org/issue45054>
___
___
Python-bugs-list mailing list
Unsubscribe:
Raymond Hettinger added the comment:
> So I really *do* want to see the ability of __float__
> to return a non-float eventually removed.
Note, the __str__ method on strings does not require an exact str.
class S:
def __str__(self):
return self
print(type
Change by Raymond Hettinger :
--
nosy: +davin
___
Python tracker
<https://bugs.python.org/issue45021>
___
___
Python-bugs-list mailing list
Unsubscribe:
Raymond Hettinger added the comment:
These should be left as they are because they indicate different problems and
solutions.
The Overflow errors are dependent on PY_SSIZE_T_MAX. They indicate the that
size is to big to store in a variable. Changing from a 32-bit build to a
64-bit build
Raymond Hettinger added the comment:
> what it's correcting for is an inaccurate value of "c" [...]
I'll leave the logic as-is and just add a note about what is being corrected.
> Numerically, it's probably not helpful.
To make a difference, the mean wo
Change by Raymond Hettinger :
--
keywords: +patch
pull_requests: +26406
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27960
___
Python tracker
<https://bugs.python.org/issu
Raymond Hettinger added the comment:
The rounding correction in _ss() looks mathematically incorrect to me:
∑ (xᵢ - x̅ + εᵢ)² = ∑ (xᵢ - x̅)² - (∑ εᵢ)² ÷ n
If we drop this logic (which seems completely bogus), all the tests still pass
and the code becomes cleaner:
def _ss(data, c=None
Raymond Hettinger added the comment:
Would you like to submit a PR?
--
nosy: +rhettinger
___
Python tracker
<https://bugs.python.org/issue45003>
___
___
Pytho
Raymond Hettinger added the comment:
Looking again, I think code is correct as-is (am not sure about the depth
adjustment though).
Stylistically, it is different from the other blocks w_complex_object() that
always have a "return" after setting p->error. The new code jumps to
Raymond Hettinger added the comment:
Should the error paths decref the key and return NULL as they do elsewhere in
the function?
--
status: closed -> open
___
Python tracker
<https://bugs.python.org/issu
Change by Raymond Hettinger :
--
Removed message: https://bugs.python.org/msg400243
___
Python tracker
<https://bugs.python.org/issue44986>
___
___
Python-bug
Raymond Hettinger added the comment:
I don't think anything like this should be done. Besides breaking existing
'%%' markup, it invents a new %-formatting notation.
--
nosy: +rhettinger
type: crash -> enhancement
___
Pyth
Raymond Hettinger added the comment:
Thanks for the report but this is an allowed behavior and not a bug.
Per the docs¹: If typed is set to true, function arguments of different types
will be cached separately. For example, f(3) and f(3.0) will always be treated
as distinct calls with
Change by Raymond Hettinger :
--
Removed message: https://bugs.python.org/msg400182
___
Python tracker
<https://bugs.python.org/issue37596>
___
___
Python-bug
Raymond Hettinger added the comment:
Here's pure python code for experimentation:
from marshal import dumps, loads
def marshal_set(s):
return dumps(sorted(s, key=dumps))
def unmarshal_set(m):
return frozenset(loads(m))
def test(s):
a
Raymond Hettinger added the comment:
Here's pure python code for expirmentation:
from marshal import dumps, loads
def marshal_set(s):
return dumps(sorted((dumps(value), value) for value in s))
def unmarshal_set(m):
return {value for dump, value in lo
Raymond Hettinger added the comment:
> I can clean it up and convert it to a PR if we decide
> we want to go this route.
+1 This is by far the smallest intervention that has been discussed.
--
___
Python tracker
<https://bugs.p
Change by Raymond Hettinger :
--
assignee: docs@python -> rhettinger
___
Python tracker
<https://bugs.python.org/issue4442>
___
___
Python-bugs-list mai
Change by Raymond Hettinger :
--
assignee: -> rhettinger
___
Python tracker
<https://bugs.python.org/issue44973>
___
___
Python-bugs-list mailing list
Un
Raymond Hettinger added the comment:
I retract the suggestion to deprecate __trunc__.
--
___
Python tracker
<https://bugs.python.org/issue44977>
___
___
Pytho
Raymond Hettinger added the comment:
The classmethod and staticmethod decorators have somewhat different semantics.
Accessing a classmethod with C.cm creates a bound method object which has both
__call__ and __get__. In contrast, accessing a staticmethod with C.sm returns
the underlying
Raymond Hettinger added the comment:
Possibly, we could have math.trunc() call __int__, letting us deprecate
__trunc__.
That would let users avoid gratuitous aliasing such as that in _pydecimal.py:
__trunc__ = __int__
--
___
Python tracker
Raymond Hettinger added the comment:
Afterwards, do __trunc__ and math.trunc() still need to exist?
They were mostly unused. Now they would also be unnecessary. Just having them
around would be a point of confusion.
--
nosy: +rhettinger
Change by Raymond Hettinger :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Raymond Hettinger added the comment:
New changeset 407b3e0bb028c30fbf5efcf58c70c50eaa6712b0 by Miss Islington (bot)
in branch '3.9':
bpo-44966: Fix out-of-date traceback message (GH-27867) (GH-27876)
https://github.com/python/cpython/commit/407b3e0bb028c30fbf5efcf58c70c5
Raymond Hettinger added the comment:
New changeset 15a64d89a31b7e91f0361c305b7b27d8761db93d by Raymond Hettinger in
branch 'main':
bpo-44966: Fix out-of-date traceback message (GH-27867)
https://github.com/python/cpython/commit/15a64d89a31b7e91f0361c305b7b27
Raymond Hettinger added the comment:
See commit d71ab4f73887a6e2b380ddbbfe35b600d236fd4a for bpo-40855.
--
nosy: +rhettinger
resolution: -> fixed
stage: needs patch -> resolved
status: open -> closed
___
Python tracker
<https://bug
Change by Raymond Hettinger :
--
keywords: +patch
nosy: +rhettinger
nosy_count: 2.0 -> 3.0
pull_requests: +26322
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27867
___
Python tracker
<https://bugs.p
Raymond Hettinger added the comment:
Removing the assertion and implementing Steven's idea seems like the best way
to go:
sum((y:=(x-c)) * y for x in data)
--
___
Python tracker
<https://bugs.python.org/is
Raymond Hettinger added the comment:
I concur with Terry. The suggestion is nice but it belongs outside the
standard library.
--
nosy: +rhettinger
resolution: -> rejected
stage: -> resolved
status: open -> closed
___
Python tracke
Change by Raymond Hettinger :
--
keywords: +patch
nosy: +rhettinger
nosy_count: 8.0 -> 9.0
pull_requests: +26321
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/27866
___
Python tracker
Raymond Hettinger added the comment:
No one has shown any interest in this in a long time. Marking is as closed
for now.
This issue can be reopened if there is an interest and a reasonable use case
that can't be reasonably handled with sorted, min, or max.
--
resol
Raymond Hettinger added the comment:
[Steven]
> Thoughts?
1) Document that results are undefined if a NaN is present in the data.
2) Add function to strip NaNs from the data:
def remove_nans(iterable):
"Remove float('NaN') and other objects not e
Change by Raymond Hettinger :
--
resolution: -> duplicate
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Raymond Hettinger added the comment:
This has come up several times in the past and never moved forward. Part of
the reason is that the mapping API doesn't translate cleanly to bidirectional
lookups and it leaves users trapped if two keys every end up needing to be
mapped to the same
Raymond Hettinger added the comment:
Generally, construction time is faster if the arguments are positional only.
Also, this isn't a method that people typically call directly — it is only
quasi-public because the layout of the codestring is implementation dependent
and changes ever
Raymond Hettinger added the comment:
To my ears, the sentence reads nicely. I vote for leaving it as is.
--
nosy: +rhettinger
___
Python tracker
<https://bugs.python.org/issue41
Raymond Hettinger added the comment:
> `types.MappingProxyType` is documented as
> 'Read-only proxy of a mapping'. But if used with a
> `collections.defaultdict` mapping, it can modify
> the underlying mapping.
Technically, the underlying mapping is modifying it
Change by Raymond Hettinger :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10, Python 3.9
___
Python tracker
<https://bugs.python.or
Raymond Hettinger added the comment:
New changeset 66dd1a0e645f26b074547dccc92448169cb32410 by Miss Islington (bot)
in branch '3.10':
bpo-44605: Teach @total_ordering() to work with metaclasses (GH-27633)
(GH-27640)
https://github.com/python/cpyt
Raymond Hettinger added the comment:
New changeset fde84170d06f74afd6f95d5b18cf3f733018191a by Miss Islington (bot)
in branch '3.9':
bpo-44605: Teach @total_ordering() to work with metaclasses (GH-27633)
(GH-27641)
https://github.com/python/cpyt
Raymond Hettinger added the comment:
New changeset 1f7d64608b5c7f4c3d96b01b33e18ebf9dec8490 by Raymond Hettinger in
branch 'main':
bpo-44605: Teach @total_ordering() to work with metaclasses (GH-27633)
https://github.com/python/cpython/commit/1f7d64608b5c7f4c3d96b01b33e18e
Change by Raymond Hettinger :
--
nosy: +larry
___
Python tracker
<https://bugs.python.org/issue44831>
___
___
Python-bugs-list mailing list
Unsubscribe:
Raymond Hettinger added the comment:
The cause of the problem is inconsistent rounding modes:
end = datetime.datetime.now() # always rounds down
start = datetime.datetime.fromtimestamp(start, None) # sometimes rounds_up
>From the C code in Modu
Change by Raymond Hettinger :
--
keywords: +patch
pull_requests: +26127
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/27633
___
Python tracker
<https://bugs.python.org/issu
Raymond Hettinger added the comment:
> If the preference is to not support this use-case ,,,
I don't really have a preference. Was just letting you know the pros and cons.
I'll put together a PR with the "type(self).__lt__(self, other)"
substitutions. Let me know
Raymond Hettinger added the comment:
[Glyph]
> why not decide on implementation at decoration time?
We could do that and not incur performance issues. However, it would expand
the API and double the size of the code.
We've had no other reports about this issue since total_orderi
Raymond Hettinger added the comment:
If some examples are added, the should note which operating system is being
used.
--
___
Python tracker
<https://bugs.python.org/issue41
Raymond Hettinger added the comment:
Concrete examples for os.path are problematic because typical inputs and
outputs vary across difference file systems. The point of os.path is to hide
these differences.
--
nosy: +rhettinger
___
Python tracker
Raymond Hettinger added the comment:
Do you all have preference for 1) expanding the range of use cases to cover
metaclasses but incurring a performance hit for common cases, or 2) leaving it
as-is and documenting that it doesn't work for metacl
Raymond Hettinger added the comment:
[Serhiy]
> In particularly it allows to modify __dict__ of builtin types.
This doesn't look like something that would happen accidentally. We've never
had any bug reports about this occurring in the wild.
[GvR]
> Maybe we should n
Change by Raymond Hettinger :
--
keywords: +patch
pull_requests: +26104
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27609
___
Python tracker
<https://bugs.python.org/issu
Raymond Hettinger added the comment:
Here's the latest effort:
---
def __get__(self, instance, owner=None):
if instance is None:
return self
if self.attrname is None:
raise Type
Raymond Hettinger added the comment:
ISTM this was mostly a net win. We get compactness and sharing most of the
time, and lose sharing only in cases like this where different instances of the
same class happen to have different attributes. Personally, I would not have
expected sharing to
Raymond Hettinger added the comment:
New changeset c50a672eebb16cf778d9a3b22b72d506c3f54ced by Miss Islington (bot)
in branch '3.9':
bpo-44782: Improve OrderedDict recipe for LRU cache variants (GH-27536)
(GH-27567)
https://github.com/python/cpyt
Change by Raymond Hettinger :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Raymond Hettinger added the comment:
New changeset 54f185b6d321a6354aef2b2886c766677f487ecb by Raymond Hettinger in
branch 'main':
bpo-44782: Improve OrderedDict recipe for LRU cache variants (GH-27536)
https://github.com/python/cpython/commit/54f185b6d321a6354aef2b2886c766
Raymond Hettinger added the comment:
> But if you need lru_cache() why not use lru_cache()
> from the stdlib?
This gives a foundation for people who want to roll their own variants of the
standard library lru_cache(). From here, people can experiment with pickle
support, dynamic re
Change by Raymond Hettinger :
--
keywords: +patch
pull_requests: +26046
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/27536
___
Python tracker
<https://bugs.python.org/issu
Raymond Hettinger added the comment:
> I am not sure how far we should backport these changes
> if backport them.
We've had no reports of the current code causing problems for any existing
applications (except the LRU recipe in the docs), so there is likely no value
in makin
Raymond Hettinger added the comment:
> It is hard to get rid of the execution lock once
> it was introduced, but I think we should do it.
It's likely some apps are relying on the locking feature.
So if we can fix it, we should do prefer that over more
disruptive changes.
Addenda
Raymond Hettinger added the comment:
Let's do the right thing and fix the pure python OrderedDict.pop() method as
well.
--
___
Python tracker
<https://bugs.python.org/is
Raymond Hettinger added the comment:
> I think Serhiy's patch here (before revert) may be a
> good idea (to re-apply).
That seems sensible to me as well. It keeps the C version in harmony with the
pure python version and it follows how regular dict's are implemented.
Raymond Hettinger added the comment:
Possible replacement recipes:
-- Implement as a class -
class LRU:
def __init__(self, func, maxsize=128):
self.func = func
self.d = OrderedDict()
def __call__(self, *args):
if args in self.d
Change by Raymond Hettinger :
--
nosy: +carljm, ncoghlan, pydanny
___
Python tracker
<https://bugs.python.org/issue43468>
___
___
Python-bugs-list mailin
Raymond Hettinger added the comment:
Antti Haapala, I agree that this situation is catastrophic and that we need
some way to avoid blocking parallel calculations of cached values for distinct
instances of the same class.
Here's an idea that might possibly work. Perhaps, hold one lock
Change by Raymond Hettinger :
--
nosy: +eric.snow
___
Python tracker
<https://bugs.python.org/issue44782>
___
___
Python-bugs-list mailing list
Unsubscribe:
Raymond Hettinger added the comment:
I'm thinking that the current LRU() recipe should be changed to lru_cache() API
using an OrderedDict internally rather than inheriting from it. The current
recipe was intended to be a sketch rather than a complete class; otherwise,
methods lik
Change by Raymond Hettinger :
--
assignee: docs@python -> rhettinger
nosy: +rhettinger
___
Python tracker
<https://bugs.python.org/issue44782>
___
___
Python-
Raymond Hettinger added the comment:
I don't think this should be done.
If case doesn't matter at all, the input can be casefolded before the
replacement:
s.casefold().replace('hippo', 'giraffe').
If it can't be casefolded in advance because t
Raymond Hettinger added the comment:
Alex, thank for noticing this, but it is not a bug.
MutableMapping is meant to describe all mapping classes including those that
don't remember insertion order.
The builtin dict() type implements MutableMapping but also adds ordering
guarantees.
Raymond Hettinger added the comment:
To add support for metaclasses, replacing 'self.__lt__(other)' with
'type(self).__lt__(self, other)' will work.
The performance degradation for the common case is about 25%:
$ py -m timeit -s 'from tmp import a, b' 'a
501 - 600 of 9609 matches
Mail list logo