[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread Tim Peters

Tim Peters added the comment:

Let's spell one of these out, to better understand why sticking to native 
precision is inadequate.  Here's one way to write the Newton step in "guess + 
relatively_small_correction" form:

def plain(x, n):
g = x**(1.0/n)
return g - (g - x/g**(n-1))/n

Alas, it's pretty much useless.  That's because when g is a really good guess, 
`g` and `x/g**(n-1)` are, in native precision, almost the same.  So the 
subtraction cancels out almost all the bits, leaving only a bit or two of 
actual information.  For this kind of approach to be helpful in native 
precision, it generally requires a clever way of rewriting the correction 
computation that _doesn't_ suffer massive cancellation.

Example:

>>> x = 5.283415219603294e-14

and we want the square root.  Mark's `nroot` always gives the best possible 
result:

>>> nroot(x, 2)
2.298568080262861e-07

In this case, so does sqrt(), and also x**0.5 (on my box - pow() may not on 
yours):

>>> sqrt(x)
2.298568080262861e-07
>>> x**0.5
2.298568080262861e-07

You're going to think it needs "improvement", because the square of that is not 
x:

>>> sqrt(x)**2 < x
True

Let's see what happens in the `plain()` function above:

>>> g = x**0.5
>>> temp = x/g**(2-1)

>>> g.hex()
'0x1.ed9d1dd7ce57fp-23'
>>> temp.hex()
'0x1.ed9d1dd7ce580p-23'

They differ by just 1 in the very last bit.  There's nothing wrong with "the 
math", but _in native precision_ the subtraction leaves only 1 bit of 
information.

Then:

>>> correction = (g - temp)/2
>>> correction
-1.3234889800848443e-23

is indeed small compared to g, but it only has one "real" bit:

>>> correction.hex()
'-0x1.0p-76'

Finally,

>>> g - correction
2.2985680802628612e-07

is _worse_ than the guess we started with.  Not because of "the math", but 
because sticking to native precision leaves us with an extremely crude 
approximation to the truth.

This can be repaired in a straightforward way by computing the crucial 
subtraction with greater than native precision.  For example,

import decimal
c = decimal.DefaultContext.copy()
c.prec = 25

def blarg(x, n,
  D=decimal.Decimal,
  pow=c.power,
  sub=c.subtract,
  div=c.divide):
g = x**(1.0/n)
Dg = D(g)
return g - float(sub(Dg, div(D(x), pow(Dg, n-1 / n

del decimal, c

Then the difference is computed as

Decimal('-2.324439989147273024835272E-23')

and the correction (convert that to float and divide by 2) as:

-1.1622199945736365e-23

The magnitude of that is smaller than of the -1.3234889800848443e-23 we got in 
native precision, and adding the new correction to g makes no difference:  the 
correction is (correctly!) viewed as being too small (compared with g) to 
matter.

So, bottom line:  there is no known way of writing the Newton step that won't 
make things worse at times, so long as it sticks to native precision.  Newton 
iterations in native precision are wonderful when, e.g., you know you have 
about 20 good bits and want to get about 40 good bits quickly.  The last bit or 
two remain pure noise, unless you can write the correction computation in a way 
that retains "a bunch" of significant bits.  By far the easiest way to do the 
latter is simply to use more precision.

--

___
Python tracker 

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



[issue24052] sys.exit(code) returns "success" to the OS for some nonzero values of code

2016-08-28 Thread Martin Panter

Martin Panter added the comment:

Here is a relevant Posix bug thread:
http://austingroupbugs.net/view.php?id=947

As well as Windows, apparently Solaris, OS X, and a recent version of Free BSD 
have more than eight bits of exit status. I don’t know if Python’s sys.exit() 
supports this though.

--
nosy: +martin.panter

___
Python tracker 

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



[issue25969] Update lib2to3 grammar to include missing unpacking generalizations.

2016-08-28 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith
priority: normal -> high
versions: +Python 2.7

___
Python tracker 

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



[issue27877] Add recipe for "valueless" Enums to docs

2016-08-28 Thread Emanuel Barry

Emanuel Barry added the comment:

The patch doesn't apply. I manually copy-pasted the lines in the source and 
generated a new one.

I would probably rephrase "these values hold no meaning and should not be used" 
into "the values are not important" or something along those lines.

--
nosy: +ebarry
Added file: https://bugs.python.org/file44250/enum_valueless_1.patch

___
Python tracker 

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



[issue24045] Behavior of large returncodes (sys.exit(nn))

2016-08-28 Thread Martin Panter

Martin Panter added the comment:

Is this a duplicate of Issue 24052?

--
nosy: +martin.panter

___
Python tracker 

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



[issue27886] Docs: the difference between rename and replace is not obvious

2016-08-28 Thread Eryk Sun

Eryk Sun added the comment:

Having rename() in pathlib is fine as long as it links to the os docs. This 
probably needs a new issue, but I do see room for improvement in the latter.

For Unix, the os.rename and os.replace docs should clarify that an empty 
destination directory can be replaced by another directory. For example:

>>> os.mkdir('foo1')
>>> os.mkdir('foo2')
>>> os.rename('foo1', 'foo2')

The specification of rename [1] states that "[i]f the *old* argument points to 
the pathname of a directory, the *new* argument shall not point to the pathname 
of a file that is not a directory". It further specifies that "[i]f *new* names 
an existing directory, it shall be required to be an empty directory". Windows, 
on the other hand, doesn't allow replacing a directory, even an empty one. The 
wording for os.rename and os.replace could be changed to something like: "[i]f 
dst is a directory, OSError will be raised, except not on Unix if src is a 
directory and dst is empty".

Windows MoveFileEx calls NtSetInformationFile to set the FileRenameInformation 
[2]. The MSDN docs do not explicitly require that the operation is atomic, 
unlike POSIX rename. I think it's a reasonable expectation that a Windows 
filesystem should rename atomically, and that's probably the case. However, it 
should be clear that only Unix guarantees this, e.g. "[i]f successful, on Unix 
the renaming will be an atomic operation, as required by POSIX".

MSDN claims that a rename will fail in the following cases:

A file or directory can only be renamed within a volume. 

Even if ReplaceIfExists is set to TRUE, the rename operation
will still fail if a file with the same name already exists
and is a directory, a read-only file, or a currently
executing file.

A file cannot be renamed if it has any open handles, unless it
is only open because of a batch opportunistic lock (oplock)
and the batch oplock can be broken immediately.

A file cannot be renamed if a file with the same name exists
and has open handles (except in the batch-oplock case
described earlier).

A directory cannot be renamed if it or any of its
subdirectories contains a file that has open handles (except
in the batch-oplock case described earlier).

For the third case, actually an open file can be renamed if delete/rename 
access is shared. For example:

>>> with open('foo1', 'w') as f: f.write('foo1')
...
4

Open the file with shared delete access:

>>> SHARE_ALL = 7
>>> _winapi.CreateFile('foo1', 0x8000, SHARE_ALL, 0, 3, 0, 0)
224

and rename/replace succeeds: 

>>> os.replace('foo1', 'foo2')
>>> open('foo2').read()
'foo1'

Anyway, the os.replace docs could state in general that: "[o]n Windows, a 
PermissionError will be raised if dst is a read-only file, or if either src or 
dst is currently open, or if src is a directory with an open file".

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html
[2]: https://msdn.microsoft.com/en-us/library/ff540344

--
nosy: +eryksun

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread Tim Peters

Tim Peters added the comment:

As I said, the last code I posted is "fast enough" - I can't imagine a real 
application can't live with being able to do "only" tens of thousands of roots 
per second.  A geometric mean is typically an output summary statistic, not a 
transformation applied billions of times to input data.

To get a 100% guarantee of 100% portability (although still confined to IEEE 
754 format boxes), we can't use the libm pow() at all.  Then you can kiss speed 
goodbye.  Mark's `nroot` is portable in that way, but can take tens of 
thousands of times longer to compute a root.

Here's another way, but routinely 100 times slower (than the last code I 
posted):

import decimal
c = decimal.DefaultContext.copy()
c.prec = 25

def slow(x, n,
 D=decimal.Decimal,
 pow=c.power,
 div=c.divide,
 d1=decimal.Decimal(1)):
return float(pow(D(x), div(d1, n)))

del decimal, c

Too slow for my tastes, but at least it's obvious ;-)

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread STINNER Victor

STINNER Victor added the comment:

Tim Peters: "Victor, happy to add comments, but only if there's
sufficient interest in actually using this."

It looks like tests fail on some platforms. I guess that it depends on
the different factors: quality of the C math library, quality of the
IEEE 754 hardware implementation, etc.

I like the idea of providing an accurate and *portable* function
(_nth_root) thanks to the usage of the decimal module to get a better
precision.

If someone considers that the performance of
statistics.geometric_mean() matters, I suggest to document it. It's
new feature of Python 3.6, it's not like a regression, so it's ok.

What do you think?

--

___
Python tracker 

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



[issue27877] Add recipe for "valueless" Enums to docs

2016-08-28 Thread John Hagen

John Hagen added the comment:

Patch attached.

--
keywords: +patch
Added file: https://bugs.python.org/file44249/issue27877.johnthagen.01.patch

___
Python tracker 

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



[issue27886] Docs: the difference between rename and replace is not obvious

2016-08-28 Thread R. David Murray

R. David Murray added the comment:

No, we don't like to overuse warnings.

--

___
Python tracker 

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



[issue27886] Docs: the difference between rename and replace is not obvious

2016-08-28 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Just keeping the reference to `os.rename()`: 
https://docs.python.org/3/library/os.html#os.rename

Aha, `os.rename` says: "On Unix, if dst exists and is a file, it will be 
replaced silently if the user has permission." and "On Windows, if dst already 
exists, OSError will be raised even if it is a file."

Sorry, I've missed this.

Maybe it worth to add `.. warning:` section for both `os.rename` and 
`pathlib.Path.rename`?

--

___
Python tracker 

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



[issue27886] Docs: the difference between rename and replace is not obvious

2016-08-28 Thread R. David Murray

R. David Murray added the comment:

The existing docs are pretty clear on the difference: rename is only guaranteed 
to replace an existing file on unix (which I think means posix in this 
context), whereas replace always replaces the file, regardless of platform.

I'm actually surprised that rename is even part of the pathlib API, since its 
cross platform behavior is not consistent.  It also seems as though the replace 
docs are incorrect, since they imply directories are replaced, but the os docs 
say they are not.

The "this is a posix requirement" note in os.replace also seems imprecise.  
Windows is not posix, so that note leaves me wondering if replace is atomic on 
Windows or not.  That should be clarified one way or another.

I think adding the cross platform note in the pathlib docs is reasonable, since 
it addresses the question of why there are two similar functions.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27886] Docs: the difference between rename and replace is not obvious

2016-08-28 Thread R. David Murray

Changes by R. David Murray :


--
versions:  -Python 3.4

___
Python tracker 

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



[issue27744] Add AF_ALG (Linux Kernel crypto) to socket module

2016-08-28 Thread Christian Heimes

Christian Heimes added the comment:

New patch with setsockopt(socket.SOL_ALG, socket.ALG_SET_AEAD_AUTHSIZE, None, 
taglen) instead of (None, taglen).

--
Added file: 
https://bugs.python.org/file44248/AF_ALG-kernel-crypto-support-for-socket-module-2.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-28 Thread Christian Heimes

Christian Heimes added the comment:

Thanks Alex, I ported the Python and C code to 2.7 but forgot to address doc 
updates. You can find an updated patch on github: 
https://github.com/python/cpython/compare/2.7...tiran:feature/openssl110_27 
I'll submit a new patch after your review.

Chi Hsuan Yen, I'll update remaining documentation later.

--

___
Python tracker 

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



[issue27886] Docs: the difference between rename and replace is not obvious

2016-08-28 Thread Andrew Svetlov

New submission from Andrew Svetlov:

Hi.

On reading the doc for pathlib I've stuck with `.rename()` and `.replace()` 
(https://docs.python.org/3/library/pathlib.html#pathlib.Path.rename).

What's the difference?

Going to pathlib's source code I've figured out that methods are use different 
functions from `os` module: `os.rename()` and `os.replace()`.

But the documentation for `os` module is not obvious too: 
the docs for both functions are almost equal from my perspective, the only 
significant difference is that `os.rename()` suggests to use `os.replace()` for 
cross-compatibility.

Could anybody explain the difference?

Also, at least the doc for `pathlib.Path.rename` worth to have a sentence like 
borrowed from `os.rename`: "If you want cross-platform overwriting of the 
destination, use replace()."

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 273836
nosy: asvetlov, docs@python, pitrou
priority: low
severity: normal
status: open
title: Docs: the difference between rename and replace is not obvious
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue27877] Add recipe for "valueless" Enums to docs

2016-08-28 Thread John Hagen

John Hagen added the comment:

Raymond, thanks for your consideration and input.

I'll work on a small patch unless I hear from Ethan that he'd rather do it.  
I'm happy to defer to his expertise.

I did try out None as a value just to be sure that that didn't work as it would 
not be a bad alternative.  But since the values are "equal", Enum tries to 
alias them.

import enum

@enum.unique
class Color(enum.Enum):
red = None
green = None
blue = None

>>> ValueError: duplicate values found in : green -> red, blue -> 
>>> red

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread Tim Peters

Tim Peters added the comment:

Steven, you certainly _can_ ;-) check first whether `r**n == x`, but can you 
prove `r` is the best possible result when it's true?  Offhand, I can't.  I 
question it because it rarely seems to _be_ true (in well less than 1% of the 
random-ish test cases I tried).  An expensive test that's rarely true tends to 
make things slower overall rather than faster.

As to whether a Newton step won't make things worse, that requires seeing the 
exact code you're using.  There are many mathematically equivalent ways to code 
"a Newton step" that have different numeric behavior.  If for some unfathomable 
(to me) reason you're determined to stick to native precision, then - generally 
speaking - the numerically best way to do "a correction step" is to code it in 
the form:

r += correction  # where `correction` is small compared to `r`

Coding a Newton step here as, e.g., `r = ((n-1)*r + x/r**(n-1))/n` in native 
precision would be essentially useless:  multiple rounding errors show up in 
the result's last few bits, but the last few bits are the only ones we're 
_trying_ to correct.

When `correction` is small compared to `r` in `r += correction`, the rounding 
errors in the computation of `correction` show up in correction's last few 
bits, which are far removed from `r`'s last few bits (_because_ `correction` is 
small compared to `r`).  So that way of writing it _may_ be helpful.

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread Tim Peters

Tim Peters added the comment:

That's clever, Serhiy!  Where did it come from?  It's not Newton's method, but 
it also appears to enjoy quadratic convergence.

As to speed, why are you asking?  You should be able to time it, yes?  On my 
box, it's about 6 times slower than the last code I posted.  I assume (but 
don't know) that's because + - * / have trivial cost compared to power() and 
ln(), and your code uses two ln() while the last code I posted uses only one 
power().  Also, my power() has an exact integer exponent, which - for whatever 
reasons - appears to run much faster than using a non-integer Decimal exponent. 
 It's for the latter reason that I didn't suggest just doing `return float(D(x) 
** (D(1)/n))` (much slower).

Or maybe it's "a platform thing".  FYI, I'm using the released Python 3.5.2 on 
64-bit Win 10 Pro.

--

___
Python tracker 

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



[issue27885] Add a Crypto++ Wrapper for when Someone needs to use Crypto++ things outside of C++, e.g. in Python Code

2016-08-28 Thread R. David Murray

R. David Murray added the comment:

And, not surprisingly, the pypi package already exists: 
https://pypi.python.org/pypi/pycryptopp/0.7.1.869544967005693312591928092448767568728501330214

The rest of my comment stands.

--

___
Python tracker 

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



[issue27885] Add a Crypto++ Wrapper for when Someone needs to use Crypto++ things outside of C++, e.g. in Python Code

2016-08-28 Thread R. David Murray

R. David Murray added the comment:

This kind of thing should be a pypi package.  The process for getting something 
included in the standard library includes it being available on pypi, as well 
as a widespread need for the functionality, and even then it is not easy to get 
something included.  There have been various discussions around crypto support 
in the stdlib, so anything along these lines need to be part of that wider 
discussion, mostly likely on python-ideas (I'm sure there must be previous 
threads there about crypto).

(As an aside: 3.6 beta is in two weeks, so there'd be no time even if this was 
a good idea.)

--
nosy: +r.david.murray
resolution:  -> rejected
stage:  -> 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



[issue27885] Add a Crypto++ Wrapper for when Someone needs to use Crypto++ things outside of C++, e.g. in Python Code

2016-08-28 Thread Decorater

New submission from Decorater:

So, I have Python Code that would be nice if the interpreter had a built in 
Crypto++ support. I am Suggesting for 3.6 to Add in this as it would be helpful 
for any Python Developer to do something like:

import cryptopp

And then doing the functiosn that Crpyto++ Provides for some needed and good 
Encryption Techniques that zlib lacks and hey the cool stuff is that Crypto++ 
Can be used after zlib is used so it can be beneficial to many people as it can 
save soem file sizes.

Also Crypto++ Seems to have some things that zlib has as well like Deflate, 
Adler32, CRC, etc. So that makes zlib not be the only thing to compute 
checksums.

Useful Links:
http://www.cryptopp.com/
https://github.com/weidai11/cryptopp
Hopefully something like this could be possible but I do not see why not as it 
was done for zlib. I have no idea if crypto++ is windows only though but it is 
worth a test to find out.

--
components: Extension Modules, Library (Lib)
messages: 273830
nosy: Decorater
priority: normal
severity: normal
status: open
title: Add a Crypto++ Wrapper for when Someone needs to use Crypto++ things 
outside of C++, e.g. in Python Code
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Wouldn't following implementation be faster?

import decimal
c = decimal.DefaultContext.copy()
c.prec = 25
def rootn(x, n,
  D=decimal.Decimal,
  sub=c.subtract,
  mul=c.multiply,
  log=c.ln):
g = x ** (1.0/n)
g += float(sub(log(D(x)), mul(log(D(g)), D(n * g / n
return g
del decimal, c

--

___
Python tracker 

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



[issue27051] Create PIP gui

2016-08-28 Thread Nick Coghlan

Nick Coghlan added the comment:

As David hinted at, the pip GUI should *not* support privilege escalation on 
Linux - needing to do so indicates someone is attempting to install into the 
system Python, and the GUI should never do that. If there's no active virtual 
environment, it should do a user install by default.

(The only reason pip doesn't work that way by default is due to backwards 
compatibility constraints affecting tools that assume that root can install 
into system Python installations without any additional flags)

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread Steven D'Aprano

Steven D'Aprano added the comment:

This has been really eye-opening, and I just wanted to drop you a note 
that I am watching this thread carefully. My first priority is to get 
the tests all passing before beta 1 on 2016-09-12, even if (as seems 
likely) that means weakening the tests, and then come back and see if we 
can tighten it up again later.

I haven't checked it in yet, but I've already managed to simplify the 
nth_root code by taking Tim's advice that more than one iteration of 
Newton's method is a waste of time. Thanks!

Can somebody comment on my reasoning here?

I start by taking an initial guess for the root by using 
r = pow(x, 1.0/n). Then I test if r**n == x, if it does I conclude that 
r is either the exact root, or as close as representable as a float, and 
just return it without bothering with even one iteration. Sensible?

Or should I just always run one iteration of Newton and trust that it 
won't make things worse?

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread Tim Peters

Tim Peters added the comment:

Victor, happy to add comments, but only if there's sufficient interest in 
actually using this.  In the context of this issue report, it's really only 
important that Mark understands it, and he already does ;-)

For example, it starts with float `**` because that's by far the fastest way to 
get a very good approximation.  Then it switches to Decimal to perform a Newton 
step using greater-than-float precision, which is necessary to absorb rounding 
errors in intermediate steps.  Then it rounds back to float, because it has to 
- it's a "float in, float out" function.  It's for the same reason, e.g., that 
Mark's `nroot` converts floats to potentially gigantic integers for its Newton 
step(s), and my other `fractions.Fraction` function converts floats to 
potentially gigantic rationals.  "Potentially gigantic" may be necessary to 
guarantee always-correct rounding of the final result, but isn't necessary to 
guarantee < 1 ulp error in the final result.

--

___
Python tracker 

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



[issue27884] during 'make install', pre-existing site-packages residents are recompiled. Twice.

2016-08-28 Thread R. David Murray

R. David Murray added the comment:

As far as I can tell, this is working as designed, and in fact you ought to see 
site-packages getting compiled *three* times (normal, -O, and -OO).

I wonder if this is a holdover from when we didn't have per-interpreter pyc 
files, and its just that no one noticed the need for recompile of site-packages 
didn't exist any more.  On the other hand, I may be missing some piece of logic 
that means that it is still needed.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27884] during 'make install', pre-existing site-packages residents are recompiled. Twice.

2016-08-28 Thread Matt Morrison

New submission from Matt Morrison:

I've been building Python 3 from source on Linux for a long time (at least 
since 3.2 days), and I honestly can't remember if this has happened before 3.6 
or not, which is why I'm only tagging this 3.6. 

Basically, when running 'make install' (after building either static or shared, 
I haven't been messing around with any other options except install prefix - 
$HOME) you'll start seeing messages like:

=
Listing 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/__init__.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/anova_nistcertified.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/ar_panel.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/example_kernridge.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/gmm.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/kernridgeregress_class.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/ols_anova_original.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/onewaygls.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/penalized.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/predstd.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/runmnl.py'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/sympy_diff.py'...
Listing 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/tests'...
Compiling 
'/home/mattdmo/lib/python3.6/site-packages/statsmodels/sandbox/regression/tests/__init__.py'...
=

and on and on and on. I usually don't pay much attention to them, but since I 
have nothing better to do I just stare idly at them and watch as all my 
third-party modules in 'site-packages' scroll by in alphabetical order very 
quickly. For the last few builds of 3.6, though, I've noticed that the modules 
get gone through twice. I have a pretty large number of modules (341, according 
to `ls | wc -l`), so it takes a while to go through them, and they're 
definitely being repeated.

Unfortunately, I don't know a whole lot about Makefiles or the internals of the 
installation process, so I don't have the slightest idea of where to begin even 
looking for the bug. But, I bet you ladies and gentlemen do :)

If it's necessary, I can rebuild and pipe all the output into a file for you to 
examine. Just let me know.

--
components: Build, Extension Modules, Installation
messages: 273824
nosy: MattDMo
priority: normal
severity: normal
status: open
title: during 'make install', pre-existing site-packages residents are 
recompiled. Twice.
versions: Python 3.6

___
Python tracker 

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



[issue27883] sqlite-3.14.1 for Python_3.6.0b1 ?

2016-08-28 Thread Big Stone

Big Stone added the comment:

remark: since sqlite 3.11.0, sqlite.org default sqlite3.dll includes  FTS3, 
FTS5, RTREE, DBSTAT, JSON1, and RBU extensions, causing sqlite3.dll to jump to 
1646Ko size instead of 756Ko current (windows 64).

This works well over Python3.5.2 64 bit, but you may prefer a version with not 
all these extensions. I don't know the respective size of each one. 

the JSON1 extension would be nice if we can keep it: 
- web technology,
- similar to postgresql, so good to go at schools.

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-28 Thread STINNER Victor

STINNER Victor added the comment:

Hum, "g = D(x**(1.0/n))" computes a float and then convert it to a decimal,
right?

Can we please add comments to explain why you start with float, compute
decimal and finish with float?

And maybe also document the algorithm?

--

___
Python tracker 

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



[issue27883] sqlite-3.14.1 for Python_3.6.0b1 ?

2016-08-28 Thread Big Stone

New submission from Big Stone:

Sqlite-3.14.1 includes a lot of fixes since sqlite-38.11, including some for 
windows ;-) . it would be nice to upgrade

