[issue47259] Clarify SortingHOWTO regarding locale aware string sorting

2022-04-08 Thread Raymond Hettinger
Change by Raymond Hettinger : -- title: string sorting often incorrect -> Clarify SortingHOWTO regarding locale aware string sorting versions: +Python 3.10, Python 3.11 ___ Python tracker <https://bugs.python.org/issu

[issue47259] string sorting often incorrect

2022-04-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think splashing this everywhere else in the docs would be helpful. Tools like list.sort, sorted, min, max, nlargest, nsmallest use whatever sort order is provided by the underlying object whether it be a string, tuple, float, or int

[issue47259] string sorting often incorrect

2022-04-08 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue47259> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47121] math.isfinite() can raise exception when called on a number

2022-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: > isfinite() should return True for all ints, without needing > to coerce them to float Whoa there. You're venturing into changing what those math functions were all about and the core approach to how they operate. A zigzag to this new direction

[issue47234] PEP-484 "numeric tower" approach makes it hard/impossible to specify contracts in documentation

2022-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: This is a partial duplicate of an issue you already filed: https://bugs.python.org/issue47121 where math.isfinite(10**1000) raises an OverflowError even though it type checks. Here was one of the comments: """ Types relationships are usefu

[issue28540] math.degrees(sys.float_info.max) should throw an OverflowError exception

2022-04-05 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <https://bugs.python.org/issue28540> ___ ___ Python-bugs-list mailing list Un

[issue28540] math.degrees(sys.float_info.max) should throw an OverflowError exception

2022-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: One other thought. The mental model for degrees() is just a simple scaling operation. If done in pure Python, we would get *inf* rather than an OverflowError. I don't see any value in breaking with the obvious substitution: >>> sys.float

[issue28540] math.degrees(sys.float_info.max) should throw an OverflowError exception

2022-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm not interested in having this move forward. AFAICT it doesn't solve any known user problems (no one has cared about this before or since this issue was opened). It slightly slows the code. And it might break some existing code that wasn't

[issue47220] Document the optional callback parameter of weakref.WeakMethod

2022-04-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: Antoine, was the *callback* argument intended to be part of the public API? -- nosy: +pitrou, rhettinger ___ Python tracker <https://bugs.python.org/issue47

[issue47225] Issue in subtraction of float numbers

2022-04-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: See https://docs.python.org/3/tutorial/floatingpoint.html -- nosy: +rhettinger resolution: -> wont fix stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue44090] Add class binding to unbound super objects for allowing autosuper with class methods

2022-04-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: > any objections before I propose the removal of one-argument super? AFAICT there is nothing to be gained by deprecating the one argument form. Because it has been stable API for two decades, removing it is guaranteed to cause some disruption. So

[issue47083] The __complex__ method is missing from the complex, float, and int built-in types

2022-03-31 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue47178] Improve the implementations of Sequence.index and MutableSequence.extend in collections.abc

2022-03-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: Marking as closed because the changes are incorrect. See the comments in the PR. -- assignee: -> rhettinger nosy: +rhettinger resolution: -> rejected stage: -> resolved status: open -> closed __

[issue47180] Remove unnecessary registration of weakref.WeakSet as a subtype of _collections_abc.Set

2022-03-31 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue47180> ___ ___

[issue47180] Remove unnecessary registration of weakref.WeakSet as a subtype of _collections_abc.Set

2022-03-31 Thread Raymond Hettinger
Change by Raymond Hettinger : -- versions: -Python 3.10, Python 3.9 ___ Python tracker <https://bugs.python.org/issue47180> ___ ___ Python-bugs-list mailin

[issue47157] bijective invertible map

2022-03-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: This is indeed a duplicate. If needed just use one of implementations on PyPI https://pypi.org/project/bidict/ -- nosy: +rhettinger resolution: -> duplicate stage: -> resolved status: open -&g

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-03-28 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +ncoghlan ___ Python tracker <https://bugs.python.org/issue47135> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47083] The __complex__ method is missing from the complex, float, and int built-in types

2022-03-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think this may fine as-is. In general, virtiual classes only promise that an operation will work rather than promsing the presence of a particular method. An object can be Iterable without defining __iter__ because iter() can use __getitem__

[issue44090] Add class binding to unbound super objects for allowing autosuper with class methods

2022-03-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: Will leave this open for a few days to see if anyone else steps forward to make a case for or against this proposal. -- assignee: -> rhettinger versions: -Python 3.10, Python 3.9 ___ Python tracker <

