[issue39127] _Py_HashPointer's void * argument should be const

2019-12-23 Thread Andy Lester


New submission from Andy Lester :

_Py_HashPointer in Python/pyhash.c takes a pointer argument that can be made 
const.  This will let compiler and static analyzers know that the pointer's 
target is not modified.  You can also change calls to _Py_HashPointer that are 
down-casting pointers.

For example, in meth_hash in Objects/methodobject.c, this call can have the 
void * changed to const void *.

y = _Py_HashPointer((void*)(a->m_ml->ml_meth));

--
components: Interpreter Core
messages: 358839
nosy: petdance
priority: normal
severity: normal
status: open
title: _Py_HashPointer's void * argument should be const

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



[issue39127] _Py_HashPointer's void * argument should be const

2019-12-23 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39150] See if PyToken_OneChar would be faster as a lookup table

2019-12-28 Thread Andy Lester


New submission from Andy Lester :

PyToken_OneChar in Parser/token.c is autogenerated.  I suspect it may be faster 
and smaller if it were a lookup into a static table of ops rather than a switch 
statement.  Check to see if it is.

--
components: Interpreter Core
messages: 358975
nosy: petdance
priority: normal
severity: normal
status: open
title: See if PyToken_OneChar would be faster as a lookup table
type: enhancement

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



[issue39150] See if PyToken_OneChar would be faster as a lookup table

2019-12-28 Thread Andy Lester


Andy Lester  added the comment:

Thank you. I appreciate the pointer.

--

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



[issue39146] too much memory consumption in re.compile unicode

2020-01-03 Thread Andy Lester


Change by Andy Lester :


--
components: +Regular Expressions -Library (Lib)
nosy: +ezio.melotti, mrabarnett

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



