[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Mark Shannon


Mark Shannon  added the comment:

> How do we know `x` is falsey without calling `bool()` on it?

We don't, but in `if x: pass`, it doesn't matter.
Discounting side-effects in __bool__, the code does nothing regardless of the 
value of `x`.

--

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



[issue42634] Incorrect line number in bytecode for try-except-finally

2020-12-13 Thread Mark Shannon


New submission from Mark Shannon :

The following code, when traced, produces a spurious line event for line 5:

a, b, c = 1, 1, 1
try:
a = 3
except:
b = 5
finally:
c = 7
assert a == 3 and b == 1 and c == 7

Bug reported by Ned Batchelder 
https://gist.github.com/nedbat/6c5dedde9df8d2de13de8a6a39a5f112

--
assignee: Mark.Shannon
messages: 382958
nosy: Mark.Shannon, nedbat
priority: release blocker
severity: normal
stage: needs patch
status: open
title: Incorrect line number in bytecode for try-except-finally
type: behavior
versions: Python 3.10

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



[issue42615] Redundant jump instructions due to deleted unreachable bytecode blocks

2020-12-16 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset c71581c7a4192e6ba9a79eccc583aaadab300efa by Om G in branch 
'master':
bpo-42615: Delete redundant jump instructions that only bypass empty blocks 
(GH-23733)
https://github.com/python/cpython/commit/c71581c7a4192e6ba9a79eccc583aaadab300efa


--
nosy: +Mark.Shannon

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



[issue42246] Implement PEP 626 -- Precise line numbers for debugging

2020-12-16 Thread Mark Shannon


Mark Shannon  added the comment:

https://github.com/python/cpython/pull/23780 fixes the finally handling.
The if-break case was fixed by earlier changes.

--

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



[issue42990] Improve the C code for calling Python code: _PyEval_EvalCode()

2021-02-01 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 0332e569c12d3dc97171546c6dc10e42c27de34b by Mark Shannon in 
branch 'master':
bpo-42990: Further refactoring of PyEval_ functions. (GH-24368)
https://github.com/python/cpython/commit/0332e569c12d3dc97171546c6dc10e42c27de34b


--

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



[issue42990] Improve the C code for calling Python code: _PyEval_EvalCode()

2021-02-01 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

2021-01-26 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset dea5bf9d15999bfcc58095b157c0678d45b00bdd by Irit Katriel in 
branch 'master':
bpo-33387: update documentation for exception handling opcode changes (GH-24334)
https://github.com/python/cpython/commit/dea5bf9d15999bfcc58095b157c0678d45b00bdd


--

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



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67 by Victor Stinner in 
branch 'master':
bpo-42979: Enhance abstract.c assertions checking slot result (GH-24352)
https://github.com/python/cpython/commit/c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67


--
nosy: +Mark.Shannon

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



[issue43054] What does the existence of a struct in a header file imply about the C-API

2021-01-28 Thread Mark Shannon


New submission from Mark Shannon :

Given the lack of explicit documentation on this subject, and differing 
opinions among core developers, I though it would be good to discuss how the 
existence of a struct in a header file constrains the C-API.

Original PR provoking this discussion: 
https://github.com/python/cpython/pull/24298

Suppose a header file, e.g. funcobject.h, contains a struct, e.g. 
PyFunctionObject, to what extent is that struct part of the API?


If a struct is present in a header file, there are three options for what means 
in terms of the API (that make sense to me).

1. That the struct is not part of the API and may be freely changed or deleted.
2. That the struct is produced, or initialized, by an API function, which 
implies that existing fields will continue to exist, but they can be reorder or 
added to.
3. That the struct is consumed by an API function, which implies that the 
struct must keep its exact shape, only adding fields if flags are present in 
the pre-existing fields to indicate the use of the extension.

PyTypeObject is an example of (3).

We should be able to infer which of the above cases applies, if not explicitly 
documented, for any struct.

Using PyFunctionObject in funcobject.h as an example:

There is no API function or macro that directly produces or consumes the 
struct, which would imply case 1. But, the struct is documented as the struct 
for Python functions, and `PyFunction_Check()` exists, which strongly implies 
that the following code is OK:

if (PyFunction_Check(obj)) {  
PyFunctionObject *func = (PyFunctionObject *)obj;
...

which therefore implies that (2) applies.
(3) does not apply as there is no API that takes a PyFunctionObject struct as a 
parameter.

Similar logic can be applied to other parts of the API.


Rather than go through this tortuous analysis for all headers, it might be 
better to document which structs are part of the API.

--
messages: 385851
nosy: Mark.Shannon, gvanrossum, petr.viktorin, vstinner
priority: normal
severity: normal
status: open
title: What does the existence of a struct in a header file imply about the 
C-API

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-02-02 Thread Mark Shannon


Mark Shannon  added the comment:

Option 3 with what semantics exactly?

https://docs.python.org/3/reference/datamodel.html#object.__bool__ says that 
__bool__ should return True or False.


If we don't allow the optimizer the freedom to assume that __bool__ is 
self-consistent and has no side effects, then we need to define what happens 
for stuff like:

class FlipFlop:
def __init__(self):
self.val = random.choice((True, False))
def __bool__(self):
self.val = not self.val
return self.val

Saying that only the second test can be removed is hard to define in a way that 
we can reliably implement.
For example, it makes the simplification of `x = True and y` to `x = y` 
problematic.
We routinely remove any tests of `if True:` or `while True:`, but the removal 
of `if True:` and the simplification of `x = True and y` to `x = y` is 
basically the same thing in the CFG.

--

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-02-02 Thread Mark Shannon


Mark Shannon  added the comment:

It isn't a specific optimization at all, but the combination of several.
I will change the behavior to match what appears to be the consensus.

BUT, we need to define what the semantics should be. Otherwise implementing the 
compiler is just guesswork.


As for a definition of what is legal, the best I can come up with is:

"Repeated bool() checks of a value in short-circuiting expressions ('and' and 
'or') may be eliminated if the result can be deduced using boolean algebra."

--

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-02-02 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44338] Port LOAD_GLOBAL to adaptive interpreter