[issue44090] Add class binding to unbound super objects for allowing autosuper with class methods

2022-03-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: Guido, what do you think about this proposal? Personally, I'm dubious about changing the meaning of the arguments between code paths. The callee has no way to distinguish which meaning was intended. And adding classmethod() support in super_descr_get

[issue47122] Fix the table of methods in the collections.abc documentation

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

[issue47121] math.isfinite() can raise exception when called on a number

2022-03-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: The math.isfinite() docs could be changed to something like, "coerces x to a float if possible and then returns True if x is neither an infinity nor a NaN, and False otherwise." Or there could be a general note about which functions (mo

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <https://bugs.python.org/issue47114> ___ ___ Python-bugs-list mailing list Un

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: This was an intentional decision. It is documented and tested. The rationale is that is keeps choices() internally consistent so that choices with equal weights produces the same result as if no weights are specified. For anyone who wants

[issue18241] Add unique option to heapq functions

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

[issue26019] collections.abc documentation incomplete

2022-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: This was fixed in commit 62fa613f6a6e872723505ee9d56242c31a654a9d -- nosy: +rhettinger resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker <https://bug

[issue433030] SRE: Atomic Grouping (?>...) is not supported

2022-03-18 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: effbot -> ___ Python tracker <https://bugs.python.org/issue433030> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue47023] re.sub shows key error on regex escape chars provided in repl param

2022-03-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: There seem to be a number of escaping problems in the OP's example. Is this what was intended? >>> re.sub(r"\{(\w+)\}", r"\1", "Hello! {user}") 'Hello! user' -- no

[issue47007] [doc] str docs are inconsistent with special method lookup

2022-03-13 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue47007> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46941] Bug or plug not removed (The operator "is")

2022-03-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: The code in the screenshot looks correct. >>> i = 0 >>> i is int False >>> type(i) is int True The code above does not get warning because "int" is a variable. This kind of comparison is always allowed and

[issue44863] Allow TypedDict to inherit from Generics

2022-03-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: Related issue: https://bugs.python.org/issue43923 -- nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue44

[issue46925] Document dict behavior when setting equal but not identical key

2022-03-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: The weakref docs in particular should point out the OP's example and highlight the workaround. -- ___ Python tracker <https://bugs.python.org/issue46

[issue46925] Replace key if not identical to old key in dict

2022-03-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Jelle and Methane that we can't do this without breaking code. Also if you don't care about dict order, the work around is easy. Just remove the old key: d.pop(k); d[k] = v -- nosy: +rhettinger resolution: -> rejected st

[issue46900] marshal.dumps represents the same list object differently

2022-03-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: The difference is the FLAG_REF which is set to 128 (0x80). >>> import marshal >>> var_example = [(1,2,3),(4,5,6)] >>> vm = marshal.dumps(var_example) >>> rm = marshal.dumps([(1,2,3),(4,5,6)]) >>> [v ^ r for v,

[issue12165] [doc] clarify documentation of nonlocal

2022-02-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I think this is more confusing then helpful. I concur. -- ___ Python tracker <https://bugs.python.org/issu

[issue46852] Remove float.__get_format__() and float.__set_format__()

2022-02-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: I would not miss these methods. Unless Mark says they are needed, +1 for removal. -- nosy: +mark.dickinson, rhettinger, tim.peters ___ Python tracker <https://bugs.python.org/issue46

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Andrew Svetlov] > A third-party library should either copy all these > implementation details or import a private function from stdlib OrderedDict provides just about everything needed to roll lru cache variants. It simply isn't true this ca

[issue46813] Allow developer to resize the dictionary

2022-02-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm going to close this one. Making a new and previously rejected extension to one of Python's most import APIs requires broad discussion and buy-in. If you really want to push for this, please take it to the python-ideas list. -- resolution

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-22 Thread Raymond Hettinger
Change by Raymond Hettinger : -- title: Add a async variant of lru_cache for coroutines. -> Add an async variant of lru_cache for coroutines. ___ Python tracker <https://bugs.python.org/issu

[issue46622] Add a async variant of lru_cache for coroutines.

2022-02-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: If this goes forward, my strong preference is to have a separate async_lru() function just like the referenced external project. For non-async uses, overloading the current lru_cache makes it confusing to reason about. It becomes harder to describe

[issue46828] math.prod can return integers (contradicts doc)

