[issue40286] Add randbytes() method to random.Random

2020-04-20 Thread STINNER Victor
STINNER Victor added the comment: I created bpo-40346: "Redesign random.Random class inheritance". -- ___ Python tracker ___ ___ Py

[issue40346] Redesign random class inheritance

2020-04-20 Thread STINNER Victor
New submission from STINNER Victor : The random.Random class has a strange inheritance which is something uncommon in Python: it inherits from _random.Random which a concrete Mersenne Twister PRNG. When a class inherit it, like random.SystemRandom, it should carefully override the right meth

[issue40312] Weakref callbacks running before finalizers in GC collection

2020-04-20 Thread Tim Peters
Tim Peters added the comment: A simple (finalizer-only) example of what an SCC-based DAG topsort ordering would accomplish: import gc class C: def __init__(self, val): self.val = val def __del__(self): print("finalizing", self.val) c, b, a

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread Antoine Pitrou
Change by Antoine Pitrou : -- keywords: +patch nosy: +pitrou nosy_count: 1.0 -> 2.0 pull_requests: +18957 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19539 ___ Python tracker

[issue40347] Programming FAQ about "How do you remove duplicates from a list?" -- Improve the examples + Mention possible caveats

2020-04-20 Thread Dominik V.
New submission from Dominik V. : https://docs.python.org/3/faq/programming.html#how-do-you-remove-duplicates-from-a-list In the beginning it points to the recipes at https://code.activestate.com/recipes/52560/ which does mention various caveats such as > [...] whether [elements are] hashable

[issue40348] Programming FAQ about "What is delegation?": Fix typos

2020-04-20 Thread Dominik V.
New submission from Dominik V. : https://docs.python.org/3/faq/programming.html#what-is-delegation The code example uses `self._outfile` with a single leading underscore, however in the subsequent text it is referred to with a double leading underscore: * [...] calling the underlying `self.__

[issue39939] PEP 616: Add str methods to remove prefix or suffix

2020-04-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: I disagree with the rationale given in the PEP. The reason that "startswith" and "endswith" don't have underscores is that the aren't needed to disambiguate the text. Our rules are to add underscores when it improves readability, which in this case it d

[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Dominik V.
Dominik V. added the comment: It was not my intention to disturb the traffic on the bug tracker. My apologies if that caused any trouble. I also thought only people subscribed to the indicated topic (e.g. "Documentation") would receive a notification. The docs pages mention that for enhancem

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: -18957 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Andy Lester
Change by Andy Lester : -- nosy: +petdance ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Your contributions are welcome. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Un

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: The randbytes() method could have been added effortlessly as a one line pure python method. It only became complicated as a result of premature optimization into C code and as a result of ignoring the API promises. You really don't have to redesign the w

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +18958 pull_request: https://github.com/python/cpython/pull/19631 ___ Python tracker ___ __

[issue40342] Programming FAQ about "How do I apply a method to a sequence of objects?" should include the option of an explicit for-loop

2020-04-20 Thread Vedran Čačić
Vedran Čačić added the comment: I must say I agree with Dominik here. Too many times my students write list comprehensions when they mean a for loop. It's not just a "has result vs updates inplace" dichotomy: often it produces some output like a drawing or just a print() call [one of rare thi

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread STINNER Victor
STINNER Victor added the comment: Attached PR 19631 adds random.BaseRandom. random.SystemRandom now inherits from BaseRandom and so no longer inherits from _random.Random: an instance now only takes 48 bytes of memory, rather than 2568 bytes (on x86-64). -- _

[issue40313] bytes.hex(sep, bytes_per_sep) is many times slower than manually inserting the separators

2020-04-20 Thread Gregory P. Smith
Change by Gregory P. Smith : -- assignee: -> gregory.p.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40313] bytes.hex(sep, bytes_per_sep) is many times slower than manually inserting the separators

2020-04-20 Thread miss-islington
miss-islington added the comment: New changeset 6a9e80a93148b13e4d3bceaab5ea1804ab0e64d5 by sweeneyde in branch 'master': bpo-40313: speed up bytes.hex() (GH-19594) https://github.com/python/cpython/commit/6a9e80a93148b13e4d3bceaab5ea1804ab0e64d5 -- nosy: +miss-islington __

[issue40313] bytes.hex(sep, bytes_per_sep) is many times slower than manually inserting the separators

2020-04-20 Thread STINNER Victor
STINNER Victor added the comment: Thanks Dennis for the optimization! FYI I also pushed another optimization recently: commit 455df9779873b8335b20292b8d0c43d66338a4db Author: Victor Stinner Date: Wed Apr 15 14:05:24 2020 +0200 Optimize _Py_strhex_impl() (GH-19535) Avoid a tem

[issue40335] Regression in multiline SyntaxError offsets

2020-04-20 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___

[issue40335] Regression in multiline SyntaxError offsets

2020-04-20 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 11a7f158ef51b0edcde3c3d9215172354e385877 by Pablo Galindo in branch 'master': bpo-40335: Correctly handle multi-line strings in tokenize error scenarios (GH-19619) https://github.com/python/cpython/commit/11a7f158ef51b0edcde3c3d921517235

[issue40089] Add _at_fork_reinit() method to locks

2020-04-20 Thread STINNER Victor
Change by STINNER Victor : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ __

[issue39954] test_subprocess: test_specific_shell() fails on AMD64 FreeBSD Shared 3.x

2020-04-20 Thread STINNER Victor
STINNER Victor added the comment: AMD64 FreeBSD Shared 3.x is green again, I close the issue. -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker __

[issue39933] test_gdb fails on AMD64 FreeBSD Shared 3.x: ptrace: Operation not permitted

2020-04-20 Thread STINNER Victor
STINNER Victor added the comment: AMD64 FreeBSD Shared 3.x is green again, I close the issue. -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker __

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Having SystemRandom() use less memory is nice. The seed() logic is reusable (not MT specific) and should be kept. Historically, subclassers were supposed to supply random(), and the getrandbits() method was optional and just added greater range to randr

[issue40349] Python3.9 changes col_offset for some ast nodes

2020-04-20 Thread Shantanu
New submission from Shantanu : With Python 3.8: ``` Python 3.8.1 (default, Jan 23 2020, 23:36:06) [Clang 11.0.0 (clang-1100.0.33.17)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> ast.parse("(a).x").body[0].value.col_offset 1 ``` With Pytho

[issue40349] Python3.9 changes col_offset for some ast nodes

2020-04-20 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +BTaskaya, pablogsal ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue40349] Python3.9 changes col_offset for some ast nodes

2020-04-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: col_offset = 0 is the correct value. There was a bug which is fixed now (see issue39474). -- nosy: +serhiy.storchaka resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker

[issue40286] Add randbytes() method to random.Random

2020-04-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: $ ./python -m timeit -s 'import random' 'random.randbytes(10**6)' 200 loops, best of 5: 1.36 msec per loop $ ./python -m timeit -s 'import random' 'random.getrandbits(10**6*8).to_bytes(10**6, "little")' 50 loops, best of 5: 6.31 msec per loop The Python im

<    1   2