[issue37863] Speed up hash(fractions.Fraction)

2019-08-17 Thread Tim Peters


Tim Peters  added the comment:

Some random notes:

- 1425089352415399815 appears to be derived from using the golden ratio to 
contrive a worst case for the Euclid egcd method.  Which it's good at :-)  Even 
so, the current code runs well over twice as fast as when replacing the 
pow(that, -1, P) with pow(that, P-2, P).

- Using binary gcd on the same thing requires only 46 iterations - and, of 
course, no divisions at all.  So that could be a big win.  There's no possible 
way to get exponentiation to require less than 60 iterations, because it 
requires that many squarings just to reach the high bit of P-2.  However, I 
never finishing working out how to extend binary gcd to return inverses too.

- All cases are "bad" for pow(whatever, P-2, P) because P-2 has 60 bits set.  
So we currently need 60 multiplies to account for those, in addition to 60 
squarings to reach P-2's high bit.  A significant speedup could probably have 
been gotten just by rewriting whatever**(P-2) as

(whatever ** 79511827903920481) ** 29

That is, express P-2 as its prime factorization.  There are 28 zero bits in the 
larger factor, so would save 28 multiply steps right there.  Don't know how far 
that may yet be from an optimal addition chain for P-2.

- The worst burden of the P-2-power method is that there's no convenient way to 
exploit that % P _can_ be very cheap, because P has a very special value.  The 
power method actually needs to divide by P on each step.  As currently coded, 
the egcd method never needs to divide by P (although _in_ the egcd part it 
divides narrower & narrower numbers < P).

- Something on my todo list forever was writing an internal routine for 
squaring, based on that (a+b)**2 = a**2 + 2ab + b**2.  That gives 
Karatsuba-like O() speedup but with simpler code, enough simpler that it could 
probably be profitably applied even to a relatively small argument.

Which of those do I intend to pursue?  Probably none :-(  But I confess to be 
_annoyed_ at giving up on extending binary gcd to compute an inverse, so I may 
at least do that in Python before I die ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16468] argparse only supports iterable choices

2019-08-17 Thread Brendan Barnwell


Brendan Barnwell  added the comment:

This issue has sat idle for six years.  Meanwhile, the docs are still 
incorrect, giving every user wrong information about how the module works.  Can 
we consider just changing the documentation instead of worrying about what the 
behavior should be or what the rationale is?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16697] argparse kwarg 'choices' documentation

2019-08-17 Thread Brendan Barnwell


Brendan Barnwell  added the comment:

This issue has sat idle for six years.  Meanwhile, the docs are still 
incorrect, giving every user wrong information about how the module works.  Can 
we consider just changing the documentation instead of worrying about what the 
behavior should be or what the rationale is?

--
nosy: +BrenBarn
versions: +Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16468] argparse only supports iterable choices

2019-08-17 Thread Brendan Barnwell


Brendan Barnwell  added the comment:

https://bugs.python.org/issue16468

--
nosy: +BrenBarn
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37868] `is_dataclass` returns `True` if `getattr` always succeeds.

2019-08-17 Thread Eric V. Smith


Change by Eric V. Smith :


--
keywords: +patch
pull_requests: +15042
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15325

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25299] TypeError: __init__() takes at least 4 arguments (4 given)

2019-08-17 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

Opened issue37880 to track this change.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37880] For argparse add_argument with action='store_const', const should default to None.

2019-08-17 Thread Joannah Nanjekye


New submission from Joannah Nanjekye :

Currently, when `parser.add_argument()` is given argument with 
`action='store_const'` and no `const` argument , it throws an exception :

>>> from argparse import ArgumentParser
>>> parser = ArgumentParser()
>>> parser.add_argument("--foo", help="foo", action='store_const')
Traceback (most recent call last):
File "", line 1, in 
File "/home/captain/projects/cpython/Lib/argparse.py", line 1350, in 
add_argument
action = action_class(**kwargs)
TypeError: __init__() missing 1 required positional argument: 'const'
>>>

Specifying the `const` argument stops this exception:

>>> parser.add_argument("--foo", help="foo", action='store_const', const=None)
_StoreConstAction(option_strings=['--foo'], dest='foo', nargs=0, const=None, 
default=None, type=None, choices=None, help='foo', metavar=None)

Originally the docs, said when `action` was set to` 'store_const'` `const` 
defaulted to `None` which was not matching with the implementation at the time. 

After this commit : 
https://github.com/python/cpython/commi/b4912b8ed367e540ee060fe912f841cc764fd293,
 The docs were updated to match the implementation to fix Bpo issues :