2022-02-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'll add a note that the output type is determined by the input type. -- assignee: docs@python -> rhettinger nosy: +rhettinger priority: normal -> low ___ Python tracker <https://bugs.python.org/i

[issue46757] dataclasses should define an empty __post_init__

2022-02-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: Note that adding an empty __post_init__ method would be a breaking change. The following prints out 'B' then 'C'. But if class A adds an empty __post_init__, then 'B' never gets printed. The arrangement relies on class A being a passthrough to class B

[issue46814] Documentation for constructing abstract base classes is misleading

2022-02-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, I’m only -0 on this. It is also perfectly reasonable to say that a class is abstract if and only if there is at least one remaining abstract method. After 15 years though, I’m inclined to say that the status quo wins

[issue46814] Documentation for constructin abstract base classes is misleading

2022-02-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: An analogy may help. Release managers must check the list of release blockers and stop if the list is non-empty. If no release blockers were ever filed, the release blockers list is empty, but it still exists and its definition hasn't changed

[issue46814] Documentation for constructin abstract base classes is misleading

2022-02-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: To me, this looks like a way too extensive edit jsut to emphasize a corner case that rarely arises in practice. It bends over backwards to force an awkward definition regarding what an ABC really is. A more minimal edit is to just note

[issue46813] Allow developer to resize the dictionary

2022-02-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: This idea surfaced once before and Guido shot it down. IIRC the rationale was the exposed implementation details, that would challenging for users to consistently set the size correctly, and that it may not make sense for other implementations

[issue46812] Thread starvation with threading.Condition

2022-02-20 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +tim.peters ___ Python tracker <https://bugs.python.org/issue46812> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46757] dataclasses should define an empty __post_init__

2022-02-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 * I concur with Eric that this is mostly not needed. Probably 99.95% of dataclass use case don't need this. When it is needed, it is trivial to implement and probably should be explicit rather that implicit. * Vedran is also correct in noting