[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-08 Thread Andy Lester


Andy Lester  added the comment:

I tried out some experimenting with the lookup table vs. the switch
statement.

The relevant diff (not including the patches to the code generator) is:


--- Parser/token.c
+++ Parser/token.c
@@ -77,31 +77,36 @@
 int
 PyToken_OneChar(int c1)
 {
-switch (c1) {
-case '%': return PERCENT;
-case '&': return AMPER;
-case '(': return LPAR;
-case ')': return RPAR;
-case '*': return STAR;
-case '+': return PLUS;
-case ',': return COMMA;
-case '-': return MINUS;
-case '.': return DOT;
-case '/': return SLASH;
-case ':': return COLON;
-case ';': return SEMI;
-case '<': return LESS;
-case '=': return EQUAL;
-case '>': return GREATER;
-case '@': return AT;
-case '[': return LSQB;
-case ']': return RSQB;
-case '^': return CIRCUMFLEX;
-case '{': return LBRACE;
-case '|': return VBAR;
-case '}': return RBRACE;
-case '~': return TILDE;
-}
+static char op_lookup[] = {
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,PERCENT,   AMPER, OP,
+LPAR,  RPAR,  STAR,  PLUS,  COMMA,
+MINUS, DOT,   SLASH, OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,COLON, SEMI,
+LESS,  EQUAL, GREATER,   OP,AT,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,LSQB,  OP,RSQB,  CIRCUMFLEX,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,OP,OP,
+OP,OP,OP,LBRACE,VBAR,
+RBRACE,TILDE
+};
+if (c1>=37 && c1<=126)
+return op_lookup[c1];
 return OP;
 }

To test the speed change, I couldn't use pyperformance, because the only
thing I wanted to time was the In my testing, I didn't use pyperformance
because the only part of the code I wanted to test was the actual
compilation of the code.  My solution for this was to find the 100 largest
*.py files in the cpython repo and compile them like so:

python -m py_compile $(List-of-big-*.py-files)

The speedup was significant: My table-driven lookup ran the compile tests
about 10% than the existing switch approach.  That was without
--enable-optimizations in my configure.

However, as pablogsal suspected, with PGO enabled, the two approaches ran
the code in pretty much the same speed.

I do think that there may be merit in using a table-driven approach that
generates less code and doesn't rely on PGO speeding things up.

If anyone's interested, all my work is on branch Issue39150 in my fork
petdance/cpython.

--

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



[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-09 Thread Andy Lester


Andy Lester  added the comment:

Yes, I ran it multiple times on my 2013 Macbook Pro and got ~10% speedup.  I 
also ran it on my Linux VM (that I only use for development) and got a speedup 
but less so.

The code I used to run the tests is at: 
https://github.com/petdance/cpython/blob/Issue39150/timetests

LOG=timelog.txt
NRUNS=100
NFILES=100

if [ -x ./python.exe ] ; then
PYTHON=./python.exe
else
PYTHON=./python
fi

# Build a file list, but throw out some that have syntax errors.
# Use the 100 biggest files.
FILES=$(
find . -name '*.py' -type f -ls \
| grep -v Tools/test2to3/ \
| grep -v Lib/lib2to3/tests/ \
| grep -v Lib/test/badsyntax \
| grep -v Lib/test/bad_coding \
| sort -r -n -k7 \
| awk '{print $11}' \
| head -n $NFILES
)

echo "Compiling $NFILES files for $NRUNS iterations"

rm -f $LOG

for (( i=1; i<=$NRUNS; i++ )) do
echo "Run $i"
{ time $PYTHON -m py_compile $FILES; } >> $LOG 2>&1
done

perl -ne'if(/real\s+0m([\d.]+)s/){$t+=$1;$n++} END { printf "%d runs, average 
%0.4f\n", $n, $t/$n}' $LOG

--

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



[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-09 Thread Andy Lester


Andy Lester  added the comment:

Re: branch prediction.

The branch

if (c1>=37 && c1<=126)

could just as easily be

if (c1>=0 && c1<=126)

with no other changes to the code.  It could be just

if (c1<=126)

if c1 wasn't signed.

As far as branch prediction, we could make it something like

if (c1>=0 && c1<=255)

and expand the table lookup, depending on what the likely inputs are.  I could 
play around with that some if anyone was interested.

I'm not trying to push on this.  Just sharing some thoughts and research.

--

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



[issue39588] Use memcpy() instead of for() loops in _PyUnicode_To*

2020-02-08 Thread Andy Lester


New submission from Andy Lester :

Four functions in Objects/unicodectype.c copy values out of lookup tables with 
a for loop

int i;
for (i = 0; i < n; i++)
res[i] = _PyUnicode_ExtendedCase[index + i];

instead of a memcpy

memcpy(res, &_PyUnicode_ExtendedCase[index], n * sizeof(Py_UCS4));

My Apple clang version 11.0.0 on my Mac optimizes away the for loop and 
generates equivalent code to the memcpy.

gcc 4.8.5 on my Linux box (the newest GCC I have) does not optimize away the 
loop.

The four functions are:
_PyUnicode_ToLowerFull
_PyUnicode_ToTitleFull
_PyUnicode_ToUpperFull
_PyUnicode_ToFoldedFull

--
components: Unicode
messages: 361636
nosy: ezio.melotti, petdance, vstinner
priority: normal
severity: normal
status: open
title: Use memcpy() instead of for() loops in _PyUnicode_To*
type: performance

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



[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-02-08 Thread Andy Lester


Andy Lester  added the comment:

I'm closing this as it seems there's not much interest in this.

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

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



[issue39588] Use memcpy() instead of for() loops in _PyUnicode_To*

2020-02-08 Thread Andy Lester


Andy Lester  added the comment:

Thanks for replying. I figured that might be the case, which is why I made a 
ticket before bothering with a pull request.

I've also seen this kind of thing around:

i = ctx->pattern[0];
Py_ssize_t groupref = i+i;

instead of

Py_ssize_t groupref = ctx->pattern[0]*2;

Is that also the kind of thing we would leave for the compiler to sort out?

--

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



[issue39591] Functions in Python/traceback.c can take const pointer arguments

2020-02-08 Thread Andy Lester


New submission from Andy Lester :

The functions tb_displayline and tb_printinternal can take const pointers on 
some of their arguments.

tb_displayline(PyObject *f, PyObject *filename, int lineno, const PyObject 
*name)

tb_printinternal(const PyTracebackObject *tb, PyObject *f, long limit)

--
components: Interpreter Core
messages: 361643
nosy: petdance
priority: normal
severity: normal
status: open
title: Functions in Python/traceback.c can take const pointer arguments
type: enhancement

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



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-08 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +17793
pull_request: https://github.com/python/cpython/pull/18420

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



[issue39591] Functions in Python/traceback.c can take const pointer arguments

2020-02-08 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-08 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +17797
pull_request: https://github.com/python/cpython/pull/18422

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



[issue39591] Functions in Python/traceback.c can take const pointer arguments

2020-02-08 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -17794

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



[issue39591] Functions in Python/traceback.c can take const pointer arguments

2020-02-08 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +17798
pull_request: https://github.com/python/cpython/pull/18422

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



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-08 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +17799
pull_request: https://github.com/python/cpython/pull/18422

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



[issue39591] Functions in Python/traceback.c can take const pointer arguments

2020-02-09 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -17798

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



[issue39591] Functions in Python/traceback.c can take const pointer arguments

2020-02-09 Thread Andy Lester


Andy Lester  added the comment:

I'm sorry, I think my comment was misleading.

The changes I had proposed were not making the object itself const, but some of 
the arguments in the static worker functions.  For example:

-tb_displayline(PyObject *f, PyObject *filename, int lineno, PyObject *name)
+tb_displayline(PyObject *f, PyObject *filename, int lineno, const PyObject 
*name)

and

-tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
+tb_printinternal(const PyTracebackObject *tb, PyObject *f, long limit)

I've got -Wincompatible-pointer-types-discards-qualifiers and -Wcast-qual 
turned on, and no errors occur.

Is there somewhere in the deep internals of the Python macros where constness 
can be changed but the compiler isn't reporting on it?

Thanks,
Andy

--

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



[issue39591] Functions in Python/traceback.c can take const pointer arguments

2020-02-10 Thread Andy Lester


Andy Lester  added the comment:

> Yes, Py_INCREF and Py_DECREF change the type, and therefore constness.

Understood. The changes that I have proposed are not to objects that get sent 
through Py_INCREF/Py_DECREF.  If they did, -Wcast-qual would have caught it.  
-Wcast-qual catches if you cast, say, a const char * to a char *.

Let's let this stay closed and I'll resubmit with a clearer ticket & PR.

--

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



[issue39605] Fix some casts to not cast away const

2020-02-10 Thread Andy Lester


New submission from Andy Lester :

gcc -Wcast-qual turns up a number of instances of casting away constness of 
pointers.  Some of these can be safely modified, by either:

* Adding the const to the type cast, as in:

-return _PyUnicode_FromUCS1((unsigned char*)s, size);
+return _PyUnicode_FromUCS1((const unsigned char*)s, size);

* Removing the cast entirely, because it's not necessary (but probably was at 
one time), as in:

-PyDTrace_FUNCTION_ENTRY((char *)filename, (char *)funcname, lineno);
+PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno);

These changes will not change code, but they will make it much easier to check 
for errors in consts.

--
components: Interpreter Core
messages: 361780
nosy: petdance
priority: normal
severity: normal
status: open
title: Fix some casts to not cast away const
type: enhancement

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



[issue39605] Fix some casts to not cast away const

2020-02-10 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39620] PyObject_GetAttrString and tp_getattr do not agree

2020-02-12 Thread Andy Lester


New submission from Andy Lester :

PyObject_GetAttrString(PyObject *v, const char *name)

typedef PyObject *(*getattrfunc)(PyObject *, char *)

The outer PyObject_GetAttrString takes a const char *name, but then casts away 
the const when calling the underlying tp_getattr.  This means that an 
underlying function would be free to modify or free() the char* passed in to 
it, which might be, for example, a string literal, which would be a Bad Thing.

The setattr function pair has the same problem.

The API doc at https://docs.python.org/3/c-api/typeobj.html says that the 
tp_getattr and tp_setattr slots are deprecated.  If they're not going away 
soon, I would think this should be addressed.

Fixing this in the cPython code by making tp_getattr and tp_setattr take const 
char * pointers would be simple.  I don't have any idea how much outside code 
it would affect.

--
components: C API
messages: 361929
nosy: petdance
priority: normal
severity: normal
status: open
title: PyObject_GetAttrString and tp_getattr do not agree
type: enhancement

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



[issue39620] PyObject_GetAttrString and tp_getattr do not agree

2020-02-12 Thread Andy Lester


Andy Lester  added the comment:

Do you know why it was reverted?  (Granted, it was 15 years ago...)

It looks like the original changeset is trying to address at least two 
different problems with non-const string literals.  My ticket here is focusing 
only on getattrfunc and setattrfunc.  The handling of all the kwlist is a 
separate issue, that I'm about to write up as a different ticket.

--

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



[issue39621] md5_compress() in Modules/md5module.c can take a const buf

2020-02-12 Thread Andy Lester


New submission from Andy Lester :

The function md5_compress does not modify its buffer argument.

static void md5_compress(struct md5_state *md5, unsigned char *buf)

buf should be const.

--
components: Extension Modules
messages: 361932
nosy: petdance
priority: normal
severity: normal
status: open
title: md5_compress() in Modules/md5module.c can take a const buf
type: enhancement

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



[issue39621] md5_compress() in Modules/md5module.c can take a const buf

2020-02-12 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39630] Const some pointers to string literals