https://bugs.python.org/issue25299

https://bugs.python.org/issue24754 and

https://bugs.python.org/issue25314

I suggest that we make `const` default to `None` If `action='store_const'` as 
was intended originally before edits to the docs. If no one objects, I can open 
a PR for this.

--
messages: 349911
nosy: A. Skrobov, nanjekyejoannah, r.david.murray
priority: normal
severity: normal
status: open
title: For argparse add_argument with action='store_const', const should 
default to None.
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25299] TypeError: __init__() takes at least 4 arguments (4 given)

2019-08-17 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

Since both the docs and implementation now match, I suggest we close this and 
open a new issue suggesting to change the implementation back to make 
const=None when action='store_const'.

--
stage: needs patch -> resolved

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37552] [Windows] strptime/strftime return invalid results with UCRT version 17763.615

2019-08-17 Thread Steve Dower


Change by Steve Dower :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37664] Update bundled pip and setuptools

2019-08-17 Thread Steve Dower


Steve Dower  added the comment:

Is pip 19.2.2 worth taking? Or are we expecting another patch this week?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32910] venv: Deactivate.ps1 is not created when Activate.ps1 was used

2019-08-17 Thread Steve Dower


Change by Steve Dower :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37641] Embeddable distribution pyc filenames show build machine location

2019-08-17 Thread Steve Dower


Change by Steve Dower :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36266] Which module could not be found?

2019-08-17 Thread miss-islington


miss-islington  added the comment:


New changeset 786a4e1cef3eda8f434613d3801a5c7565fb5cd8 by Miss Islington (bot) 
in branch '3.8':
bpo-36266: Add module name in ImportError when DLL not found on Windows 
(GH-15180)
https://github.com/python/cpython/commit/786a4e1cef3eda8f434613d3801a5c7565fb5cd8


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36670] test suite broken due to cpu usage feature on win 10/ german

2019-08-17 Thread Steve Dower


Change by Steve Dower :


--
keywords: +easy, newcomer friendly

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36266] Which module could not be found?

2019-08-17 Thread Steve Dower


Steve Dower  added the comment:

Thanks for the contribution!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36266] Which module could not be found?

2019-08-17 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15041
pull_request: https://github.com/python/cpython/pull/15324

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37734] Registry keys for Windows Store package have wrong executable

2019-08-17 Thread Steve Dower


Change by Steve Dower :


--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36266] Which module could not be found?

2019-08-17 Thread Steve Dower


Steve Dower  added the comment:


New changeset 24fe46081be3d1c01b3d21cb39bc3492ab4485a3 by Steve Dower 
(shireenrao) in branch 'master':
bpo-36266: Add module name in ImportError when DLL not found on Windows 
(GH-15180)
https://github.com/python/cpython/commit/24fe46081be3d1c01b3d21cb39bc3492ab4485a3


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37879] Segfaults in C heap type subclasses

2019-08-17 Thread Eddie Elizondo


Change by Eddie Elizondo :


--
keywords: +patch
pull_requests: +15040
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15323

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37879] Segfaults in C heap type subclasses

2019-08-17 Thread Eddie Elizondo


New submission from Eddie Elizondo :

`subtype_dealloc` is not correctly handling the reference count of c heap type 
subclasses. It has some builtin assumptions which can result in the type 
getting its reference count decreased more that it needs to be, leading to its 
destruction when it should still be alive.

Also, this bug is a blocker for the full adoption of PEP384.

The full details of the bug along with a fix and tests are described in the 
Github PR.

--
messages: 349905
nosy: eelizondo
priority: normal
severity: normal
status: open
title: Segfaults in C heap type subclasses

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37841] Python store app launcher has dependency on msvcp140.dll

2019-08-17 Thread Steve Dower


Change by Steve Dower :


--
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37869] Compilation warning on GCC version 7.4.0-1ubuntu1~18.04.1

2019-08-17 Thread Hansraj Das


Change by Hansraj Das :


--
resolution:  -> duplicate

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37645] Replace PyEval_GetFuncName/PyEval_GetFuncDesc

2019-08-17 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> I'm wary of "%S" used in error messages.

Maybe you're misunderstanding something. The goal is not really to change error 
messages, only the way how they are produced. For example, we currently have

>>> def f(): pass
>>> f(**1)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: f() argument after ** must be a mapping, not int