[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Nor will it achieve world peace. Please watch the tone. It is borderline abusive and dismissive. > we can invoke the attached as best_fraction(Fraction("0.001"), > Fraction("0.0005"), Fraction("0.0015")) to get t

[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: Also note for the music example that the notion of "near enough" isn't equidistant about the "simple fraction". The sense of nearness is logarithmic and is measured in "cents" which are hundredths of an equal-tempered semito

[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

2022-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think the standard library should go down this path. Mark's disinclinations all make sense to me, but I'm also concerned that the API would be almost unusable in practical situations. Users would tend to know their input fraction

[issue45356] Calling `help` executes @classmethod @property decorated methods

2022-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: See also: https://bugs.python.org/issue46764 -- ___ Python tracker <https://bugs.python.org/issue45356> ___ ___ Python-bug

[issue46764] Wrapping a bound method with a @classmethod no longer works

2022-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: This seems like a reasonable fix. I'll wait a bit so that others can comment as well. FWIW, we looking a potentially reverting the whole line of development starting with that commit. It has caused a number of problems and no longer looks tenable

[issue46783] Add a new feature to enumerate(iterable, start=0) built-in function

2022-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thank you for the suggestion, but we will decline. We looked at this before and decided not to go down this path, preferring instead to the keep the builtin function simple and focused on its core task of enumeration. To cover the rarer cases

[issue46737] Default to the standard normal distribution

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

[issue46737] Default to the standard normal distribution

2022-02-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 08ec80113b3b7f7a9eaa3d217494536b63305181 by Zackery Spytz in branch 'main': bpo-46737: Add default arguments to random.gauss and normalvariate (GH-31360) https://github.com/python/cpython/commit/08ec80113b3b7f7a9eaa3d217494536b63305181

[issue45976] Random._randbelow() loses time by caching an attribute lookup

2022-02-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm thinking that we care more about the unhappy cases (the extreme values) than we care about a mild and implementation dependent improvement to the average case. -- resolution: later -> rejected ___ Pyt

[issue46737] Default to the standard normal distribution

2022-02-13 Thread Raymond Hettinger
New submission from Raymond Hettinger : This is really minor, but it would convenient if we provided default arguments: random.gauss(mu=0.0, sigma=1.0) random.normalvariate(mu=0.0, sigma=1.0) -- components: Library (Lib) messages: 413177 nosy: rhettinger priority: normal

[issue46700] wrong nomenclature (options vs. arguments) in argparse

2022-02-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: Éric is correct. There is not much that can be done about this. The nomenclature is deeply baked into the code and the docs. We did change the help output to list "options" rather than "optional arguments". That helps the end use

[issue46718] Feature: itertools: add batches

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

[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-12 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue46728> ___ ___ Python-bugs-lis

[issue46282] return value of builtins is not clearly indicated

2022-02-11 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: -rhettinger ___ Python tracker <https://bugs.python.org/issue46282> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46713] Provide a C implementation of collections.abc.KeysView and friends

2022-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: - arbitrary mappings supports by the view ABCs + arbitrary mappings supported by the view ABCs - A first look, + At first glance, -- ___ Python tracker <https://bugs.python.org/issue46

[issue46713] Provide a C implementation of collections.abc.KeysView and friends

2022-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: Some thoughts: * Other than set operations, most of the pure python code in the dict view ABCs are fast pass throughs. There is no point in rewriting these in C: def __contains__(self, key): return key in self._mapping def __iter__(self

[issue46721] Optimize set.issuperset() for non-set argument

2022-02-11 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <https://bugs.python.org/issue46721> ___ ___ Python-bugs-list mailing list Un

[issue46718] Feature: itertools: add batches

2022-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: For large n, I don't think a C implementation would do much better than your Python version where most of the work is done by chain() and islice() which are already in C. The best that could be done is to eliminate the overhead of chain() which

[issue46705] Memory optimization for set.issubset

2022-02-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Would not testing len(self.difference(other)) == 0 > be more efficient? Yes, I think so. -- Added file: https://bugs.python.org/file50620/instrument_issubset.py ___ Python tracker <https://bugs.p

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : Added file: https://bugs.python.org/file50615/instrument_issubset.py ___ Python tracker <https://bugs.python.org/issue46705> ___ ___ Pytho

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : Removed file: https://bugs.python.org/file50614/instrument_issubset.py ___ Python tracker <https://bugs.python.org/issue46705> ___ ___ Pytho

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : Removed file: https://bugs.python.org/file50613/instrument_issubset.py ___ Python tracker <https://bugs.python.org/issue46705> ___ ___ Pytho

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: I've run a few more experiments and this looks like a net win more often than not. Go ahead and submit a PR so we can evaluate it further. -- Added file: https://bugs.python.org/file50614/instrument_issubset.py

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: We care more about the running speed than the memory usage. Since sets only store pointers to data, they are typically smaller than the data they refer to. I've attached some instrumentation code for running experiments to verify the workload under

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : -- versions: -Python 3.10, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue46705> ___ ___ Pytho

[issue46705] Memory optimization for set.issubset

2022-02-09 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <https://bugs.python.org/issue46705> ___ ___ Python-bugs-list mailing list Un

[issue46684] Expose frozenset._hash classmethod

2022-02-08 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <https://bugs.python.org/issue46684> ___ ___ Python-bugs-list mailing list Un

[issue46684] Expose frozenset._hash classmethod

2022-02-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Why not expose the C implementation via a frozenset._hash() > classmethod, and change Set._hash() to merely call that? The frozenset.__hash__ method is tightly bound to the internals of real sets to take advantage of the hash values already being

[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Your suggested signature looks like it's trying to support > the second invariant, but it doesn't quite: if the types > don't match, the type checker will just set T to the > common base type of the two arguments. Is there a way to writ

[issue46282] return value of builtins is not clearly indicated

2022-02-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: > New learners coming to Python don't know the same things > as people with experience. IMO, new learners will be worse off by adding "returns None" to all of the builtins. At best it a distractor. I work with new learners almost every

[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Implementing PEP 673 (Self type) ___ Python tracker <https://bugs.python

[issue46669] Add types.Self

2022-02-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: On a related note, is this the correct way to annotate __exit__? Exc = TypeVar('Exc', bound=Exception) def __exit__(self, exctype: Optional[Type[Exc]], excinst: Optional[Exc], exctb: Any) -> N

[issue46666] IDLE Add indent guide

2022-02-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: If this were possible, it would be really nice to have. FWIW, the rich¹ project was able to pull this off in regular text terminal window: $ python3.10 -m pip install rich $ python3.10 -m rich.pretty { │ 'foo': [1, 'Hello World!', 100.123, 323.232

[issue46669] Add types.Self

2022-02-06 Thread Raymond Hettinger
New submission from Raymond Hettinger : Typeshed now has a nice self-describing type variable to annotate context managers: Self = TypeVar('Self') def __enter__(self: Self) -> Self: return self It would be nice to have that in the standard library types module as w

[issue46615] Use-after-free by mutating set during set operations

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Marking as low priority given that ehe next loop code has been deployed without incident for two decades (a little less for sets and a little more for dicts). -- priority: normal -> low ___ Python trac

[issue46200] Discourage logging f-strings due to security considerations

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: In a favor of deferred substitution, the cookbook should have a recipe where substituted messages are logged to a file and the unsubstituted message stored in SQLite3 database with the parameters stored as JSON.This gives both human readable output

[issue46200] Discourage logging f-strings due to security considerations

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Eric is absolutely right, due to function calls being > somewhat slow in Python the performance argument in > practice falls in favor of f-strings. Also f-strings can evaluate expressions in the template which is also a big win: f('Pending

[issue46615] Use-after-free by mutating set during set operations

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Presumably _PyDict_Next is also suspect. Even the advertised "safe" calls to PyDict_SetItem() for existing keys would be a trigger. Calling clear() in either __eq__ or __hash__ would suffice. If the next loops are the culprint, the new

[issue46615] Use-after-free by mutating set during set operations

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: The likely culprit is the set_next() loop. Perhaps it is never safe to use set_next() because any lookup can callback to __eq__ which can mutate the set. Since set_isdisjoint() method isn't a mutating method, that is the easiest place to start

[issue46624] random.randrange removed support for non-integer types after just one release of deprecation

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

[issue46624] random.randrange removed support for non-integer types after just one release of deprecation

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 6baa98e538b2e26f16eaaf462f99496e98d2cfb1 by Miro Hrončok in branch 'main': bpo-46624: Defer to 3.12: "Remove deprecated support for non-integer values" (GH-31098) https://github.com/python/cpyt

[issue46621] Should map(function, iterable, ...) replace StopIteration with RuntimeError?

2022-02-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 for being a breaking change, for addressing a minor issue that rarely arises in real life, and for being a slippery slope. -- nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue46

[issue46610] assertCountEqual doesn't work as expected for dictionary elements

2022-02-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: I agree with Eric that this should not be changed. It is working as documented and intended. In its original incarenation, assertCountEqual was documented as being equivalent to ``assertEqual(sorted(expected), sorted(actual))``. Either way, the goal

[issue46561] Descriptor resolution should own arguments passed to descriptors

2022-02-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: If this can only be triggered from C code, it less of a concern. The PR increases cost on a critical path, so we ought to be wary of applying it unless a known problem is being solved. Note, this code path has survived two decades of deployment. Also

[issue46554] Add append keyword argument to Path.write_text() and Path.write_bytes()

2022-01-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Serhiy. -- nosy: +pitrou, rhettinger ___ Python tracker <https://bugs.python.org/issue46554> ___ ___ Pytho

[issue46574] itertools.count should work with non-number types

2022-01-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for the suggestion but I'm going to decline. * The need for this is very low. * It's easy to roll your own. * The code for `count('', 'a')` and `count((), (1,))` isn't intelligible. * Without special casing, the code for `count

[issue33205] GROWTH_RATE prevents dict shrinking

2022-01-25 Thread Raymond Hettinger
Change by Raymond Hettinger : -- status: closed -> open ___ Python tracker <https://bugs.python.org/issue33205> ___ ___ Python-bugs-list mailing list Un

[issue46527] enumerate no longer accepts iterable keyword argument

2022-01-25 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +rhettinger ___ Python tracker <https://bugs.python.org/issue46527> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33205] GROWTH_RATE prevents dict shrinking

2022-01-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: Should this have been "filled*3" rather than "used*3"? The intent was to give a larger resize to dict that had a lot of dummy entries and a smaller resize to dicts without deletions. -- __

[issue46488] listsort.txt wrongly assumes you cannot calculate leading zeros in O(1) time.

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

[issue37295] Possible optimizations for math.comb()

2022-01-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: > But I won't post code (unless someone asks) Okay, I'll ask. -- ___ Python tracker <https://bugs.python.org/issu

[issue46488] listsort.txt wrongly assumes you cannot calculate leading zeros in O(1) time.

2022-01-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: Presumably the OP is referring to this text: """ `powerloop()` emulates these divisions, 1 bit at a time, using comparisons, subtractions, and shifts in a loop. You'll notice the paper uses an O(1) method instead, but that relies on two

  1   2   3   4   5   6   7   8   9   10   >