2020-02-13 Thread Andy Lester


New submission from Andy Lester :

Here are some fixes of char * pointers to literals that should be const char * 
in these four files.

+++ Objects/frameobject.c
+++ Objects/genobject.c
+++ Python/codecs.c
+++ Python/errors.c

--
components: Interpreter Core
messages: 361982
nosy: petdance
priority: normal
severity: normal
status: open
title: Const some pointers to string literals
type: enhancement

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



[issue39630] Const some pointers to string literals

2020-02-13 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-15 Thread Andy Lester


Andy Lester  added the comment:

@vstinner would it be helpful if I went on a sweep looking for places we can 
use the new Py_IS_TYPE macro?

Getting away from Py_TYPE(op) would also mean a move to making the internals 
const-correct.

--
nosy: +petdance

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-15 Thread Andy Lester


Andy Lester  added the comment:

I'm hoping that a goal here is to make

static inline int _Py_IS_TYPE(PyObject *ob, PyTypeObject *type)

actually be

static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type)

--

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-17 Thread Andy Lester


Andy Lester  added the comment:

> Would you mind to explain how it's an issue to modify PyObject* temporarily 
> during a function call?

It's not a problem to modify the PyObject* during a function call.  However, 
many functions don't need to modify the object, but are still taking non-const 
PyObject* arguments.

