[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 7211d306d4c2f73732540759e20dd17bd18b3361 by Serhiy Storchaka in 
branch 'master':
Remove an unused variable after bpo-35444. (GH-7)
https://github.com/python/cpython/commit/7211d306d4c2f73732540759e20dd17bd18b3361


--

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread STINNER Victor


STINNER Victor  added the comment:

I reopen the issuue. Commit bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d introduced 
a new compiler warning:

gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall -O0   -std=c99 
-Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration  
-I./Include/internal  -I. -I./Include-DPy_BUILD_CORE -o Objects/object.o 
Objects/object.c

In file included from ./Include/object.h:715,
 from ./Include/pytime.h:6,
 from ./Include/Python.h:75,
 from Objects/object.c:4:
./Include/cpython/object.h:37:51: warning: 'PyId_builtins' defined but not used 
[-Wunused-variable]
 #define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
   ^
./Include/cpython/object.h:36:66: note: in definition of macro 
'_Py_static_string'
 #define _Py_static_string(varname, value)  static _Py_Identifier varname = 
_Py_static_string_init(value)
  ^~~
Objects/object.c:20:1: note: in expansion of macro '_Py_IDENTIFIER'
 _Py_IDENTIFIER(builtins);
 ^~

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

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +10346
stage: resolved -> patch review

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.6, Python 3.7

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset be6ec444729f727f304ae10f3a7e2feda3cc3aaa by Serhiy Storchaka 
(Miss Islington (bot)) in branch '3.6':
bpo-35444: Fix error handling when fail to look up builtin "getattr". 
(GH-11047) (GH-11107) (GH-11108)
https://github.com/python/cpython/commit/be6ec444729f727f304ae10f3a7e2feda3cc3aaa


--

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10337

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 3cae16d2e98ffaa89ddd311df70a857dfaff4020 by Serhiy Storchaka in 
branch '3.7':
bpo-35444: Fix error handling when fail to look up builtin "getattr". 
(GH-11047) (GH-11107)
https://github.com/python/cpython/commit/3cae16d2e98ffaa89ddd311df70a857dfaff4020


--

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +10336

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d by Serhiy Storchaka in 
branch 'master':
bpo-35444: Unify and optimize the helper for getting a builtin object. 
(GH-11047)
https://github.com/python/cpython/commit/bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d


--

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-09 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +10283
stage:  -> patch review

___
Python tracker 

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



[issue35444] Unify and optimize the helper for getting a builtin object

2018-12-09 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

_PyIter_GetBuiltin() was introduced in issue14288 
(31668b8f7a3efc7b17511bb08525b28e8ff5f23a). This was used for getting 
references to the builtin "iter" and "reverse". It was renamed to 
_PyObject_GetBuiltin() in a701388de1135241b5a8e4c970e06c0e83a66dc0.

There is other code that gets references to the builtin "getattr" using 
PyEval_GetBuiltins(). It is more efficient, but contains bugs.

The proposed PR unifies getting references to builtins:

* The prefix _PyObject_ is changed to _PyEval_, since this function has 
relation not to the object type but to the evaluation environment.

* It uses now the private _Py_Identifier API instead of a raw C string. This 
saves time by omitting the creation of a Unicode object on every call.

* It uses now fast PyEval_GetBuiltins() instead of slower PyImport_Import().

* Fixed errors handling in the code that used PyEval_GetBuiltins() before. It 
no longer swallows unexpected exceptions, no longer returns an error without 
setting an exception, and no longer causes raising a SystemError.

An example of an error in current code:

>>> import builtins
>>> del builtins.getattr
>>> int.bit_length.__reduce__()
Traceback (most recent call last):
  File "", line 1, in 
SystemError: NULL object passed to Py_BuildValue

--
components: Interpreter Core
messages: 331424
nosy: kristjan.jonsson, pitrou, serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: Unify and optimize the helper for getting a builtin object
versions: Python 3.8

___
Python tracker 

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