This is about how the "f()" in the error message is produced. Currently, this 
uses PyEval_GetFuncName() and PyEval_GetFuncDesc(). For the reasons explained 
in this issue, I want to replace that.

I see two ways of doing this:

1. (PR 14890) Write a new function _PyObject_FunctionStr(func) which returns 
func.__qualname__ + "()" with a suitable fallback if there is no __qualname__ 
attribute. At some point, we could also introduce a %F format character for 
this.

2. (PR 15295) Use str(func) in the error message and change various __str__ 
methods (really tp_str functions) to give a more readable output.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37645] Replace PyEval_GetFuncName/PyEval_GetFuncDesc

2019-08-17 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> I'm wary of making error messages depend on the str representation of a 
> function; that would prevent us from changing it later.

Why wouldn't we be able to change anything? Typically, the exact string of an 
error message is NOT part of the API (the exception *type* is, but we're not 
talking about that).

> I'm wary of "%S" used in error messages. Those are for the programmer, not 
> the user

I'm not following here. Given that Python is a programming language, the user 
*is* the programmer.

Anyway, you don't have to be convinced. I'm trying to solve a problem here and 
I have two approaches (PR 14890 and PR 15295). I'm more inclined towards PR 
15295, but if you like the idea of PR 14890 better, we can go with that instead.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37754] alter size of segment using multiprocessing.shared_memory

2019-08-17 Thread Davin Potts


Davin Potts  added the comment:

Attempts to alter the size of a shared memory segment are met with a variety of 
different, nuanced behaviors on systems we want to support.  I agree that it 
would be valuable to be able to effectively realloc a shared memory segment, 
which thankfully the user can do with the current implementation although they 
become responsible for adjusting for platform-specific behaviors.  The design 
of the API in multiprocessing.shared_memory strives to be as feature-rich as 
possible while providing consistent behavior across platforms that can be 
reasonably supported; it also leaves the door open (so to speak) for users to 
exploit additional platform-specific capabilities of shared memory segments.

Knowing beforehand whether to create a segment or attach to an existing one is 
an important feature for a variety of use cases.  I believe this is discussed 
at some length in issue35813.  If what is discussed there does not help (it did 
get kind of long sometimes), please say so and we can talk through it more.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37830] continue and break in finally with return in try results with segfault

2019-08-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 15320 fixes a regression by changing the compiler. None is now always pushed 
on the stack before entering a try...finally block. The "return" statement with 
a non-constant value replaces it, so the stack is balanced.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37830] continue and break in finally with return in try results with segfault

2019-08-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +15039
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15320

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37801] Compilation on MINGW64 fails (CODESET,wcstok,...)

2019-08-17 Thread Erik Janssens


Erik Janssens  added the comment:

fyi 1 : this issue pops up in multiple places, cfr :

 * bpo-35890
 * bpo-20596

the selection of the wcstok function is based on MS_WINDOWS being
defined, rather than eg. an autoconf check on which function is
available. 

fyi 2 : I've been able to cross compile 3.8 with mingw64 (gcc 7.3), but with a 
custom meson script instead of autoconf

--
nosy: +erikjanss

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25299] TypeError: __init__() takes at least 4 arguments (4 given)

2019-08-17 Thread A. Skrobov


A. Skrobov  added the comment:

Joannah, I see that under #25314, the docs were updated to match the 
implementation: 
https://github.com/python/cpython/commit/b4912b8ed367e540ee060fe912f841cc764fd293

On the other hand, the discussion here (from 2015) and on #25314 (from 2016) 
includes suggestions for improvements in the implementation as well.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37565] test_faulthandler: test_register_chain() crash with SIGSEGV (signal 11) on Skylake chipset

2019-08-17 Thread Bennet Fauber


Bennet Fauber  added the comment:

It would appear that jshelly was correct and this is resolved by fixing the 
problem isolated in issue 21131, which was closed and a patch was committed.

https://github.com/python/cpython/pull/15276

--
nosy: +justbennet

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37790] subprocess.Popen() is extremely slow

2019-08-17 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

I don't seen any significant difference here (Ubuntu 18.04):

$ time python2 sp.py 
10.3433089256

real0m10,362s
user0m6,565s
sys 0m4,372s

$ time python3 sp.py 
11.746907234191895

real0m11,781s
user0m7,356s
sys 0m5,239s

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36947] [Good first issue] Fix 3.3.3.1 Metaclasses Documentation

2019-08-17 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
pull_requests: +15037
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15319

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-17 Thread Hansraj Das


Change by Hansraj Das :


--
nosy: +hansrajdas

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com