2021-06-14 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset eecbc7c3900a7f40d8498b151db543a202c72f74 by Mark Shannon in 
branch 'main':
bpo-44338: Port LOAD_GLOBAL to PEP 659 adaptive interpreter (GH-26638)
https://github.com/python/cpython/commit/eecbc7c3900a7f40d8498b151db543a202c72f74


--

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-14 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25306
pull_request: https://github.com/python/cpython/pull/26718

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



[issue44417] bytecode<>line number mapping and f_lasti seem wrong in 3.10.0b2

2021-06-14 Thread Mark Shannon


Mark Shannon  added the comment:

What does "seem wrong" mean?
What exactly is the problem?

--

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



[issue44283] Add jump table for certain safe match-case statements

2021-06-14 Thread Mark Shannon


Mark Shannon  added the comment:

This is going in the wrong direction.

Rather than add more complex instructions for use only by pattern matching, we 
need to simplify the individual operations and re-use existing instructions.
That way pattern matching can benefit from the general performance improvements 
that we are making.


If you are serious about improving the performance of pattern matching, you 
need to do the following in the compiler:
1. Generate a decision tree.
2. Improve that decision tree so that fewer decisions are required.
3. Generate bytecode from that tree that uses lower level operations.

E.g.

match x:
case [1]:
A
case [2]:
B

The initial decision tree looks like:

if is_sequence(x):
if len(x) == 1:
if x[0] == 1:
A
if is_sequence(x):
if len(x) == 1:
if x[0] == 2:
B

which can be improved to:

if is_sequence(x):
if len(x) == 1:
if x[0] == 1:
A
elif x[0] == 2:
B

For a sequence of integer constants, introducing the test `type(x) == int` at 
the start would allow you to convert the linear sequence of tests into a tree. 
Reducing `n` tests to `ln(n) + 1` tests.

--
nosy: +Mark.Shannon

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



[issue38211] clean up type_init()

2021-06-16 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset ab030d6f9d73e7f6c2213c2e308d1ceb04761485 by Sergey Fedoseev in 
branch 'main':
bpo-38211: Clean up type_init() (GH-16257)
https://github.com/python/cpython/commit/ab030d6f9d73e7f6c2213c2e308d1ceb04761485


--
nosy: +Mark.Shannon

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-16 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25344
pull_request: https://github.com/python/cpython/pull/26759

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



[issue44187] Implement infrastructure for quickening and specializing

2021-06-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 001eb520b5757294dc455c900d94b7b153de6cdd by Mark Shannon in 
branch 'main':
bpo-44187: Quickening infrastructure (GH-26264)
https://github.com/python/cpython/commit/001eb520b5757294dc455c900d94b7b153de6cdd


--

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



[issue44338] Port LOAD_GLOBAL to adaptive interpreter

2021-06-07 Thread Mark Shannon


New submission from Mark Shannon :

Port the implementation of LOAD_GLOBAL to the new adaptive interpreter

