Steven D'Aprano added the comment:
This was discussed on Python-Ideas:
https://mail.python.org/archives/list/python-id...@python.org/message/LSGZF3G4RFVTKXB5Y2EW5USL2JANG5RS/
and on Discuss:
https://discuss.python.org/t/why-no-tuple-comprehension/2820/1
In both cases the consensu
Steven D'Aprano added the comment:
Regarding performance, on my computer, the overhead of calling tuple() on a
list comp ranges from about 30% for tiny sequences down to about 5% for largish
sequences.
Tiny sequences are fast either way:
[steve@ando cpython]$ ./python -m timeit &quo
Steven D'Aprano added the comment:
I agree with both Eric and Zachary, but I just wanted to point out that in a
Python interpreter with a keyhole optimizer, you can expect that expressions
like `1*10**9` to be a constant:
# Python 3.5
py> from dis import dis
py> dis(
Steven D'Aprano added the comment:
> would it not be better to for dis.dis to behave consistently for methods and
> source strings of methods
I don't think so. The inputs are different. One is a string containing a `def`
statement, which is an executable statement. The oth
Steven D'Aprano added the comment:
> Integers are implicitly converted to floats in operations with floats.
> How can this change break old code?
# Status quo
print(1e60 + 1)
=> prints 1e+60
# In the future:
=> prints 10
New submission from Steven D'Aprano :
Function objects are mutable, so I expected that a copy of a function should be
an actual independent copy. But it isn't.
py> from copy import copy
py> a = lambda: 1
py> b = copy(a)
py> a is b
True
This burned
Steven D'Aprano added the comment:
> BTW how else are methods/functions are created in Python except via def?
Functions are objects like everything else in Python, so they have a
type, which has a constructor:
from types import FunctionType
The documentation for FunctionType
Steven D'Aprano added the comment:
I think this is sufficient for a shallow copy.
import copy
import types
def copyfunction(func):
new = types.FunctionType(
func.__code__,
func.__globals__,
func.__name__,
func.__defaults__,
Steven D'Aprano added the comment:
Ah, I see now. I was using an older version of Python and the output of
dis was different. It didn't recurse in to show the disassembly of the
code object as well.
> The first block of instructions here are for the def statement, and
>
Change by Steven Hilton :
--
nosy: +Steven Hilton
nosy_count: 5.0 -> 6.0
pull_requests: +18121
pull_request: https://github.com/python/cpython/pull/18687
___
Python tracker
<https://bugs.python.org/issu
Steven D'Aprano added the comment:
This is a numpy issue, you will need to report it to the numpy developers. But
first you need to check that it really is a bug. What makes you think it is a
bug? In your example, index 3 looks out of bounds to me. Remember that indexes
start at 0,
Change by Steven D'Aprano :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
Steven D'Aprano added the comment:
What does it mean for two Bytecode objects to be equal?
I know what equality means for ints: they have the same numeric value.
I know what equality means for strings: they have the same sequence of Unicode
code points.
I have no concept of what it
Change by Steven D'Aprano :
--
resolution: -> third party
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
Steven D'Aprano added the comment:
To be clear, are you only making a copy of the unchanged object if it is a
mutable bytearray, not str or bytes?
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
That's not a bug. The in-place addition `+=` for lists is equivalent to the
extend method. See the documentation:
https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types
and the tutorial:
https://docs.python.org/
Steven D'Aprano added the comment:
Code churn for no good reason is not a good idea. I cannot think of any good
reasons to change this:
- it doesn't add new functionality;
- it doesn't fix bugs;
- it doesn't make the code easier to maintain;
- it makes the code LESS c
Steven D'Aprano added the comment:
I don't know... To my mind, if we are going to support working with primes, the
minimum API is:
- is_prime(n)
- next_prime(n)
- prev_prime(n)
- factorise(n)
- generate_primes(start=0)
(I trust the names are self-explanatory.)
There are var
Steven D'Aprano added the comment:
Ross:
"implement this logic for a limited range of non-negative n, imposing an upper
limit (suggestions welcome) to make sure all provided input can be safely
processed. We can then build from there to support larger n going forward if
the dem
Steven D'Aprano added the comment:
On Sat, Mar 21, 2020 at 01:30:13PM +, Julin wrote:
> Why do you think it makes the code less clear, though?
Classes that inherit from object, and those which don't ("classic
classes") behave differently in Python 2. But in Python
Steven D'Aprano added the comment:
Perhaps this is just my old eyes, but I can't see where the turtle is going
backwards. I can see it spinning, but it's not clear that the turtle position
is moving backwards or if it is an illusion caused by the turtle spinning
around.
I
Steven D'Aprano added the comment:
Try changing the turtle to the arrow pointer and see if you can still see
backwards movement.
james.shape('arrow')
--
___
Python tracker
<https://bugs.pyt
Change by Steven D'Aprano :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
Steven D'Aprano added the comment:
> the program is supposed to draw a function like y=sin(x) but is drawing
> y=abs(sin(x)).
It would have been nice if you had described the problem this way from your
initial bug report, instead of saying that the turtle was moving backwards. I
Steven D'Aprano added the comment:
How about this?
"The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are
special. Not-a-number values always compare unordered and unequal to any other
value, including themselves. For example, if ``x =
Steven D'Aprano added the comment:
Oops, that should be
... ``x == x``, ``3 < x``, and ``x > 3`` are all false ...
--
___
Python tracker
<https://bugs.python.
Steven D'Aprano added the comment:
Oh never mind, I'm just going to slink away now and stop posting corrections
when distracted...
--
___
Python tracker
<https://bugs.python.o
Steven D'Aprano added the comment:
I think you may have misread the documentation. It says:
"an OS-level handle to an open file"
which is what you call a file descriptor. Not a file object, which is what you
get by calling the builtin `open`, but a file handle like you g
Steven D'Aprano added the comment:
I think the error messages could be improved.
In the first example: `f,x, a, b = [1,2,3]`
you are unpacking three values, but you need to unpack 4. The error message is
not very helpful: 5 values is "more than 3" but it would be too many
Steven D'Aprano added the comment:
Rémi, it is not true that the Decimal module won't lose precision. It will.
Decimal is not exact either, it is still a floating point format similar to
float.
py> Decimal(1)/3*3
Decimal('0.')
The two majo
New submission from Steven Lu :
I hope to be able to set blocking or unblocking in `tty.setraw` so that I won't
need to mess with `termios` in every of my python codes using an unblocking raw
mode. I will personally find it useful in the situation where I want a mainloop
that cont
Steven D'Aprano added the comment:
> Since the original report was about 2.7 which is no longer maintained,
> I propose to close this issue as outdated.
For what it's worth, I'm okay with closing.
--
___
Python tracker
<
Steven D'Aprano added the comment:
This feature is already provided by just supplying a `__missing__` dunder:
py> class MyDict(dict):
... def __missing__(self, key):
... return "The key is {}".format(key)
...
py> d = MyDict()
py> d[1234]
'The ke
Steven D'Aprano added the comment:
Would we be willing to consider an enhancement to have complex numbers always
display using float format rather than ints?
1+1j --> 1.0+1.0j
We could still suppress an unsigned real zero:
1j --> 1.0j
but negative zero would show
Steven D'Aprano added the comment:
Have you tried calling multiline_output() in the REPL?
It does *not* show your expected output:
# expected
First line
Second line
but the string repr():
# actual
'First line\nSecond line\n'
Change your do
Steven D'Aprano added the comment:
By the way Filip, you were told on the Stackoverflow page that the output was
correct and that you were not using doctest correctly. Serhiy also hinted to
you that you should check the output in the REPL and you falsely claimed that
it gave the exp
Steven D'Aprano added the comment:
This is a new feature and cannot be added to older versions which are in
feature-freeze.
Adding the feature to (say) Python 2.7.18 would be inconsistent, because it
wouldn't exist in 2.7.0 through .17. Likewise for all the other versions b
Steven D'Aprano added the comment:
Sorry Massimo, there are no new features being added to 2.7, not even
critical security fixes. That's not my decision.
https://www.python.org/doc/sunset-python-2/
Python 2 is effectively now a dead project from the point of view of us
here at CP
Steven D'Aprano added the comment:
https://docs.python.org/3/reference/expressions.html#membership-test-operations
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
I don't think this is needed in the builtin zip at all. I think that there is
no consensus on Python-Ideas that this is needed or desirable.
I especially don't think the API should be a keyword flag on zip. Flag
arguments which change t
Steven D'Aprano added the comment:
> independent class
Oops, sorry I mean independent implementation.
--
___
Python tracker
<https://bugs.python.org
New submission from Steven Fleck :
I'm having some issues with installing python 3.8.2. I'm installing it in my
personal workspace on my university's computing resources (linux). I've
installed many programs here, but python is giving me some issues.
Ultimately,
Steven D'Aprano added the comment:
What you are describing is not what we mean by a crash (a core dump or
segfault); it sounds like a regular Python exception.
Python 3.5 is obsolete and there are no more bug fixes for it except for
security fixes.
You have not given us enough inform
Steven D'Aprano added the comment:
Take your pick between either of these:
random.randrange(1, N)
random.randint(1, N-1)
https://docs.python.org/3/library/random.html#functions-for-integers
--
___
Python tracker
<https://bugs.py
Steven D'Aprano added the comment:
Hi,
The behaviour you are calling "gibbrish" is correct, as the expression
`(p-1)/2` calculates a 64-bit floating point number, which may lose
precision even for small values of p, but will definitely lose precision
for large p.
Calling
Steven D'Aprano added the comment:
Miller-Rabin is known to be deterministic for all N < 2**64 too.
To be pedantic, M-R is known to be deterministic if you check every
value up to sqrt(N), or possibly 2*log(N) if the generalized Riemann
hypothesis is true. The question is whether th
Steven D'Aprano added the comment:
Speaking of OpenSSL, a few years ago this paper came out about OpenSSL's
vulnerability to adversarial composites. Quote:
"As examples of our findings, weare able to construct 2048-bit
composites that are declared prime with probability 1
Steven D'Aprano added the comment:
What reason do you have to think that this is a Python issue rather than a
permissions error?
Since you haven't told us what permissions the file has, what OS you are using,
who set the permissions, or even the actual error message, it is imp
Steven D'Aprano added the comment:
Python is a case-sensitive language. Why would case-insensitive completions be
useful?
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
This is a new feature, so it would have to go into 3.9, all older versions are
in feature-freeze.
--
versions: -Python 3.5, Python 3.6, Python 3.7, Python 3.8
___
Python tracker
<https://bugs.py
Steven D'Aprano added the comment:
You have given no justification for removing item access for the fields except
"some users are still relying on ... access by item position and length".
Normally the fact that some people are doing this would be reason to reject
Steven D'Aprano added the comment:
Please re-upload the patch file as an uncompressed text file, as it is quite
difficult for many people to view zip files in their browser.
--
nosy: +steven.daprano
title: slice does not slice -> slice not
Change by Steven D'Aprano :
--
components: +Interpreter Core -ctypes
type: behavior -> enhancement
___
Python tracker
<https://bugs.python.org
Steven D'Aprano added the comment:
*blink*
How did I miss this entire thing? Where was the code review?
Thanks Tal for shepherding this through, and thanks Tzanetos for caring
about the unit tests.
--
___
Python tracker
<https://bugs.py
Steven D'Aprano added the comment:
> Perhaps you missed it because you're not in the CODEOWNERS so don't
> automatically get notified by GitHub?
That's quite possible. I can't fix that as Github considers everything
to do with my computer and browser too old.
Steven D'Aprano added the comment:
Hi Jacob, and welcome.
You said: "I was experimenting with nested dictionaries when I came across
strange behavior that I can not figure out at all."
This is a bug tracker, for reporting bugs, not a help desk for asking how to
figu
Steven D'Aprano added the comment:
This would be a change of behaviour, and 3.8 and 3.9 are in feature freeze, so
we could only add it in 3.10.
You say:
"it's supposed to capture the output without holding references to real things"
Is this requirement documented some
Steven D'Aprano added the comment:
Re-adding older versions.
--
versions: +Python 3.8, Python 3.9
___
Python tracker
<https://bugs.python.org/is
Steven D'Aprano added the comment:
The ^ operator is bitwise-xor (exclusive-or), not exponentiation.
Stop wasting our time by posting false bug reports. This is now your fifth
incorrect bug report in a row. Once or twice can be forgiven that you didn't
know better.
Please stop
Steven D'Aprano added the comment:
Nishant Gautam does not understand not condition.
This is your sixth incorrect bug report in a row. Please stop. This is not a
help desk to correct your mistakes.
a == 10 and (b != (not(11))) and b == a
--> True and (b != False) and True
--> Tr
Steven D'Aprano added the comment:
Hi Sébastien,
This is a bug tracker for reporting bugs, not a help desk to help with your
code. There are many community resources to help you debug your code, but this
is not one of them. You can try:
* Reddit's /r/learnpython
* the Python-li
Steven D'Aprano added the comment:
As a new feature, this could only go into 3.10, 3.9 is in feature freeze.
The requirements are unclear, it could mean any of:
- the file's *owner* has the execute bit set;
- the file's mode has any execute bit set;
- the *current us
Steven D'Aprano added the comment:
This would be a classic example of the "Flag argument" anti-pattern:
https://www.martinfowler.com/bliki/FlagArgument.html
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.pyt
Steven D'Aprano added the comment:
Code is working correctly, not a bug. Perhaps you are mistaking `continue` for
`break`.
Kshitish, we keep telling you not to use the bug tracker as a help desk. This
is now your eighth "bug report" that was 100% your misunderstanding. There
Steven D'Aprano added the comment:
The class you have provided is awkward to use, random access is inefficient, it
is not compatible with lists or offer a sequence API, it's not subscriptable or
iterable, the API exposes an unnecessary "Proxy" class, and the API is mor
Steven D'Aprano added the comment:
"Maybe a helpful tip can be added to the error message."
What sort of helpful tip do you have in mind?
Remember that the error doesn't occur when the file is opened, but some time
later.
--
n
Steven D'Aprano added the comment:
You are comparing the name with the file extension against the name without the
file extension:
>>> "Файл на български.ldr" == "Файл на български"
False
--
nosy: +steven.daprano
Steven D'Aprano added the comment:
In addition, you are probably hitting normalization issues. There are two ways
to get the Cyrillic character 'й' in your string, one of them is a single code
point, the other is two code points:
>>> a = 'й'
>>>
Steven D'Aprano added the comment:
The position of the caret assumes that every character in the string takes up
the same width, measured in pixels. That is only true for monospaced fonts like
Courier.
The only way to position the caret precisely with a proportional-width font i
Steven D'Aprano added the comment:
> @ Steven, did you mean to un-nosy Pratik?
No. I have tried to re-add him, but I think that because his user name
is all digits, the bug tracker won't accept it.
When I try, I get this error:
Edit Error: user has no
Steven D'Aprano added the comment:
Shouldn't this be discussed on Python-Ideas? I'm pretty sure this is a big
enough change that it will need a PEP.
If you need code run on startup, can't you just put it in the PYTHONSTARTUP
file?
--
n
Steven D'Aprano added the comment:
Hello valeriymartsyshyn,
This is for reporting bugs in the Python interpreter, it is not a help desk for
learning how to program in Python. There are many places you can ask for help
to debug your code, such as Reddit's r/learnpython, or Stackov
Steven D'Aprano added the comment:
> Additionally, it suffers from the same issue as
> sitecustomize. It is a single file that won't be a real substitute for
> code execution in pth files.
I thought that the consensus in b.p.o. #33944 is that code execution in
pth files
Steven D'Aprano added the comment:
> There is also the os.system() function which exposes the libc system()
> function. Should we deprecate this one as well?
Please don't deprecate os.system. For quick and dirty scripts used in trusted
environments with trusted data, it
Steven D'Aprano added the comment:
I strongly oppose this change, and I dispute the characterisation of
this as a misleading note. It is not misleading, and I argue that every
word of it is factually correct. Jake, if you disagree, then please
provide some citations.
Irit: it is ridic
Steven D'Aprano added the comment:
I'm pretty sure this is not a bug, but is working as designed.
The interpreter normalises unicode identifiers, but key lookup in the dict does
not.
Sorry, I don't have time right now to give a more detailed answer, but there
are two distinc
Steven D'Aprano added the comment:
I'm willing to give Irit and Jake opportunity to make their case.
Particularly if they can demonstrate that I got my facts wrong.
I'm going to close the ticket, but if anyone feels strongly enough to
respond with a good argument, or better
Change by Steven D'Aprano :
--
resolution: -> rejected
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
Steven D'Aprano added the comment:
Sorry Raymond, I missed this before closing the task.
> FWIW, Allen Downey also had concerns about this wording.
I don't recognise the name, who is Allen Downey and what concerns does
he have?
--
_
Steven D'Aprano added the comment:
As far as I can tell, every one of those are already available in Python.
https://docs.python.org/3/library/math.html
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.python.org/is
Steven Geerts added the comment:
still an issue with Python 3.8 and 3.9.
A copy between 2 files on webdave mapped drives can't be done, although src and
dst are different.
--
nosy: +steven.geerts
versions: +Python 3.8, Python 3.9
___
P
Steven D'Aprano added the comment:
By the way, it is almost always wrong to write "k for k in iterable" when you
can just write "iterable" or "list(iterable)".
Here are some micro-benchmarks:
[steve ~]$ python3.9 -m timeit -s "from string im
Steven D'Aprano added the comment:
It is probably harmless to enable the option, especially if it will be
the SQLite default, but why would you do your maths computations in sql,
using the limited set of functions available, when you could do them in
Python, with a much larger s
Steven D'Aprano added the comment:
On Mon, Dec 21, 2020 at 09:11:48PM +, Samuel Marks wrote:
> There were only 12k occurrences, I'm sure I could manually go through that
> in an afternoon. Would you accept it then?
Assuming "an afternoon" is half a work d
Steven D'Aprano added the comment:
They don't do the same thing.
The dict comprehension requires a single key:value pair per loop. It
accumulates values into a single dict. Try this:
d = {}
for key, value in items:
print(id(d))
d[key] = value
The ID does
Steven D'Aprano added the comment:
I like the addition but I'm not sure why you removed the price-earnings ratio
example from the docs. I think that it's useful to have an example that shows
that harmonic mean is not *just* for speed-related problems.
I'm not going t
Steven D'Aprano added the comment:
Okay, I'm satisfied with that reasoning, thanks Raymond.
Patch looks good to me. Go for it!
Have a good Christmas and stay safe.
--
___
Python tracker
<https://bugs.python.o
Steven D'Aprano added the comment:
You say:
> after process python3 test_case.py
> json file's content like this
>
> @@{"how_dare_you": "how_dare_you"}
I cannot replicate that result.
I created a "data.json" with the followi
Steven D'Aprano added the comment:
On Fri, Dec 25, 2020 at 01:31:51PM +, 施文峰 wrote:
> first test have a problem,you didn’t use r+ mode
I did, I copied your `test()` function exactly, however I did make a
mistake. I tried again with this:
>>> with open(FILE_PATH, 'r
Steven D'Aprano added the comment:
On Sat, Dec 26, 2020 at 02:19:55AM +, Terry J. Reedy wrote:
> "Enhancements" (non-bugfix feature changes) can only be applied to
> future versions. However, you are asking for the reversion of an
> intentional feature change ma
Steven D'Aprano added the comment:
Are you the owner of imaplib2?
If so, you need to ensure that there are no licencing or copyright issues
preventing imaplib2 being transferred into the stdlib. That may (or may not)
require you to get agreement from any contributors to the library.
Steven D'Aprano added the comment:
Hi Richard,
> Also, using _asdict() seems strange as an exposed API, since it's an
> underscore method and users hence might not be inclined to use it.
I don't consider this a strong argument. Named tuple in general has to use a
Steven D'Aprano added the comment:
# True
data.find('a', 0)
That will return 0, not True.
# False
data.find('a', start=0)
And that will raise TypeError, not return False.
What exactly are you reporting here? I have read your bug report, and looked at
the screen
Steven D'Aprano added the comment:
What error are you getting?
Can you demonstrate the error without gmpy2, as that is a third-party library
and nothing to do with us.
--
nosy: +steven.daprano
___
Python tracker
<https://bugs.py
Steven D'Aprano added the comment:
I cannot replicate that. On my computer, I can compute pow(c, e) in
approximately two minutes using Python 3.9:
>>> from time import time
>>> t = time(); a = pow(c, e); time()-t
122.07566785812378
>>> math.log10(a)
50473
Change by Steven D'Aprano :
--
components: +Interpreter Core -C API
title: Pow compute can only available in python3.7 -> pow() of huge input does
not complete
versions: +Python 3.6, Python 3.9 -Python 3.7
___
Python tracker
Steven D'Aprano added the comment:
I think that -m is unacceptable as it will clash with Python's -m option.
I'm not convinced that this added complexity will provide enough benefit to
make it worth while. I can see myself spending an order of magnitude more time
trying to
New submission from Steven D'Aprano :
This function crashes on the following recursive list:
def length(x):
try:
return sum(length(i) for i in x)
except Exception:
return 1
a = [[1, 2, 3], [4, 5, 6]]
a.append(a)
length(a)
Crashes:
Fatal Python
Steven D'Aprano added the comment:
I am pretty sure this has been discussed and rejected on the Python-Ideas
mailing list before.
If not rejected, the idea didn't go very far. You may wish to search the
mailing list archives for previous discussions.
Either way, I think this
Steven D'Aprano added the comment:
See also discussion here: #17343
--
___
Python tracker
<https://bugs.python.org/issue42816>
___
___
Python-bugs-list m
601 - 700 of 1942 matches
Mail list logo