For example if I have this code:

if (Py_TYPE(deque) == &deque_type) {

That doesn't modify deque to check the type, but because Py_TYPE casts away the 
constness, deque can't be a const object.

However, with the new Py_IS_TYPE function:

if (Py_IS_TYPE(deque, &deque_type)) {

and these two changes:

-static inline int _Py_IS_TYPE(PyObject *ob, PyTypeObject *type) {
+static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
 return ob->ob_type == type;
 }
-#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST(ob), type)
+#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(((const PyObject*)(ob)), type)

the deque variable can be const.

Another example of a common pattern that I believe could benefit from this is 
Py_TYPE(ob)->tp_name.  That could be turned into Py_TYPE_NAME(ob) and that 
would allow the ob to be a const pointer. 

If we can keep functions that don't modify the object to accept const PyObject* 
it will help make things safer in the long run.

--

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-18 Thread Andy Lester


Andy Lester  added the comment:

All I'm saying is that I think Py_IS_TYPE is a great idea, and that Py_IS_TYPE 
should take const arguments, since its arguments are not modified.  If you 
think that should go in a different ticket, then I can make that happen.

--

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



[issue39684] PyUnicode_IsIdentifier has two if/thens that can be combined

2020-02-18 Thread Andy Lester


New submission from Andy Lester :

These two code if/thens can be combined

if (ready) {
kind = PyUnicode_KIND(self);
data = PyUnicode_DATA(self);
}
else {
wstr = _PyUnicode_WSTR(self);
}

Py_UCS4 ch;
if (ready) {
ch = PyUnicode_READ(kind, data, 0);
}
else {
ch = wstr[0];
}

--
components: Interpreter Core
messages: 362250
nosy: petdance
priority: normal
severity: normal
status: open
title: PyUnicode_IsIdentifier has two if/thens that can be combined

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



[issue39684] PyUnicode_IsIdentifier has two if/thens that can be combined

2020-02-18 Thread Andy Lester


Change by Andy Lester :


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

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



[issue38691] importlib: PYTHONCASEOK should be ignored when using python3 -E

2020-02-19 Thread Andy Lester


Change by Andy Lester :


--
nosy: +petdance

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



[issue39684] PyUnicode_IsIdentifier has two if/thens that can be combined

2020-02-19 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +17947
pull_request: https://github.com/python/cpython/pull/18565

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



[issue39684] PyUnicode_IsIdentifier has two if/thens that can be combined

2020-02-19 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -17937

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



[issue39721] Fix constness of members of tok_state struct.

2020-02-21 Thread Andy Lester


New submission from Andy Lester :

The function PyTokenizer_FromUTF8 from Parser/tokenizer.c had a comment:

/* XXX: constify members. */

This patch addresses that.

In the tok_state struct:
* end and start were non-const but could be made const
* str and input were const but should have been non-const

Changes to support this include:
* decode_str() now returns a char * since it is allocated.
* PyTokenizer_FromString() and PyTokenizer_FromUTF8() each creates a
new char * for an allocate string instead of reusing the input
const char *.
* PyTokenizer_Get() and tok_get() now take const char ** arguments.
* Various local vars are const or non-const accordingly.

I was able to remove five casts that cast away constness.

--
components: Interpreter Core
messages: 362441
nosy: petdance
priority: normal
severity: normal
status: open
title: Fix constness of members of tok_state struct.

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



[issue39721] Fix constness of members of tok_state struct.

2020-02-21 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-21 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +17968
pull_request: https://github.com/python/cpython/pull/18601

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-21 Thread Andy Lester


Andy Lester  added the comment:

Just added a new PR to finish off the remaining places to use Py_IS_TYPE()

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

--

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



[issue39736] const strings in Modules/_datetimemodule.c and Modules/_testbuffer.c

2020-02-23 Thread Andy Lester


New submission from Andy Lester :

In Modules/_datetimemodule.c, the char *timespec and char *specs[] can be made 
const.  Their contents are never modified.

In ndarray_get_format in Modules/_testbuffer.c, char *fmt can be made const.

--
components: Interpreter Core
messages: 362565
nosy: petdance
priority: normal
severity: normal
status: open
title: const strings in Modules/_datetimemodule.c and Modules/_testbuffer.c

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



[issue39736] const strings in Modules/_datetimemodule.c and Modules/_testbuffer.c

2020-02-23 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


New submission from Andy Lester :

The array_modexec function in Modules/arraymodule.c has a loop that calculates 
the number of elements in the descriptors array.  This size was used at one 
point, but is no longer.  The loop can be removed.

--
components: Interpreter Core
messages: 362772
nosy: petdance
priority: normal
severity: normal
status: open
title: Remove unnecessary size calculation in array_modexec in 
Modules/arraymodule.c

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18032
pull_request: https://github.com/python/cpython/pull/18674

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18033
pull_request: https://github.com/python/cpython/pull/18675

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -18032

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -18031

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18035
pull_request: https://github.com/python/cpython/pull/18673

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18034
pull_request: https://github.com/python/cpython/pull/18674

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -18034

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



[issue39770] Remove unnecessary size calculation in array_modexec in Modules/arraymodule.c

2020-02-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -18035

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



[issue39803] _PyLong_FormatAdvancedWriter has an unnecessary str

2020-02-29 Thread Andy Lester


New submission from Andy Lester :

_PyLong_FormatAdvancedWriter has a PyObject *str that is never used.  Remove it.

--
components: Interpreter Core
messages: 363006
nosy: petdance
priority: normal
severity: normal
status: open
title: _PyLong_FormatAdvancedWriter has an unnecessary str

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



[issue39803] _PyLong_FormatAdvancedWriter has an unnecessary str

2020-02-29 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39803] _PyLong_FormatAdvancedWriter has an unnecessary str

2020-02-29 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -18066

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



[issue39803] _PyLong_FormatAdvancedWriter has an unnecessary str

2020-02-29 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18067
pull_request: https://github.com/python/cpython/pull/18708

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



[issue39803] _PyLong_FormatAdvancedWriter has an unnecessary str

2020-02-29 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -18067

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



[issue39803] _PyLong_FormatAdvancedWriter has an unnecessary str

2020-02-29 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18068
pull_request: https://github.com/python/cpython/pull/18709

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-03-04 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18146
pull_request: https://github.com/python/cpython/pull/18789

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



[issue39859] set_herror should not throw away constness of hstrerror

2020-03-04 Thread Andy Lester


New submission from Andy Lester :

set_herror builds a string by calling hstrerror but downcasts its return value 
to char *.  It should be const char *.

--
components: Interpreter Core
messages: 363418
nosy: petdance
priority: normal
severity: normal
status: open
title: set_herror should not throw away constness of hstrerror

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



[issue39859] set_herror should not throw away constness of hstrerror

2020-03-04 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39870] sys_displayhook_unencodable takes an unnecessary PyThreadState * argument