Once this and https://bugs.python.org/issue44337 are implemented we can remove 
the old opcache.

--
messages: 395272
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Port LOAD_GLOBAL to adaptive interpreter

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-07 Thread Mark Shannon


New submission from Mark Shannon :

Port the implementation of LOAD_ATTR to the new adaptive interpreter

--
messages: 395271
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Port LOAD_ATTR to adaptive interpreter

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



[issue44363] Likely false positive for address sanitizer after fork

2021-06-09 Thread Mark Shannon


New submission from Mark Shannon :

Running the buildbot for https://github.com/python/cpython/pull/26595
results in failures:
https://buildbot.python.org/all/#/builders/581/builds/63
Which claim that the address calculation in `LOAD_ATTR_MODULE` is out of bounds.

The tests pass with an added assert to verify that the address in question is 
in bounds. 

All failures seem to happen after a fork, which seems to be a longstanding 
weakness of the address sanitizer.

I'd like to merge https://github.com/python/cpython/pull/26595. I'd also like 
to keep the buildbots working. Dichotomy.

--
messages: 395403
nosy: Mark.Shannon, pablogsal
priority: normal
severity: normal
status: open
title: Likely false positive for address sanitizer after fork

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



[issue44348] test_exceptions.ExceptionTests.test_recursion_in_except_handler stack overflow on Windows debug builds

2021-06-09 Thread Mark Shannon


Change by Mark Shannon :


--
nosy: +Mark.Shannon
nosy_count: 9.0 -> 10.0
pull_requests: +25208
pull_request: https://github.com/python/cpython/pull/26623

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



[issue44206] Add a version number to dict keys.

2021-06-09 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44187] Implement infrastructure for quickening and specializing

2021-06-09 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25209
pull_request: https://github.com/python/cpython/pull/26624

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



[issue44363] Likely false positive for address sanitizer after fork

2021-06-09 Thread Mark Shannon


Mark Shannon  added the comment:

If I run the following on main
./configure --with-address-sanitizer
make clean
make -j12 test

I get 22 failures.

So something is broken.

test_lib2to3 does fork; at least it does when I run it under gdb.

--

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-09 Thread Mark Shannon


Mark Shannon  added the comment:

I still get quite a few failures on the main branch.
It seems like ceval.c:1600 upsets the sanitizer, at least for gcc.

There isn't anything wrong with that line, but as I plan to change it anyway I 
guess it doesn't matter:
https://github.com/python/cpython/pull/26595

I plan to get the main branch passing the tests with address sanitization (at 
least on my machine with my gcc :)

Running the tests doesn't seem to take that long (at least not compared with 
refleak tests).
Do you think it would be it feasible to run the address sanitizer on all PRs, 
so that we can keep it passing?

--
title: Likely false positive for address sanitizer after fork -> Address 
sanitizer (gcc version) is generating false positives

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-09 Thread Mark Shannon


Mark Shannon  added the comment:

This line seems to be responsible for most of the failures:
https://github.com/python/cpython/blob/main/Objects/frameobject.c#L985

Which does appear to be a true positive.

--

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



[issue44187] Implement infrastructure for quickening and specializing

2021-06-09 Thread Mark Shannon


Mark Shannon  added the comment:

No, this is done

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

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-09 Thread Mark Shannon


Mark Shannon  added the comment:

What commit are you running that on?

--

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



[issue44348] test_exceptions.ExceptionTests.test_recursion_in_except_handler stack overflow on Windows debug builds

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 54cb63863f19a7c64d9a3a5fd97bdfc0dd7ab374 by Mark Shannon in 
branch 'main':
bpo-44348: Move trace-info to thread-state (GH-26623)
https://github.com/python/cpython/commit/54cb63863f19a7c64d9a3a5fd97bdfc0dd7ab374


--

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset e117c0283705943189e6b1aef668a1f68f3f00a4 by Mark Shannon in 
branch 'main':
bpo-44337: Port LOAD_ATTR to PEP 659 adaptive interpreter (GH-26595)
https://github.com/python/cpython/commit/e117c0283705943189e6b1aef668a1f68f3f00a4


--

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



[issue44338] Port LOAD_GLOBAL to adaptive interpreter

2021-06-10 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:

It looks like I've been a bit unfair to the address sanitizer.

It does appear to produce incorrect locations sometimes, but that's not really 
a false positive and the reports are generally useful.

--

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



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:

Yes. Simpler is good.


I think it will also be better for performance:

In general, we don't know what X is in `from Y import X`. It could be a module 
or anything else.