--
components: Windows
messages: 273821
nosy: Big Stone, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: sqlite-3.14.1 for Python_3.6.0b1 ?
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue27881] Fix possible bugs when setting sqlite3.Connection.isolation_level

2016-08-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
stage:  -> patch review

___
Python tracker 

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



[issue27881] Fix possible bugs when setting sqlite3.Connection.isolation_level

2016-08-28 Thread Xiang Zhang

Xiang Zhang added the comment:

issue27881.patch tires to solve this. Hope to get feedback.

--
keywords: +patch
Added file: https://bugs.python.org/file44247/issue27881.patch

___
Python tracker 

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



[issue27413] Add an option to json.tool to bypass non-ASCII characters.

2016-08-28 Thread Berker Peksag

Berker Peksag added the comment:

> If I'm not misreading your comment, this will change the original behavior, 
> right?

Assuming you also change

   ensure_ascii = not options.no_ensure_ascii

to

   ensure_ascii = options.no_ensure_ascii

no, it won't change the original behavior. That way you won't need to invert 
the value of ``options.no_ensure_ascii`` in line 37.

--

___
Python tracker 

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



[issue27882] Python docs on 9.2 Math module lists math.log2 as function but it does not exist

2016-08-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

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



[issue27413] Add an option to json.tool to bypass non-ASCII characters.

