[issue30111] json module: encoder optimization
New submission from Marian Horban: It is possible to improve performance of json module encoder. Since access to local variables is faster than to globals/builtins I propose to use locals instead of globals. Small test of such improvement: >>> import timeit >>> def flocal(name=False): ... for i in range(5): ... x = name ... >>> timeit.timeit("flocal()", "from __main__ import flocal", number=1000) 5.0455567836761475 >>> >>> def fbuilt_in(): ... for i in range(5): ... x = False ... >>> >>> timeit.timeit("fbuilt_in()", "from __main__ import fbuilt_in", >>> number=1000) 5.451796054840088 -- components: Library (Lib) files: encoder_opt.patch keywords: patch messages: 291955 nosy: Marian Horban 2 priority: normal severity: normal status: open title: json module: encoder optimization type: performance versions: Python 2.7 Added file: http://bugs.python.org/file46815/encoder_opt.patch ___ Python tracker <http://bugs.python.org/issue30111> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30114] json module: it is not possible to override 'true', 'false' values during encoding bool
New submission from Marian Horban: It is not possible to override 'true', 'false' values during encoding bool. For example if I want to dump dict like: {"key": True} and result must be not {"key": true} but let's say {"key": "TRUE"} It is really hard to force json.dumps function to do it. I understand that improving of json encoder performance causes this inflexible implementation. Perfect solution for extending/overriding json module would be move nested functions _iterencode_list _iterencode_dict _iterencode into class JSONEncoder as static methods. But it could make performance a bit worse. So if we cannot afford it I would propose to move function _make_iterencode to JSONEncoder as a static method. This change will not degrade performance. But it will be possible to override this method in SPECIFIC user's Encoder. -- components: Library (Lib) files: json_improvement.patch keywords: patch messages: 291959 nosy: Marian Horban 2 priority: normal severity: normal status: open title: json module: it is not possible to override 'true', 'false' values during encoding bool type: enhancement versions: Python 2.7 Added file: http://bugs.python.org/file46816/json_improvement.patch ___ Python tracker <http://bugs.python.org/issue30114> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24884] Add method reopenFile() in WatchedFileHandler class
New submission from Marian Horban: Method WatchedFileHandler::emit() makes 2 things: 1. reopens log file, 2. emits record. Sometimes user wants to reopen file immediately after some action without emitting. Code that reopens file must be moved to separate method to avoid copy-pasting code in programs that use this functionality. Patch is provided. -- files: add_reopen_file.patch keywords: patch messages: 248765 nosy: Marian Horban priority: normal severity: normal status: open title: Add method reopenFile() in WatchedFileHandler class type: enhancement Added file: http://bugs.python.org/file40201/add_reopen_file.patch ___ Python tracker <http://bugs.python.org/issue24884> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com