However, if we are accessing an attribute it is quite likely to be a module or 
class.
For `X` defined by `from Y import X`, `X` is likely to be a module, class, 
function, or some sort of constant like a string, int or Enum.

If it is a string, int or function then it is rare to call a method on it, so 
we can ignore that case.
Calling methods on an Enum constant is probably not very common either (I'm 
guessing here)

For a module, `LOAD_ATTR; CALL_FUNCTION` is clearly better than `LOAD_METHOD; 
CALL_METHOD`.

For a class, specializing `LOAD_ATTR` is no more complex than `LOAD_METHOD`, 
probably simpler.
So, for a class `LOAD_ATTR; CALL_FUNCTION` is no worse than `LOAD_METHOD; 
CALL_METHOD`, and might be better.


Overall, it looks like `X.foo()` when `X` is defiend by `from Y import X` is 
best as `LOAD_ATTR; CALL_FUNCTION` not `LOAD_METHOD; CALL_METHOD`.

--

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-10 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44363] Address sanitizer (gcc version) is generating false positives

2021-06-10 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25226
pull_request: https://github.com/python/cpython/pull/26639

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



[issue44032] Function locals and evaluation stack should be stored in a contiguous, per-thread stack

2021-06-17 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25357
pull_request: https://github.com/python/cpython/pull/26771

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



[issue44442] Globals (and presumably builtins) are cleared premuturely in FrameObject

2021-06-17 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44442] Globals (and presumably builtins) are cleared premuturely in FrameObject

2021-06-17 Thread Mark Shannon


Mark Shannon  added the comment:

No problem, I've added a simple test.

--
stage: patch review -> 

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



[issue43693] Logically merge cell and locals array. They are already contiguous in memory

2021-06-17 Thread Mark Shannon


Change by Mark Shannon :


--
assignee: Mark.Shannon -> eric.snow

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



[issue44442] Globals (and presumably builtins) are cleared premuturely in FrameObject

2021-06-17 Thread Mark Shannon


New submission from Mark Shannon :

When calling frame.clear(), the globals (and builtins) are cleared.
This is not the case in 3.10. We should restore the 3.10 behavior, as there is 
no reason not to.


Victor, you've mentioned this problem. Did you have a specific example I can 
add as a test?

--
assignee: Mark.Shannon
messages: 395995
nosy: Mark.Shannon, vstinner
priority: normal
severity: normal
status: open
title: Globals (and presumably builtins) are cleared premuturely in FrameObject
type: behavior
versions: Python 3.11

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



[issue44442] Globals (and presumably builtins) are cleared premuturely in FrameObject

2021-06-17 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44297] Frame with -1 line number

2021-06-19 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44450] Generator expressions trace differently on Windows than on Mac

2021-06-19 Thread Mark Shannon


Mark Shannon  added the comment:

Ned, is this a regression (does 3.9 do the right thing on Windows) or an 
inconsistency between Mac and Windows?

I suspect this might have something to do with the PREDICT macros. If that the 
were the case 3.9 should show the same inconsistency between Windows and the 
Mac.

--
assignee:  -> Mark.Shannon

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



[issue44297] Frame with -1 line number

2021-06-19 Thread Mark Shannon


Mark Shannon  added the comment:

Thanks Anthony, that's a big help.

--

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



[issue44032] Function locals and evaluation stack should be stored in a contiguous, per-thread stack

2021-06-18 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 0982ded179f280176868c1c4eccf77bf70687816 by Mark Shannon in 
branch 'main':
bpo-44032: Move pointer to code object from frame-object to frame specials 
array. (GH-26771)
https://github.com/python/cpython/commit/0982ded179f280176868c1c4eccf77bf70687816


--

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



[issue44446] linecache.getline TypeError when formatting tracebacks in stacks containing an async list comprehension

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:

This appears to be a duplicate of https://bugs.python.org/issue44297

--

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



[issue44297] Frame with -1 line number

2021-06-21 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25402
pull_request: https://github.com/python/cpython/pull/26821

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



[issue44450] Generator expressions trace differently on Windows than on Mac

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:

Hmm, I'm a bit puzzled by that.

Did you test with 3.10b3 or the latest build from the 3.10 branch with the fix 
to https://bugs.python.org/issue44297 included?

--

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



[issue44450] Generator expressions trace differently on Windows than on Mac

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:

I think this is a combination of https://bugs.python.org/issue44297 and the 
PREDICT macros.

I don't have a  windows machine to confirm this on, but I suspect that if you 
rewrite `doit` as:

def doit():
o = ((1,2), (3,4))
o = (a for
 a in
 o)
for tup in o:
x = tup[0]
y = tup[1]

then you should be able to observe a difference between Windows and Mac on 3.9 
as well.

--

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset fb68791a26e157ed3cdeb409c8d8b6cddc7535bd by Mark Shannon in 
branch 'main':
bpo-44337: Improve LOAD_ATTR specialization (GH-26759)
https://github.com/python/cpython/commit/fb68791a26e157ed3cdeb409c8d8b6cddc7535bd


--

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



[issue44297] Frame with -1 line number

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 7674c83d81905d6afe989ca3f93f08b7939b057c by Mark Shannon in 
branch '3.10':
bpo-44297: Fix missing line number in generator expressions (GH-26821)
https://github.com/python/cpython/commit/7674c83d81905d6afe989ca3f93f08b7939b057c


--

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



[issue44446] linecache.getline TypeError when formatting tracebacks in stacks containing an async list comprehension

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:

With the latest 3.10, I get:

  File "/home/mark/test/test.py", line 13, in 
next(bar().__await__(), None)
  File "/home/mark/test/test.py", line 10, in bar
return [chunk async for chunk in foo()]
  File "/home/mark/test/test.py", line 10, in 
return [chunk async for chunk in foo()]
  File "/home/mark/test/test.py", line 6, in foo
traceback.print_stack()
working!


Thomas, can you confirm?

--

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



[issue44486] Modules should alway have a dictionary

2021-06-23 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset c3f52b4d707a78eb342372a2be00f3eb846a05b9 by Mark Shannon in 
branch 'main':
bpo-44486: Make sure that modules always have a dictionary. (GH-26847)
https://github.com/python/cpython/commit/c3f52b4d707a78eb342372a2be00f3eb846a05b9


--

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



[issue44500] Document changes to code object.

2021-06-23 Thread Mark Shannon


New submission from Mark Shannon :

We are making lots of changes to the code object.

We should clearly document all the changes in one place and explain the new 
design well before 3.11 beta.

--
assignee: docs@python
components: Documentation
messages: 396432
nosy: Mark.Shannon, docs@python, eric.snow, gvanrossum
priority: normal
severity: normal
status: open
title: Document changes to code object.
type: enhancement
versions: Python 3.11

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



[issue44486] Modules should alway have a dictionary

2021-06-23 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44297] Frame with -1 line number

2021-06-23 Thread Mark Shannon


Mark Shannon  added the comment:

Thanks for the reproducer.

--
assignee:  -> Mark.Shannon

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



[issue44486] Modules should alway have a dictionary

2021-06-22 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44486] Modules should alway have a dictionary

2021-06-22 Thread Mark Shannon


New submission from Mark Shannon :

It is possible to create a module without a dictionary:
m = types.ModuleType.__new__(types.ModuleType)

But that is the only way to create to a module without a dict; all other means 
of creating a module, both in Python and in the C API, result in a fully formed 
module.

Existing code expects that modules will always have a dictionary, e.g.
https://github.com/python/cpython/blob/3.10/Include/internal/pycore_moduleobject.h#L35

We should change types.ModuleType.__new__ to properly initialize the module.

--
assignee: Mark.Shannon
messages: 396316
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Modules should alway have a dictionary
type: behavior

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



[issue44297] Frame with -1 line number

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 82e5c28af7049c4f5343c808f172cbe2e145f49b by Mark Shannon in 
branch 'main':
bpo-44297: Fix missing line number in generator expressions (GH-26801)
https://github.com/python/cpython/commit/82e5c28af7049c4f5343c808f172cbe2e145f49b


--

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



[issue44337] Port LOAD_ATTR to adaptive interpreter

2021-06-08 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue43693] Logically merge cell and locals array. They are already contiguous in memory

2021-06-08 Thread Mark Shannon


Mark Shannon  added the comment:

Pablo,

Is there a bpo issue for the buildbot failures on Windows?
The failures I've been seeing are C stack overflows.

Long term, I expect to fix it by decoupling the C and Python stacks.
In the short term I have a couple of changes that might get it working again

--

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-13 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 0acdf255a51b836c0b44f3676797620322974af3 by Mark Shannon in 
branch '3.10':
[3.10] bpo-43933: Force RETURN_VALUE bytecodes to have line numbers (GH-26061)
https://github.com/python/cpython/commit/0acdf255a51b836c0b44f3676797620322974af3


--

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



[issue44088] traced line number can be None

2021-05-12 Thread Mark Shannon