2016-08-28 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
Removed message: https://bugs.python.org/msg273813

___
Python tracker 

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



[issue27413] Add an option to json.tool to bypass non-ASCII characters.

2016-08-28 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> 

___
Python tracker 

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



[issue27877] Add recipe for "valueless" Enums to docs

2016-08-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

After a little more thought, I think this would be a worthwhile recipe and 
would help communicate the notion that the value has no particular meaning.

--

___
Python tracker 

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



[issue27877] Add recipe for "valueless" Enums to docs

2016-08-28 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
Removed message: https://bugs.python.org/msg273815

___
Python tracker 

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



[issue27413] Add an option to json.tool to bypass non-ASCII characters.

2016-08-28 Thread Wei-Cheng Pan

Wei-Cheng Pan added the comment:

1. Replaced non-ASCII literals to \u
2. Removed failed assertion

Test passed with LC_ALL=en_US and LC_ALL=en_US.UTF-8 .

I've tried to use locale.getdefaultlocale(), but seems the output string will 
vary in different locales.

--
Added file: 
https://bugs.python.org/file44246/json-add-an-option-to-bypass-non-ascii-characters-v4.patch

___
Python tracker 

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



[issue27413] Add an option to json.tool to bypass non-ASCII characters.

2016-08-28 Thread Wei-Cheng Pan