2020-03-05 Thread Andy Lester


New submission from Andy Lester :

sys_displayhook_unencodable in Python/sysmodule.c doesn't need its first 
argument.  Remove it.

--
messages: 363475
nosy: petdance
priority: normal
severity: normal
status: open
title: sys_displayhook_unencodable takes an unnecessary PyThreadState * argument

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



[issue39870] sys_displayhook_unencodable takes an unnecessary PyThreadState * argument

2020-03-05 Thread Andy Lester


Change by Andy Lester :


--
components: +Interpreter Core

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



[issue39870] sys_displayhook_unencodable takes an unnecessary PyThreadState * argument

2020-03-05 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-03-05 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18154
pull_request: https://github.com/python/cpython/pull/18798

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-03-05 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18155
pull_request: https://github.com/python/cpython/pull/18799

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



[issue39872] Remove unused args from four functions in Python/symtable.c

2020-03-05 Thread Andy Lester


New submission from Andy Lester :

These four functions have unused arguments that can be removed:

symtable_exit_block -> void *ast

symtable_visit_annotations -> stmt_ty s

symtable_exit_block -> void *ast

symtable_visit_annotations -> stmt_ty s

PR is forthcoming.

--
components: Interpreter Core
messages: 363486
nosy: petdance
priority: normal
severity: normal
status: open
title: Remove unused args from four functions in Python/symtable.c

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