Mark Shannon  added the comment:

Duplicate of https://bugs.python.org/issue43933

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed

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



[issue40222] "Zero cost" exception handling

2021-05-11 Thread Mark Shannon


Mark Shannon  added the comment:

I know PyCode_NewWithPosOnlyArgs is declared as "PyAPI_FUNC" but that can't 
make it part of the ABI unless it has stable behavior.
It can't have stable behavior because its inputs are complex, undefined, have 
altered semantics and are interlinked in complex ways.

Passing the same arguments to PyCode_NewWithPosOnlyArgs for both 3.9 and 3.10 
will cause one or other version to crash (interpreter crash, not just program 
crash).


We need to stop adding "PyAPI_FUNC" to everything.
Adding a PyAPI_FUNC does not magically make for ABI compatibility, there is a 
lot more to it than that.

The only sane ways to construct a code object are to load it from disk, to 
compile an AST, or to use
codeobject.replace(). Any purported ABI compatibility claims are just 
misleading and a trap.


I can revert the API changes and add a new function, but I think that is 
dangerously misleading. A compilation error is preferable to an interpreter 
crash.

--

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-12 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +24694
pull_request: https://github.com/python/cpython/pull/26054

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



[issue40222] "Zero cost" exception handling

2021-05-12 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +24699
pull_request: https://github.com/python/cpython/pull/26059

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-12 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +24702
pull_request: https://github.com/python/cpython/pull/26061

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-10 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue43760] The DISPATCH() macro is not as efficient as it could be.

2021-05-10 Thread Mark Shannon


Mark Shannon  added the comment:

At yappi/_yappi.c:1261 sets an undocumented field on a CPython internal data 
structure.

What did you believe that was supposed to do? use_tracing is not documented 
anywhere.

We could add the field back and ignore it, but I doubt that would help you much.

--

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-10 Thread Mark Shannon


Mark Shannon  added the comment:

If there is no C-API function that supports your needs, feel free to suggest 
one.

--

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



[issue43760] The DISPATCH() macro is not as efficient as it could be.

2021-05-10 Thread Mark Shannon


Mark Shannon  added the comment:

If there is no C-API function that supports your needs, feel free to suggest 
one.

--

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-05-10 Thread Mark Shannon


Mark Shannon  added the comment:

Ned, no line numbers should never be None.
(Except under very unusual circumstances, like the trace function raising an 
error)

Taking a look at the disassembly of execsitecustomize, there is a return with 
no line number, which shouldn't happen.

--

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



[issue40222] "Zero cost" exception handling

2021-05-10 Thread Mark Shannon


Mark Shannon  added the comment:

Thanks everyone for the triaging and fixing.

--

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



[issue43760] The DISPATCH() macro is not as efficient as it could be.

2021-05-10 Thread Mark Shannon


Mark Shannon  added the comment:

But what does "use it" mean?
What does setting `tstate->use_tracing = 1` do?
There is no documented behavior, so how do we know what assumptions people are 
making about what happens when they set some field to 1?

As I said, we could keep the field and ignore it, but that seems worse.

--

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



[issue44056] Incorrect line number for syntax error.

2021-05-07 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44056] Incorrect line number for syntax error.

2021-05-06 Thread Mark Shannon


Change by Mark Shannon :


--
keywords: +patch
pull_requests: +24606
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/25939

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



[issue44056] Incorrect line number for syntax error.

2021-05-06 Thread Mark Shannon


New submission from Mark Shannon :

Consider this function, which has a syntax error on line 4.

>>> def f():
... try: 
... 1/0
... except:
... pass
... except Exception: 
... pass

3.9 reports an incorrect line number of 3.
3.10b reports an even more incorrect line number of -1.

Although I've marked this as a "Parser" bug, the offending code is in the 
compiler.

For 3.11, this is fixed by https://github.com/python/cpython/pull/25729

--
assignee: Mark.Shannon
components: Parser
messages: 393083
nosy: Mark.Shannon, lys.nikolaou, pablogsal
priority: release blocker
severity: normal
stage: needs patch
status: open
title: Incorrect line number for syntax error.
type: behavior
versions: Python 3.10

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



[issue39394] re: DeprecationWarning for `flag not at the start of expression` is cutoff too early

2021-05-17 Thread Mark Shannon


Mark Shannon  added the comment:

I have to admit that I find the truncated version more readable.

Some sort of truncation is useful, as a regex could be thousands of character 
long.

Adding the offset to the warning message seems like a useful addition.

--
nosy: +Mark.Shannon

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