Changes by Wei-Cheng Pan :


Removed file: 
https://bugs.python.org/file44243/json-add-an-option-to-bypass-non-ascii-characters-v3.patch

___
Python tracker 

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



[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?

2016-08-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I put this in the "new feature" category in the sense that after beta we're 
trying to stabilize the code base.  Introducing a new opcode is a higher risk 
change that needs to go in the release cycle as early as possible.

--

___
Python tracker 

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



[issue27877] Add recipe for "valueless" Enums to docs

2016-08-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

-0 I concur with OP's observation that "object() returns a new unique value 
while conveying that that value should not be expected to be used in any 
meaningful way" and that this recipe could help reinforce that notion.  That 
said, the idiomatic way to communicate this in Python is to use None rather 
than to create distinct meaningless objects.

Also, the motivation seems questionable.  Instead of showing a real world case 
where some confusion exists, there seems to be a general irritation that Enum 
implementation details differ in some respects from various compiled languages. 
 ISTM, the recipe is aimed at an imagined problem rather than an actual problem 
-- in a real use case (not a toy Color example), I would expect that if the 
value field is meaningless, then the use case itself will tend to make it 
self-evident that there is no reason to access the value field (and if it 
didn't, I don't see how returning some arbitrary instance of object() would be 
more informative than returning None.)

--
nosy: +rhettinger

___
Python tracker 

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



[issue27413] Add an option to json.tool to bypass non-ASCII characters.

2016-08-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Test fails on non-utf8 locale.

$ LC_ALL=en_US ./python -m test.regrtest -v -m test_no_ensure_ascii_flag 
test_json
...
==
FAIL: test_no_ensure_ascii_flag (test.test_json.test_tool.TestTool)
--
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_json/test_tool.py", line 115, in 
test_no_ensure_ascii_flag
self.assertEqual(out.splitlines(), b'"\\u6e2c\\u8a66"\n'.splitlines())
AssertionError: Lists differ: [b'"\\u00e6\\u00b8\\u00ac\\u00e8\\u00a9\\u00a6"'] 
!= [b'"\\u6e2c\\u8a66"']

First differing element 0:
b'"\\u00e6\\u00b8\\u00ac\\u00e8\\u00a9\\u00a6"'
b'"\\u6e2c\\u8a66"'

- [b'"\\u00e6\\u00b8\\u00ac\\u00e8\\u00a9\\u00a6"']
+ [b'"\\u6e2c\\u8a66"']

--

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue27413] Add an option to json.tool to bypass non-ASCII characters.

2016-08-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The patch looks good.  If no one else objects soon, I will apply it.

--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue27882] Python docs on 9.2 Math module lists math.log2 as function but it does not exist

2016-08-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Also, check your Python version to make sure that you're running Python 3.3 or 
later.

--
nosy: +rhettinger
status: pending -> open

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-28 Thread Xiang Zhang

Xiang Zhang added the comment:

It's a trivial personal style choice I think. Do what you want if you'd like to 
merge it.

--

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM except one style nit.

--

___
Python tracker 

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



[issue27867] various issues due to misuse of PySlice_GetIndicesEx

2016-08-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm saying that PySlice_GetIndicesEx2 can't just use Py_SIZE.

--

___
Python tracker 

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