[issue39872] Remove unused args from two functions in Python/symtable.c

2020-03-05 Thread Andy Lester


Andy Lester  added the comment:

Two functions. It's only two functions.

--
title: Remove unused args from four functions in Python/symtable.c -> Remove 
unused args from two functions in Python/symtable.c

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



[issue39872] Remove unused args from two functions in Python/symtable.c

2020-03-05 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-03-06 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18167
pull_request: https://github.com/python/cpython/pull/18809

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



[issue39878] Remove unused args in Python/formatter_unicode.c

2020-03-06 Thread Andy Lester


New submission from Andy Lester :

The following functions have unused args:

calc_number_widths -> PyObject *number

fill_number -> Py_ssize_t d_end

--
components: Interpreter Core
messages: 363525
nosy: petdance
priority: normal
severity: normal
status: open
title: Remove unused args in Python/formatter_unicode.c

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



[issue39878] Remove unused args in Python/formatter_unicode.c

2020-03-06 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39127] _Py_HashPointer's void * argument should be const

2020-03-06 Thread Andy Lester


Andy Lester  added the comment:

Is there more to do here or can it be closed?

--

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



[issue39878] Remove unused args in Python/formatter_unicode.c

2020-03-06 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18181
pull_request: https://github.com/python/cpython/pull/18822

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



[issue39886] Remove unused arg in config_get_stdio_errors in Python/initconfig.c

2020-03-06 Thread Andy Lester


New submission from Andy Lester :

config_get_stdio_errors(const PyConfig *config) does not use its arg.  Delete 
it.

--
components: Interpreter Core
messages: 363582
nosy: petdance
priority: normal
severity: normal
status: open
title: Remove unused arg in config_get_stdio_errors in Python/initconfig.c

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



[issue39886] Remove unused arg in config_get_stdio_errors in Python/initconfig.c

2020-03-06 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39896] Const args and remove unused args in Python/compile.c

2020-03-07 Thread Andy Lester


New submission from Andy Lester :

Remove unused args from:
* binop
* compiler_next_instr
* inplace_binop

Const arguments for:
* assemble_jump_offsets
* blocksize
* check_caller
* check_compare
* check_index
* check_is_arg
* check_subscripter
* compiler_error
* compiler_new_block
* compiler_pop_fblock
* compiler_push_fblock
* compiler_warn
* compute_code_flags
* dfs
* find_ann
* get_ref_type
* merge_const_tuple
* stackdepth

--
components: Interpreter Core
messages: 363632
nosy: petdance
priority: normal
severity: normal
status: open
title: Const args and remove unused args in Python/compile.c

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



[issue39896] Const args and remove unused args in Python/compile.c

2020-03-07 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39898] Remove unused arg from append_formattedvalue in Python/ast_unparse.c

2020-03-07 Thread Andy Lester


New submission from Andy Lester :

append_formattedvalue() has an unused bool is_format_spec.