[issue40222] "Zero cost" exception handling

2021-05-11 Thread Mark Shannon


Mark Shannon  added the comment:

It is very little effort to add back the old function, so that isn't the 
problem. It won't work properly, but it never did anyway. So I guess that's 
sort of compatible.

Maybe the best thing is to put a big red warning in the docs and hope that 
warns away people from using it?

--

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



[issue44032] Function locals and evaluation stack should be stored in a contiguous, per-thread stack

2021-05-12 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44187] Implement infrastructure for quickening and specializing

2021-05-20 Thread Mark Shannon


Change by Mark Shannon :


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

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



[issue44187] Implement infrastructure for quickening and specializing

2021-05-20 Thread Mark Shannon


New submission from Mark Shannon :

As described in PEP 659 (Specializing Adaptive Interpreter) the first part of 
implementing specialization is to implement the machinery to do the quickening.

Conceptually, this is fairly simple: add a new field to the code object, which 
points to the first instruction in the bytecode.

When quickening, we create a new array, copy the old bytecode into it, and make 
the new field point to it.

Without any specialization or superinstructions, this will just waste memory.
However, it will pay off soon enough as we implement superinstructions, remove 
the old "opcache" and add new specializations.

We expect to see worthwhile speed ups with just superinstructions, and large 
speedups when all the above features have been implemented.

--
assignee: Mark.Shannon
messages: 394013
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Implement infrastructure for quickening and specializing
type: performance

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



[issue40222] "Zero cost" exception handling

2021-05-10 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +24671
pull_request: https://github.com/python/cpython/pull/26021

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



[issue44240] Incorrect behavior of LOAD_ATTR due to overflow in tp_version

2021-05-26 Thread Mark Shannon


Mark Shannon  added the comment:

It is extremely unlikely, I agree. But not impossible.

I plan to fix it for 3.11. Once I've done that we can decide if backports are 
worth it.

--

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



[issue43693] Logically merge cell and locals array. They are already contiguous in memory

2021-05-26 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 6cc800d3634fdd002b986c3ffe6a3d5540f311a0 by Eric Snow in branch 
'main':
bpo-43693: Clean up the PyCodeObject fields. (GH-26364)
https://github.com/python/cpython/commit/6cc800d3634fdd002b986c3ffe6a3d5540f311a0


--

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



[issue44240] Incorrect behavior of LOAD_ATTR due to overflow in tp_version

2021-05-26 Thread Mark Shannon


New submission from Mark Shannon :

Should the tp_version overflow, and wrap around to a value previously used in 
the opcache for LOAD_ATTR, then LOAD_ATTR could produce the wrong value.

It will take a fair bit of contrivance and a long time to do this, but it is 
possible:
Run some code ~2000 times to get the version cached.
Change an attibute of the type about 4 billion times.
Rerun the original code.



Invalidating all the opcaches is going to be a huge pain, so I propose not 
allowing the version to overflow but partitioning the 32 bit space something 
like this:

Top 20 bits: Unique per-class ID, 0 and 0xF are reserved.
Low 12 bits: Per-class version.

tp_version == 0 that no version has been assigned to this class, as yet.
(tp_version & 0xFFF) == 0 means that the version tag is temporarily invalid
tp_version == 0x means that the version tag is permanently invalid

If (tp_version & 0xFFF) != 0 and tp_version != 0x, then the combined 32 
bits represents a unique tag of the class's state as it does now.

Should the low bits of a class hit 0xFFF then all 32 bits are set to 
0x, and we can't cache its version any more.
If a class has been changed a 1000 times, then there is unlikely to be much 
value in caching it anyway.

--
components: Interpreter Core
messages: 394442
nosy: Mark.Shannon, pablogsal
priority: normal
severity: normal
stage: needs patch
status: open
title: Incorrect behavior of LOAD_ATTR  due to overflow in tp_version
type: behavior
versions: Python 3.10, Python 3.9

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



[issue44206] Add a version number to dict keys.

2021-05-25 Thread Mark Shannon


Mark Shannon  added the comment:

Which optimizations?

LOAD_GLOBAL:
Using a keys version instead of a whole dict version means that LOAD_GLOBAL 
won't leak references. It also means that we can (in the future) remove the PEP 
509 version and save 8 bytes per dict.

LOAD_ATTR:
_PyDict_GetItemHint() still has to do quite a lot of work compared to a version 
check.
The hint approach can't quickly tell us whether a name is not in a dictionary, 
which is needed for optimizing non-descriptor class attributes.

