Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3a7f8df
initial attempt
sweeneyde Apr 17, 2022
3b5ce1e
bump magic
sweeneyde Apr 17, 2022
b21b5f4
Merge remote-tracking branch 'upstream/main' into special_for_iter2
sweeneyde Apr 18, 2022
37269cf
NOTRACE_DISPATCH_SAME_OPARG
sweeneyde Apr 18, 2022
ea0a7ee
Update mark_stacks
sweeneyde Apr 18, 2022
0751228
comment out assertions
sweeneyde Apr 19, 2022
dc80fda
Merge branch 'main' into special_for_iter2
sweeneyde Apr 19, 2022
e429410
Make FOR_ITER_RANGE mutate the local
sweeneyde Apr 19, 2022
1cb2de7
Merge remote-tracking branch 'upstream/main' into special_for_iter2
sweeneyde Apr 19, 2022
73fa01c
Fix overflow
sweeneyde Apr 19, 2022
4213582
fix test
sweeneyde Apr 19, 2022
bf58358
fix dis
sweeneyde Apr 19, 2022
bd7575e
Add more tests, add more casts
sweeneyde Apr 19, 2022
db8754b
Merge branch 'main' into special_for_iter2
sweeneyde Apr 20, 2022
2050c4e
merge with main
sweeneyde Apr 24, 2022
824e966
Fix stats, take out some PREDICT
sweeneyde Apr 24, 2022
6b16772
📜🤖 Added by blurb_it.
blurb-it[bot] Apr 24, 2022
c2a75a5
merge with main
sweeneyde Apr 28, 2022
6696384
remove PREDEICTED(STORE_FAST)
sweeneyde Apr 28, 2022
d297091
assert no tracing
sweeneyde Apr 28, 2022
22635a6
Merge branch 'special_for_iter2' of https://github.com/sweeneyde/cpyt…
sweeneyde Apr 28, 2022
f360d65
remove unnecessary cast
sweeneyde Apr 28, 2022
81e0500
merge with main
sweeneyde May 3, 2022
c2eab68
regen
sweeneyde May 3, 2022
25689c3
merge and bump magic
sweeneyde May 4, 2022
b5df047
merge with main
sweeneyde May 8, 2022
2b1c170
Merge remote-tracking branch 'upstream/main' into special_for_iter2
sweeneyde May 10, 2022
91d280c
Fix test_dis
sweeneyde May 10, 2022
eba5e60
merge with main
sweeneyde May 12, 2022
5b153d7
Merge branch 'main' into special_for_iter2
sweeneyde May 12, 2022
76f9a74
merge with main
sweeneyde May 20, 2022
0565a68
Merge branch 'special_for_iter2' of https://github.com/sweeneyde/cpyt…
sweeneyde May 20, 2022
9ba5b79
merge with main
sweeneyde Jun 9, 2022
6cdf0e4
Add comment about re-using the old PyLongObject
sweeneyde Jun 9, 2022
03dde6a
Merge branch 'main' of https://github.com/python/cpython into special…
sweeneyde Jun 10, 2022
f1e2d39
update test_dis.py
sweeneyde Jun 10, 2022
463c3b9
Merge remote-tracking branch 'upstream/main' into special_for_iter2
sweeneyde Jun 14, 2022
ed29777
use the new exponential backoff
sweeneyde Jun 14, 2022
188b357
merge with main
sweeneyde Jun 18, 2022
36d0999
revert using sdigits, add _PyLong_AssignValue
sweeneyde Jun 19, 2022
ad2e969
revert test_sys sizeof check
sweeneyde Jun 19, 2022
d55868f
revert test_range changes
sweeneyde Jun 19, 2022
2d6ee26
add comment and use Py_ssize_t
sweeneyde Jun 20, 2022
db21da1
Add comment: only positive
sweeneyde Jun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add comment and use Py_ssize_t
  • Loading branch information
sweeneyde committed Jun 20, 2022
commit 2d6ee26f9528c459e1a228a337c7be45f44f8775
2 changes: 1 addition & 1 deletion Include/internal/pycore_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ PyObject *_PyLong_Add(PyLongObject *left, PyLongObject *right);
PyObject *_PyLong_Multiply(PyLongObject *left, PyLongObject *right);
PyObject *_PyLong_Subtract(PyLongObject *left, PyLongObject *right);

int _PyLong_AssignValue(PyObject **target, long value);
int _PyLong_AssignValue(PyObject **target, Py_ssize_t value);

/* Used by Python/mystrtoul.c, _PyBytes_FromHex(),
_PyBytes_DecodeEscape(), etc. */
Expand Down
10 changes: 5 additions & 5 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,26 @@ _PyLong_FromSTwoDigits(stwodigits x)
}

int
_PyLong_AssignValue(PyObject **target, long value)
_PyLong_AssignValue(PyObject **target, Py_ssize_t value)
{
PyObject *old = *target;
if (IS_SMALL_INT(value)) {
*target = get_small_int(Py_SAFE_DOWNCAST(value, long, sdigit));
*target = get_small_int(Py_SAFE_DOWNCAST(value, Py_ssize_t, sdigit));
Py_XDECREF(old);
return 0;
}
else if (old != NULL && PyLong_CheckExact(old) &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works for positive integers.
Given that it is only used for range iteration, that's fine for now.
But could you add a comment, so it doesn't get overlooked when we implement faster-cpython/ideas#147

Py_REFCNT(old) == 1 && Py_SIZE(old) == 1 &&
(unsigned long)value <= PyLong_MASK)
(size_t)value <= PyLong_MASK)
{
// Mutate in place if there are no other references to the old object.
// This avoids an allocation in a common case.
((PyLongObject *)old)->ob_digit[0]
= Py_SAFE_DOWNCAST(value, long, digit);
= Py_SAFE_DOWNCAST(value, Py_ssize_t, digit);
return 0;
}
else {
*target = PyLong_FromLong(value);
*target = PyLong_FromSsize_t(value);
Py_XDECREF(old);
if (*target == NULL) {
return -1;
Expand Down
1 change: 1 addition & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4510,6 +4510,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
if (_PyLong_AssignValue(&GETLOCAL(_Py_OPARG(next)), value) < 0) {
goto error;
}
// The STORE_FAST is already done.
JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + 1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explaining why this is INLINE_CACHE_ENTRIES_FOR_ITER + 1 rather than just INLINE_CACHE_ENTRIES_FOR_ITER.

NOTRACE_DISPATCH();
}
Expand Down