--
components: Interpreter Core
messages: 363634
nosy: petdance
priority: normal
severity: normal
status: open
title: Remove unused arg from append_formattedvalue in Python/ast_unparse.c

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



[issue39898] Remove unused arg from append_formattedvalue in Python/ast_unparse.c

2020-03-07 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39908] Remove unused args from init_set_builtins_open and _Py_FatalError_PrintExc in Python/pylifecycle.c

2020-03-08 Thread Andy Lester


New submission from Andy Lester :

init_set_builtins_open(PyThreadState *tstate) -> unused arg

_Py_FatalError_PrintExc(int fd) -> unused arg

--
components: Interpreter Core
messages: 363690
nosy: petdance
priority: normal
severity: normal
status: open
title: Remove unused args from init_set_builtins_open and 
_Py_FatalError_PrintExc in Python/pylifecycle.c

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



[issue39908] Remove unused args from init_set_builtins_open and _Py_FatalError_PrintExc in Python/pylifecycle.c

2020-03-08 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39922] Remove unused args in Python/compile.c

2020-03-09 Thread Andy Lester


New submission from Andy Lester :

These functions have unnecessary args that can be removed:

* binop
* compiler_add_o
* compiler_next_instr
* inplace_binop

--
components: Interpreter Core
messages: 363799
nosy: petdance
priority: normal
severity: normal
status: open
title: Remove unused args in Python/compile.c

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



[issue39896] Const args and remove unused args in Python/compile.c

2020-03-09 Thread Andy Lester


Andy Lester  added the comment:

Replaced by https://bugs.python.org/issue39922

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

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



[issue39922] Remove unused args in Python/compile.c

2020-03-09 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39922] Remove unused args in Python/compile.c

2020-03-10 Thread Andy Lester


Andy Lester  added the comment:

Sorry about the noise.  I will do that.  Yes, I have a bunch more to submit.

--

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



[issue39943] Meta: Clean up various issues

2020-03-11 Thread Andy Lester


New submission from Andy Lester :

This is a meta-ticket for a number of small PRs that clean up some internals.

Issues will include:

* Removing unnecessary casts
* consting pointers that can be made const
* Removing unused function arguments
* etc

--
components: Interpreter Core
messages: 363993
nosy: petdance
priority: normal
severity: normal
status: open
title: Meta: Clean up various issues

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-11 Thread Andy Lester


Change by Andy Lester :


--
title: Meta: Clean up various issues -> Meta: Clean up various issues in C 
internals

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



[issue39922] Remove unused args in Python/compile.c

2020-03-11 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18300
pull_request: https://github.com/python/cpython/pull/18949

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



[issue39922] Remove unused args in Python/compile.c

2020-03-11 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -18300

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-11 Thread Andy Lester


Change by Andy Lester :


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

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-12 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18322
pull_request: https://github.com/python/cpython/pull/18973

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-24 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18513
pull_request: https://github.com/python/cpython/pull/19152

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-25 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18530
pull_request: https://github.com/python/cpython/pull/19170

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18544
pull_request: https://github.com/python/cpython/pull/19185

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-26 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +18545
pull_request: https://github.com/python/cpython/pull/19186

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



[issue39943] Meta: Clean up various issues in C internals

2020-03-26 Thread Andy Lester


Andy Lester  added the comment:

It doesn't quiet any compiler warnings given the default compiler warnings that 
./configure sets.  

However, it does quiet the -Wcast-qual compiler warning that could be a helpful 
addition some time in the future. I think it would be great, for example, if it 
were made impossible to send a pointer that points at a string literal into a 
function that would modify its contents.

Consting pointers also helps static analyzers like splint by letting it know 
the intent of the API.  It makes it possible for the analyzer to detect 
uninitialized buffers, for example.

All of the 20 or so patches that I've submitted, like BPO 39770 that you 
merged, have come about from my cranking up the warning options on both GCC and 
clang and sifting through the warnings.  My hope is that by making more things 
const, we can detect existing bugs and prevent new ones.

You say "I'm not sure that it's worth it to modify exiting code."  Is your 
concern the amount of work it would take to find the problems?  If so, it's not 
that much work when you let the compiler find the problems, which I've done.  
I've already spent the time digging and validating.

--

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



[issue39908] Remove unused args from init_set_builtins_open and _Py_FatalError_PrintExc in Python/pylifecycle.c

2020-03-26 Thread Andy Lester


Change by Andy Lester :


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

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



  1   2   >