LOAD_METHOD:
Because functions are non-overriding descriptors we need to quickly check that 
the instance does not have an attribute shadowing the method.


Why is 32 bits enough?

Because the version is reset to zero, whenever the dict keys changes, and only 
set to non-zero when we explicitly ask for it when optimizing. 4 billion 
optimization events is a lot.
It can't overflow, it just becomes useless when we reach UINT_MAX.
Using 64 bits would just waste memory.


Overall, versioning the dictionary's keys is more useful and more compact than 
versioning the dictionary as a whole.

--

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



[issue44206] Add a version number to dict keys.

2021-05-21 Thread Mark Shannon


New submission from Mark Shannon :

Add a version number to dict keys.

PEP 509 added a version number to dicts. Unfortunately this is no use for 
optimizing attribute loads and store on instances.
We need to know whether the keys are as expected, not the dict as that is 
likely to be different each time.

We can add a 32 bit version number and actually reduce memory use by taking 
advantage of the redundancy in the rest of the keys object.

--
assignee: Mark.Shannon
messages: 394120
nosy: Mark.Shannon, methane, vstinner
priority: normal
severity: normal
stage: needs patch
status: open
title: Add a version number to dict keys.
type: performance

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



[issue44032] Function locals and evaluation stack should be stored in a contiguous, per-thread stack

2021-05-21 Thread Mark Shannon


Mark Shannon  added the comment:

What's the test case, exactly?

ref.py for the other issue doesn't crash if I change "func.py" to "ref.py"
otherwise it just complains that "func.py" doesn't exist.

--

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



[issue44207] Add a version number to Python functions

2021-05-21 Thread Mark Shannon


New submission from Mark Shannon :

In order to specialize calls to Python functions, or to inline them, we need to 
know that the code object has not changed. It is also useful to know that the 
globals, builtins and various defaults haven't changed either. Rather than 
attempting to check these individually it is much simpler and faster to check a 
version number.

--
assignee: Mark.Shannon
messages: 394124
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Add a version number to Python functions
type: performance

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



[issue44032] Function locals and evaluation stack should be stored in a contiguous, per-thread stack

2021-05-21 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +24891
pull_request: https://github.com/python/cpython/pull/26285

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



[issue44206] Add a version number to dict keys.

2021-05-28 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset f8a95df84bcedebc0aa7132b3d1a4e8f000914bc by Mark Shannon in 
branch 'main':
bpo-44206: Add a version number to dictionary keys (GH-26333)
https://github.com/python/cpython/commit/f8a95df84bcedebc0aa7132b3d1a4e8f000914bc


--

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



[issue42349] Compiler front-end produces a broken CFG

2021-06-07 Thread Mark Shannon


Mark Shannon  added the comment:

Basic blocks have only a single exit, at the end.
https://en.wikipedia.org/wiki/Basic_block

If the devguide says otherwise it is wrong.

--

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



[issue44298] 3.10.0b2 traces with-exit before the break that caused the exit

2021-06-03 Thread Mark Shannon


Mark Shannon  added the comment:

For context, this behavior was introduced in https://bugs.python.org/issue43933

--

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



[issue44298] 3.10.0b2 traces with-exit before the break that caused the exit

2021-06-03 Thread Mark Shannon


Change by Mark Shannon :


--
keywords: +patch
pull_requests: +25109
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/26513

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



[issue44298] 3.10.0b2 traces with-exit before the break that caused the exit

2021-06-03 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 937cebc93b4922583218e0cbf0a9a14705a595b2 by Mark Shannon in 
branch 'main':
bpo-44298: Fix line numbers for early exits in with statements. (GH-26513)
https://github.com/python/cpython/commit/937cebc93b4922583218e0cbf0a9a14705a595b2


--

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



[issue44298] 3.10.0b2 traces with-exit before the break that caused the exit

2021-06-03 Thread Mark Shannon


Mark Shannon  added the comment:

Why this occurs:

with cm: 
A
break

translates to something like:

ex = cm.__exit__; cm.__enter__()  # with cm
A
ex(...)
goto loop_end   # break

So, the break is traced after the exit call.

However, this doesn't seem consistent with try-finally statements which trace 
any break/continue/return before the finally block.

--
keywords: +3.10regression
nosy: +pablogsal
priority: normal -> release blocker
stage:  -> needs patch

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



[issue44298] 3.10.0b2 traces with-exit before the break that caused the exit

2021-06-03 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25111
pull_request: https://github.com/python/cpython/pull/26516

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



<    1   2   3   4   5   6   7   8   9   10   >