Re: [Python-Dev] Internal representation of strings and Micropython

2014-06-04 Thread Serhiy Storchaka
05.06.14 01:04, Terry Reedy написав(ла): PS. You do not seem to be aware of how well the current PEP393 implementation works. If you are going to write any more about it, I suggest you run Tools/Stringbench/stringbench.py for timings. AFAIK stringbench is ASCII-only, so it likely is compatible

Re: [Python-Dev] Internal representation of strings and Micropython

2014-06-04 Thread Serhiy Storchaka
05.06.14 00:21, Terry Reedy написав(ла): On 6/4/2014 3:41 AM, Jeff Allen wrote: Jython uses UTF-16 internally -- probably the only sensible choice in a Python that can call Java. Indexing is O(N), fundamentally. By "fundamentally", I mean for those strings that have not yet noticed that they con

Re: [Python-Dev] Internal representation of strings and Micropython

2014-06-05 Thread Serhiy Storchaka
05.06.14 03:08, Greg Ewing написав(ла): Serhiy Storchaka wrote: A language which doesn't support O(1) indexing is not Python, it is only Python-like language. That's debatable, but even if it's true, I don't think there's anything wrong with MicroPython being only a &

Re: [Python-Dev] Internal representation of strings and Micropython

2014-06-05 Thread Serhiy Storchaka
05.06.14 03:03, Greg Ewing написав(ла): Serhiy Storchaka wrote: html.HTMLParser, json.JSONDecoder, re.compile, tokenize.tokenize don't use iterators. They use indices, str.find and/or regular expressions. Common use case is quickly find substring starting from current position using str.fi

Re: [Python-Dev] Internal representation of strings and Micropython

2014-06-05 Thread Serhiy Storchaka
04.06.14 23:50, Glenn Linderman написав(ла): 3) (Most space efficient) One cached entry, that caches the last codepoint/byte position referenced. UTF-8 is able to be traversed in either direction, so "next/previous" codepoint access would be relatively fast (and such are very common operations, e

Re: [Python-Dev] Internal representation of strings and Micropython

2014-06-05 Thread Serhiy Storchaka
05.06.14 05:25, Terry Reedy написав(ла): I mentioned it as an alternative during the '393 discussion. I more than half agree that the FSR is the better choice for CPython, which had no particular attachment to UTF-16 in the way that I think Jython, for instance, does. Yes, I remember. I thing t

[Python-Dev] close() questions

2014-06-12 Thread Serhiy Storchaka
11.06.14 05:28, Antoine Pitrou написав(ла): close() should indeed be idempotent on all bundled IO class implementations (otherwise it's a bug), and so should it preferably on third-party IO class implementations. There are some questions about close(). 1. If object owns several resources, shou

[Python-Dev] Examples for PEP 572

2018-07-03 Thread Serhiy Storchaka
I like programming languages in which all are expressions (including function declarations, branching and loops) and you can use an assignment at any point, but Python is built on other ways, and I like Python too. PEP 572 looks violating several Python design principles. Python looks simple la

Re: [Python-Dev] Examples for PEP 572

2018-07-03 Thread Serhiy Storchaka
04.07.18 00:51, Chris Angelico пише: On Wed, Jul 4, 2018 at 7:37 AM, Serhiy Storchaka wrote: I believe most Python users are not professional programmers -- they are sysadmins, scientists, hobbyists and kids -- [citation needed] I don't understand what citation do you need.

Re: [Python-Dev] Examples for PEP 572

2018-07-03 Thread Serhiy Storchaka
04.07.18 03:24, INADA Naoki пише: I feel PEP 572 breaks border between expression and statement, and it makes readability of dirty code worse. Thank you, this is what I meant. On the other hand, I understand PEP 572 allows clever code simplifies tedious code.  It may increase readability of

Re: [Python-Dev] Examples for PEP 572

2018-07-03 Thread Serhiy Storchaka
04.07.18 04:26, Tim Peters пише: I really don't know what Guido likes best about this, but for me it's the large number of objectively small wins in `if` and `while` contexts.   They add up.  That conclusion surprised me.  That there are occasionally bigger wins to be had is pure gravy. Could

Re: [Python-Dev] Examples for PEP 572

2018-07-04 Thread Serhiy Storchaka
04.07.18 04:54, Terry Reedy пише: Would (f(x),) be faster? No. Both "for y in [f(x)]" and "for y in (f(x),)" are compiled to the same bytecode. Run your microbenchmarks again, the difference is a small random variation. https://bugs.python.org/issue32925 stuff = [[y := f(x), x/y] for x in

Re: [Python-Dev] Examples for PEP 572

2018-07-04 Thread Serhiy Storchaka
04.07.18 05:42, Steven D'Aprano пише: On Tue, Jul 03, 2018 at 09:54:22PM -0400, Terry Reedy wrote:     results = [(x, y, x/y) for x in input_data for y in [f(x)] if y > 0] Would (f(x),) be faster? There is a deferred feature request to optimize "for x in [item]" as equivalent to "for x in (

Re: [Python-Dev] Examples for PEP 572

2018-07-04 Thread Serhiy Storchaka
gt; occasionally bigger wins to be had is pure gravy. [Serhiy Storchaka] > Could you please show me several examples in real code? I > have not seen any win yet. My PEP Appendix was derived entirely from looking at real code.  If you don't believe the examples I showed there are win

Re: [Python-Dev] Assignment expression and coding style: the while True case

2018-07-04 Thread Serhiy Storchaka
05.07.18 01:51, Victor Stinner пише: == Pattern 1, straighforward == while True: line = input.readline() if not line: break ... IMHO here assingment expression is appropriate here. The code remains straighfoward to read. while (line := input.readline()): ... We a

Re: [Python-Dev] Assignment expression and coding style: the while True case

2018-07-04 Thread Serhiy Storchaka
05.07.18 03:03, Victor Stinner пише: +labels = [slabel for label + in self._file.readline()[1:].split(b',') + if (slabel := label.strip())] labels = [slabel for label in self._file.readli

Re: [Python-Dev] Failing tests (on a Linux distro)

2018-07-06 Thread Serhiy Storchaka
04.07.18 15:05, Nick Coghlan пише: So my guess would be that this is a test suite error where we're not handling the "running in a reproducible build environment with SOURCE_DATE_EPOCH already set" case. Should SOURCE_DATE_EPOCH be documented together with PYTHONDONTWRITEBYTECODE? __

Re: [Python-Dev] On the METH_FASTCALL calling convention

2018-07-07 Thread Serhiy Storchaka
05.07.18 17:53, Jeroen Demeyer пише: In other words: I see nothing to improve in the calling convention of METH_FASTCALL. I suggest to keep it and make it public as-is. You have considered the bytecode for calling functions, but this actually is not directly related to the calling convention.

Re: [Python-Dev] Can I make marshal.dumps() slower but stabler?

2018-07-11 Thread Serhiy Storchaka
12.07.18 08:43, INADA Naoki пише: I'm working on making pyc stable, via stablizing marshal.dumps() https://bugs.python.org/issue34093 This is not enough for making pyc stable. The order in frozesets still is arbitrary. Sadly, it makes marshal.dumps() 40% slower. Luckily, this overhead is sm

[Python-Dev] PEP 572 and assert

2018-07-17 Thread Serhiy Storchaka
Recently Barry shown an example: assert len(subdirs := list(path.iterdir())) == 0, subdirs It looks awful to me. It looks even worse than using asserts for validating the user input. The assert has a side effect, and it depends on the interpreter option (-O). Even if subdirs is not used ou

Re: [Python-Dev] PEP 572 and assert

2018-07-17 Thread Serhiy Storchaka
17.07.18 17:59, Guido van Rossum пише: The PEP has no specific opinion except it is not forbidden. Personally I like Barry's example just fine -- assuming `subdirs` is not used later, this feels like a good use case. Shouldn't this problem be solved in the same way as for comprehensions? Shou

Re: [Python-Dev] PEP 572 and assert

2018-07-17 Thread Serhiy Storchaka
17.07.18 18:48, Guido van Rossum пише: On Tue, Jul 17, 2018 at 8:28 AM, Serhiy Storchaka <mailto:storch...@gmail.com>> wrote: Should not the assert statement introduce an implicit lexical scope for preventing leaking variables? I don't see why. As Chris said, side effects

Re: [Python-Dev] PEP 572 and assert

2018-07-17 Thread Serhiy Storchaka
17.07.18 19:25, Tim Peters пише: It is a win (to my eyes) if the code it replaced was     if __debug__:         subdirs = list(path.iterdir())         assert len(subdirs) == 0, subdirs in which case the semantics are the same in either spelling, with or without -O, but the spelling at the t

Re: [Python-Dev] Tests failing on Windows with TESTFN

2018-07-26 Thread Serhiy Storchaka
25.07.18 18:07, Tim Golden пише: I'm just easing back into core development work by trying to get a stable testing environment for Python development on Windows. One problem is that certain tests use support.TESTFN (a local directory constructed from the pid) for output files etc. However this

[Python-Dev] Testing C API

2018-07-29 Thread Serhiy Storchaka
Currently C API is not completely covered by tests. Tests for particular parts of C API are scattered through different files. There are files completely purposed for testing C API (like test_capi.py, test_getargs2.py), there are classes (usually having "CAPI" in the name) in different files fo

Re: [Python-Dev] Testing C API

2018-07-29 Thread Serhiy Storchaka
29.07.18 15:39, Steve Dower пише: On 29Jul2018 1253, Serhiy Storchaka wrote: The benefit is that it will be easier to run all C API tests at once, and only them, and it will be clearer what C API is covered by tests. The disadvantage is that you will need to run several files for testing

Re: [Python-Dev] Testing C API

2018-07-30 Thread Serhiy Storchaka
30.07.18 09:46, Raymond Hettinger пише: I prefer the current organization that keeps the various tests together with the category being tested. I almost never need to run the C API tests all at once, but I do need to see all the tests for an object in one place. When maintaining something li

Re: [Python-Dev] The curious case of 255 function arguments

2018-08-06 Thread Serhiy Storchaka
06.08.18 08:13, Stephen McDowell пише: I've looked at the C code for a while and it is entirely non-obvious what would lead to python *2* /allowing/ >255 arguments.  Anybody happen to know how / why the python *2* versions *succeed*? The error message is misleading. It should be "more than 255

Re: [Python-Dev] Class decorators can't be pickled, which breaks multiprocessing and concurrent.futures. Any plans of improving this?

2018-08-11 Thread Serhiy Storchaka
11.08.18 23:08, Santiago Basulto пише: Hello folks! I'm using the `concurrent.futures.ProcessPoolExecutor` with a couple of functions that have been decorated with a class decorator. Both `concurrent.futures` and `multiprocessing` breaks because "the object's can't be pickled". There's a really

Re: [Python-Dev] ​improvement on shutil.make_archive

2018-08-20 Thread Serhiy Storchaka
20.08.18 18:18, Paul Moore пише: I expect that PR suggesting some improvements to the documentation would be very welcome - in particular, the section would almost certainly benefit from some examples. If that's something you'd feel comfortable doing, that would be great. There is an open docum

Re: [Python-Dev] Comparisions for collections.Counters

2018-09-05 Thread Serhiy Storchaka
05.09.18 13:10, Evpok Padding пише: According to the [doc][1], `collections.Counter` convenience intersection and union functions are meant to help it represent multisets. However, it currently lacks comparisons, which would make sense and seems straightforward to implement. Am I missing somet

Re: [Python-Dev] bpo-34595: How to format a type name?

2018-09-11 Thread Serhiy Storchaka
12.09.18 01:23, Victor Stinner пише: But then Petr Viktorin asked me to open a thread on python-dev to get a wider discussion. So here I am. Thank you for opening this discussion Victor. I wanted to do it myself, but you have wrote much better description of the problem. See also related issu

[Python-Dev] Stop automerging

2018-09-12 Thread Serhiy Storchaka
12.09.18 01:34, Miss Islington (bot) пише: https://github.com/python/cpython/commit/d13e59c1b512069d90efe7ee9b613d3913e79c56 commit: d13e59c1b512069d90efe7ee9b613d3913e79c56 branch: master author: Benjamin Peterson committer: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.co

Re: [Python-Dev] Arbitrary non-identifier string keys when using **kwargs

2018-10-04 Thread Serhiy Storchaka
04.10.18 11:56, Steven D'Aprano пише: While keyword arguments have to be identifiers, using **kwargs allows arbitrary strings which aren't identifiers: py> def spam(**kwargs): print(kwargs) py> spam(**{"something arbitrary": 1, '\n': 2}) {'something arbitrary': 1, '\n': 2} There

Re: [Python-Dev] Arbitrary non-identifier string keys when using **kwargs

2018-10-09 Thread Serhiy Storchaka
10.10.18 05:12, Benjamin Peterson пише: On Tue, Oct 9, 2018, at 17:14, Barry Warsaw wrote: On Oct 9, 2018, at 16:21, Steven D'Aprano wrote: On Tue, Oct 09, 2018 at 10:26:50AM -0700, Guido van Rossum wrote: My feeling is that limiting it to strings is fine, but checking those strings for rese

[Python-Dev] The future of the wchar_t cache

2018-10-20 Thread Serhiy Storchaka
Currently the PyUnicode object contains two caches: for UTF-8 representation and for wchar_t representation. They are needed not for optimization but for supporting C API which returns borrowed references for such representations. The UTF-8 cache always was in unicode objects (but in Python 2

Re: [Python-Dev] Some PRs to merge?

2018-10-20 Thread Serhiy Storchaka
20.10.18 04:08, Victor Stinner пише: Le ven. 19 oct. 2018 à 19:01, Stephane Wirtel a écrit : total: 49 PRs is:open is:pr review:approved status:success label:"awaiting merge" -label:"DO-NOT-MERGE" label:""LA signed"" I merged many PRs and closed a few (2 if I recall correctly). Your query no

Re: [Python-Dev] The future of the wchar_t cache

2018-10-22 Thread Serhiy Storchaka
20.10.18 16:01, Stefan Behnel пише: But regarding the use under Windows, I wonder if there's interest in keeping it as a special Windows-only feature, e.g. to speed up the data exchange with the Win32 APIs. I guess it would have to provide a visible (performance?) advantage to justify such specia

Re: [Python-Dev] The future of the wchar_t cache

2018-10-22 Thread Serhiy Storchaka
22.10.18 11:09, Victor Stinner пише: +1 to remove wchar_t cache. IMHO it wastes memory for no real performance gain. By the way, can we start to schedule the *removal* of the Py_UNICODE API? For example, decide when Py_DEPRECATED is used in the C API? Should we start to deprecate when Python 2 r

Re: [Python-Dev] The future of the wchar_t cache

2018-10-22 Thread Serhiy Storchaka
22.10.18 16:24, Steve Dower пише: Yes, that's true. But "should reduce ... footprint" is also an optimisation that deserves a benchmark by that standard. Also, I'm proposing keeping the 'kind' as UCS-2 when the string is created from UCS-2 data that is likely to be used as UCS-2. We would not c

Re: [Python-Dev] The future of the wchar_t cache

2018-10-23 Thread Serhiy Storchaka
22.10.18 23:41, Steve Dower пише: That said, I didn't remove the wchar_t cache (though I tried some tricks to avoid it), so it's possible that once that's gone we'll see an avoidable regression here, but on its own this doesn't contribute much. Could you please test PR 2599 on Windows? It make

[Python-Dev] Standardize error message for non-pickleable types

2018-10-29 Thread Serhiy Storchaka
When you try to to pickle or copy a non-pickleable object, you will get an error. In most cases this will be a TypeError with one of few similar, but different variants: "can't pickle XXX objects" (default) "Cannot serialize XXX object" (socket, BZ2Compressor, BZ2Decompressor) "can not se

Re: [Python-Dev] Standardize error message for non-pickleable types

2018-10-30 Thread Serhiy Storchaka
29.10.18 23:17, MRAB пише: 1. If you're pickling, then saying "pickle" is more helpful. 2. In English the usual long form is "cannot". Error messages tend to avoid abbreviations, and also tend to have lowercase after the colon, e.g.:     "ZeroDivisionError: division by zero"     "ValueErro

Re: [Python-Dev] Get a running instance of the doc for a PR.

2018-11-04 Thread Serhiy Storchaka
04.11.18 17:00, Julien Palard via Python-Dev пише: Considering feedback from Ned, what about building this as an independent service? We don't really need to interface with python.org at all, we just need some hardware, a domain, some code to interface with github API and... to start it's prob

Re: [Python-Dev] Signalling NANs

2018-11-09 Thread Serhiy Storchaka
09.11.18 13:05, Steven D'Aprano пише: py> x = cast_int2float(0x7ff1) py> x nan py> hex(cast_float2int(x)) '0x7ff80001' I got '0x7ff1'. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/l

Re: [Python-Dev] any way to subscribe to bugs and PRs on a particular topic?

2018-12-04 Thread Serhiy Storchaka
04.12.18 21:13, Chris Withers пише: I'd like to see if I can help with unittest.mock, but don't have a huge amount of bandwidth and can't even parse let alone process the whole firehose of bpo and GH PRs. Is there  any way I can get bugs.python.org and github PRs to only tell me about things,

Re: [Python-Dev] 3.7.2rc1 and 3.6.8rc1 cutoffs ahead, last 3.6.x bugfix release!

2018-12-19 Thread Serhiy Storchaka
04.12.18 10:42, Ned Deily пише: A reminder: as previously announced, 3.6.8 is planned to be the last bugfix release of the 3.6 series. Python 3.6.0 was released on 2016-12-23, so by the time 3.6.8 is released, 3.6.x will have been in bugfix mode almost exactly 2 years. When a new feature rele

Re: [Python-Dev] 3.7.2rc1 and 3.6.8rc1 cutoffs ahead, last 3.6.x bugfix release!

2018-12-19 Thread Serhiy Storchaka
19.12.18 19:01, Chris Barker - NOAA Federal via Python-Dev пише: 3.6 is the default Python in Ubuntu 18.04 LTS and RHEL 8. And due to several important syntax features it can be a minimal required version for long time. Which is a good argument for why we may not need longer term support for 3

Re: [Python-Dev] Compilation of "except FooExc as var" adds useless store

2019-01-06 Thread Serhiy Storchaka
06.01.19 13:10, Paul Sokolovsky пише: Storing None looks superfluous. For example, DELETE_FAST explicitly stores NULL on delete. https://github.com/python/cpython/blob/master/Python/ceval.c#L2249 Likewise, for DELETE_NAME/DELETE_GLOBAL, PyObject_DelItem() is called which translates to: m->mp_as

Re: [Python-Dev] Compilation of "except FooExc as var" adds useless store

2019-01-06 Thread Serhiy Storchaka
06.01.19 17:35, Chris Angelico пише: On Mon, Jan 7, 2019 at 2:27 AM Serhiy Storchaka wrote: Because there is a reason for such code. What reason though?? I added references and excerpts in the previous message. In short, the code try: 1/0 except Exception as e

Re: [Python-Dev] Compilation of "except FooExc as var" adds useless store

2019-01-06 Thread Serhiy Storchaka
06.01.19 18:05, Chris Angelico пише: Which I read, and they do not explain the assignment of None. The only reference is that the tracker issue mentions having a test case to ensure that it's happening, which is further proof that it's intentional, but still fails to explain *why*. This is expl

Re: [Python-Dev] VxWorks and cpython?

2019-01-10 Thread Serhiy Storchaka
10.01.19 18:54, Kuhl, Brian пише: The changes to Python are not large, I've kept the pull request from last year's POC active. The changed files provide a good summary of the scope. https://github.com/python/cpython/pull/4184/files To prepare this PR for review the following changes are requir

[Python-Dev] Lost sight

2019-01-19 Thread Serhiy Storchaka
I have virtually completely lost the sight of my right eye (and the loss is quickly progresses) and the sight of my left eye is weak. That is why my activity as a core developer was decreased significantly at recent time. My apologies to those who are waiting for my review. I will do it slowly.

Re: [Python-Dev] Lost sight

2019-01-21 Thread Serhiy Storchaka
Thank you very match, all who have expressed compassion here and privately. I am very touched. It at least helped me feel a little better psychologically. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/pytho

Re: [Python-Dev] Question - Bug Triage for 3.4 & 3.5

2019-02-20 Thread Serhiy Storchaka
20.02.19 17:01, Stephane Wirtel пише: As you know, Python 3.4 and 3.5 are in security mode and the EOL for these versions are respectively 2019-03-16 and 2020-09-13. Number of issues 3.4: 1530 issues 3.5: 1901 issues But some issues are not related to the security. Could we update these issue

Re: [Python-Dev] int() and math.trunc don't accept objects that only define __index__

2019-02-22 Thread Serhiy Storchaka
18.02.19 18:16, Rémi Lapeyre пише: The documentation mentions at https://docs.python.org/3/reference/datamodel.html#object.__index__ the need to always define both __index__ and __int__:     Note: In order to have a coherent integer type class, when __index__() is defined __int__() should als

[Python-Dev] Addendum to PEP 530

2019-03-04 Thread Serhiy Storchaka
PEP 530 introduced support for asynchronous comprehensions. Comprehensions are implemented as local functions. To make a function asynchronous you should to add "async" before "def", and after that you can use "async for", "async with" and "await" in a function. But you can to do this with com

Re: [Python-Dev] configparser: should optionxform be idempotent?

2019-03-07 Thread Serhiy Storchaka
07.03.19 11:18, Inada Naoki пише: So what should we do about optionxform? a) Document "optionxform must be idempotent". b) Ensure all APIs calls optionxform exactly once, and document "When you get option name from section objects, it is already optionxform-ed. You can not reuse the

Re: [Python-Dev] Is XML serialization output guaranteed to be bytewise identical forever?

2019-03-19 Thread Serhiy Storchaka
19.03.19 00:41, Raymond Hettinger пише: 3) Add a standards compliant canonicalization tool (see https://en.wikipedia.org/wiki/Canonical_XML ). This is likely to be the right-way-to-do-it but takes time and energy. 4) Fix the tests in the third-party modules to be more focused on their actual

Re: [Python-Dev] Is XML serialization output guaranteed to be bytewise identical forever?

2019-03-19 Thread Serhiy Storchaka
19.03.19 13:53, Ned Batchelder пише: Option 4 is misleading.  Is anyone here really offering to "fix the tests in third-party modules"?  Option 4 is actually, "do nothing, and let a multitude of projects figure out how to fix their tests, slowing progress in those projects as they try to suppor

Re: [Python-Dev] Is XML serialization output guaranteed to be bytewise identical forever?

2019-03-19 Thread Serhiy Storchaka
19.03.19 14:50, Antoine Pitrou пише: 2). Go into every XML module and add attribute sorting options to each function that generate xml. What do you mean with "every XML module"? Are there many of them? ElementTree and minidom. Maybe xmlrpc. And perhaps we need to add arguments in calls at h

Re: [Python-Dev] Is XML serialization output guaranteed to be bytewise identical forever?

2019-03-19 Thread Serhiy Storchaka
19.03.19 15:10, Tim Delaney пише: Now Calibre is definitely in the wrong here - it should be able to import regardless of the order of attributes. But the fact is that there are a lot of tools out there that are semi-broken in a similar manner. Is not Calibre going to seat on Python 2 forever?

Re: [Python-Dev] Remove tempfile.mktemp()

2019-03-19 Thread Serhiy Storchaka
19.03.19 15:03, Stéphane Wirtel пише: Suggestion and timeline: 3.8, we raise a PendingDeprecationWarning * update the code * update the documentation * update the tests (check a PendingDeprecationWarning if sys.version_info == 3.8) 3.9, we change PendingDeprecationWarning

Re: [Python-Dev] Best way to specify docstrings for member objects

2019-03-20 Thread Serhiy Storchaka
19.03.19 20:55, Raymond Hettinger пише: I'm working on ways to make improve help() by giving docstrings to member objects. One way to do it is to wait until after the class definition and then make individual, direct assignments to __doc__ attributes.This way widely the separates docstrings f

Re: [Python-Dev] Remove tempfile.mktemp()

2019-03-20 Thread Serhiy Storchaka
19.03.19 16:21, Paul Ganssle пише: I'm not sure the relationship with mkdir and mktemp here. I don't see any uses of tempfile.mktemp in pip or setuptools, though they do use os.mkdir (which is not deprecated). Both pip and setuptools use pytest's tmpdir_factory.mktemp() in their test suites, but

Re: [Python-Dev] Remove tempfile.mktemp()

2019-03-20 Thread Serhiy Storchaka
19.03.19 15:39, Antoine Pitrou пише: The fact that many projects, including well-maintained ones such Sphinx or pip, use mktemp(), may be a hint that replacing it is not as easy as the people writing the Python documentation seem to think. Sorry, it was my mistake (searching mkdir instead of mk

Re: [Python-Dev] Removing PendingDeprecationWarning

2019-03-22 Thread Serhiy Storchaka
22.03.19 04:41, Inada Naoki пише: I'm thinking about removing PendingDeprecationWarning. (previous discussion: https://discuss.python.org/t/pendingdeprecationwarning-is-really-useful/1038) It was added "not be printed by default" version of DeprecationWarning. But DeprecationWarning is not print

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Serhiy Storchaka
22.03.19 09:31, Greg Ewing пише: A poster on comp.lang.python is asking about array.array('u'). He wants an efficient mutable collection of unicode characters that can be initialised from a string. According to the docs, the 'u' code is deprecated and will be removed in 4.0, but no alternative i

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Serhiy Storchaka
22.03.19 09:45, Victor Stinner пише: Internally, CPython has a _PyUnicodeWriter which is an efficient way to create a string but appending substrings or characters. _PyUnicodeWriter changes the internal storage format depending on characters code points (ascii or latin1: 1 byte/character, BMP: 2

Re: [Python-Dev] Removing PendingDeprecationWarning

2019-03-22 Thread Serhiy Storchaka
22.03.19 12:51, Jeroen Demeyer пише: On 2019-03-22 11:33, Serhiy Storchaka wrote: What is wrong with PendingDeprecationWarning? It serves the same purpose as DeprecationWarning: it indicates that a feature is planned to be removed in the future. There is no point in having two warnings with

Re: [Python-Dev] Removing PendingDeprecationWarning

2019-03-22 Thread Serhiy Storchaka
22.03.19 13:23, Inada Naoki пише: On Fri, Mar 22, 2019 at 7:36 PM Serhiy Storchaka wrote: What is wrong with PendingDeprecationWarning? What problem do you want to solve at the cost of removing this feature? The main problem is complexity. In other words, learning cost. Do you have

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Serhiy Storchaka
22.03.19 13:33, Antoine Pitrou пише: On Fri, 22 Mar 2019 13:27:08 +0200 Serhiy Storchaka wrote: Making it always 32 bits would be compatibility breaking change. Currently array('u') represents the wchar_t string, and many API on Windows require it. The question is: why would

Re: [Python-Dev] Deprecating "instance method" class

2019-04-05 Thread Serhiy Storchaka
05.04.19 09:07, Jeroen Demeyer пише: On 2019-04-05 00:57, Greg Ewing wrote: If it's designed for use by things outside of CPython, how can you be sure nothing is using it? Of course I'm not sure. However: 1. So far, nobody in this thread knows of any code using it. 2. So far, nobody in this

Re: [Python-Dev] Deprecating "instance method" class

2019-04-05 Thread Serhiy Storchaka
05.04.19 14:27, Jeroen Demeyer пише: On 2019-04-05 14:10, Serhiy Storchaka wrote: it can be used to implement accelerated versions of separate methods instead of the whole class. Could you elaborate? I'm curious what you mean. It is easy to implement a function in C. But there

Re: [Python-Dev] Deprecating "instance method" class

2019-04-05 Thread Serhiy Storchaka
05.04.19 15:33, Jeroen Demeyer пише: On 2019-04-05 15:13, Serhiy Storchaka wrote: It is easy to implement a function in C. Why does it need to be a PyCFunction? You could put an actual method descriptor in the class. In other words, use PyDescr_NewMethod() instead of PyCFunction_New

Re: [Python-Dev] Deprecating "instance method" class

2019-04-06 Thread Serhiy Storchaka
05.04.19 20:56, Jeroen Demeyer пише: On 2019-04-05 19:53, Serhiy Storchaka wrote: At Python level we can monkeypatch __gt__, but not tp_richcompare. Sure, but you're planning to use C anyway so that's not really an argument. total_ordering monkeypatches the decorated class. I

Re: [Python-Dev] No longer enable Py_TRACE_REFS by default in debug build

2019-04-10 Thread Serhiy Storchaka
10.04.19 14:01, Victor Stinner пише: Disabling Py_TRACE_REFS by default in debug mode reduces the Python memory footprint. Py_TRACE_REFS costs 2 pointers per PyObject: 16 bytes on 64-bit platforms. Does not the memory allocator in debug mode have even larger cost per allocated block? ___

Re: [Python-Dev] No longer enable Py_TRACE_REFS by default in debug build

2019-04-11 Thread Serhiy Storchaka
11.04.19 12:28, Victor Stinner пише: Le jeu. 11 avr. 2019 à 07:49, Serhiy Storchaka a écrit : 10.04.19 14:01, Victor Stinner пише: Disabling Py_TRACE_REFS by default in debug mode reduces the Python memory footprint. Py_TRACE_REFS costs 2 pointers per PyObject: 16 bytes on 64-bit platforms

Re: [Python-Dev] No longer enable Py_TRACE_REFS by default in debug build

2019-04-12 Thread Serhiy Storchaka
12.04.19 17:40, Guido van Rossum пише: So let's leave it off by default even in debug builds. But let's not delete the macros. Maybe switch it on (together with other disabled by default options) on some fast buildbot? ___ Python-Dev mailing list P

Re: [Python-Dev] Proposal: dict.with_values(iterable)

2019-04-12 Thread Serhiy Storchaka
12.04.19 16:44, Inada Naoki пише: When creating many dicts with same keys, dict need to lookup internal hash table while inserting each keys. It is costful operation. If we can reuse existing keys of dict, we can skip this inserting cost. Additionally, we have "Key-Sharing Dictionary (PEP 412)

Re: [Python-Dev] Proposal: dict.with_values(iterable)

2019-04-23 Thread Serhiy Storchaka
12.04.19 19:17, Inada Naoki пише: Maybe, collections.DictBuilder may be another option. e.g. from collections import DictBuilder builder = DictBuilder(tuple("abc")) builder.build(range(3)) {"a": 0, "b": 1, "c": 2} Nitpicking: this is rather a factory than a builder. The difference between

Re: [Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files

2019-04-30 Thread Serhiy Storchaka
01.05.19 00:24, Chris Withers пише: I have a crazy idea of getting unittest.mock up to 100% code coverage. I noticed at the bottom of all of the test files in testmock/, there's a: if __name__ == '__main__':     unittest.main() ...block. How would people feel about these going away? I don't

Re: [Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files

2019-05-01 Thread Serhiy Storchaka
01.05.19 10:09, Chris Withers пише: Right, but that's not the documented way of running individual suites in the devguide. I'm happy to remove these on the basis that there should be one and only one way of doing things like this. This principle is not applicable here because the Python test

Re: [Python-Dev] Unicode identifiers in test files?

2019-05-03 Thread Serhiy Storchaka
04.05.19 05:46, Eric V. Smith пише: Is there a policy against using Unicode identifiers in test files? As part of adding !d to f-strings, there's a code path that's only executed if the text of the expression is non-ascii. The easiest way to exercise it, and the way I found a bug, is by using

Re: [Python-Dev] bpo-36829: Add sys.unraisablehook()

2019-05-15 Thread Serhiy Storchaka
16.05.19 04:23, Victor Stinner пише: The first implementation of my API used sys.unraisablehook(exc_type, exc_value, exc_tb, obj). The problem is that Serhiy Storchaka asked me to add a new error message field which breaks the API: the API is not future-proof. I modified my API to create an

Re: [Python-Dev] bpo-36829: Add sys.unraisablehook()

2019-05-16 Thread Serhiy Storchaka
16.05.19 13:12, Victor Stinner пише: I came to the UnraisableHookArgs structseq idea because of my bad experience with extension warnings "hooks". Let me tell you this story :-) I know this story, because I followed these issues. For unraisable hook, it's not hard to imagine other useful para

Re: [Python-Dev] ast changes for "debug" f-strings

2019-05-20 Thread Serhiy Storchaka
20.05.19 16:25, Eric V. Smith пише: I added an optional "expr_text" field to the FormattedValue node, which represents the text of the expression in a "debug" f-string expression. So in f'{x=}', expr_text would be "x=". This strictly speaking isn't necessary. I could have added another Consta

Re: [Python-Dev] Expected stability of PyCode_New() and types.CodeType() signatures

2019-06-01 Thread Serhiy Storchaka
31.05.19 11:46, Petr Viktorin пише: PEP 570 (Positional-Only Parameters) changed the signatures of PyCode_New() and types.CodeType(), adding a new argument for "posargcount". Our policy for such changes seems to be fragmented tribal knowledge. I'm writing to check if my understanding is reasonab

[Python-Dev] Re: python-ideas and python-dev migrated to Mailman 3/HyperKitty

2019-06-05 Thread Serhiy Storchaka
05.06.19 12:08, Victor Stinner пише: Our kind postmasters Mark Sapiro and Abhilash Raj migrated python-ideas and python-dev mailing lists from Mailman 2 to Mailman 3 (running on Python 3 ;-))! You can now enjoy HyperKitty, the new web UI to access the mailing lists: https://mail.python.org/a

[Python-Dev] Re: python-ideas and python-dev migrated to Mailman 3/HyperKitty

2019-06-05 Thread Serhiy Storchaka
05.06.19 13:52, Serhiy Storchaka пише: 05.06.19 12:08, Victor Stinner пише: Our kind postmasters Mark Sapiro and Abhilash Raj migrated python-ideas and python-dev mailing lists from Mailman 2 to Mailman 3 (running on Python 3 ;-))! You can now enjoy HyperKitty, the new web UI to access the

[Python-Dev] Re: _Py_Identifier should support non-ASCII string?

2019-06-21 Thread Serhiy Storchaka
20.06.19 19:28, Victor Stinner пише: Le jeu. 20 juin 2019 à 11:15, Inada Naoki a écrit : Can we change _PyUnicode_FromId to use _PyUnicode_FromASCII? How would a developer detect a mistake (non-ASCII) character? Does _PyUnicode_FromASCII() raise an exception, even in release mode? The functi

[Python-Dev] Re: python3 -bb and hash collisions

2019-06-21 Thread Serhiy Storchaka
22.06.19 01:08, Daniel Holth пише: Thanks. I think I might like an option to disable str(bytes) without disabling str != bytes. Unless the second operation would also corrupt output. Came across this kind of set in the hyper http library which uses a set to accept certain headers with either

[Python-Dev] What is a public API?

2019-07-13 Thread Serhiy Storchaka
I thought that the name in a module is in the public interface if: * It doesn't start with an underscore and the module does not have __all__. * It is included in the module's __all__ list. * It is explicitly documented as a part of the public interface. help() uses more complex rules, but it be

[Python-Dev] Re: What is a public API?

2019-07-20 Thread Serhiy Storchaka
14.07.19 05:09, Raymond Hettinger пише: On Jul 13, 2019, at 1:56 PM, Serhiy Storchaka wrote: Could we strictly define what is considered a public module interface in Python? The RealDefinition™ is that whatever we include in the docs is public, otherwise not. Beyond that, there is a

[Python-Dev] Re: What is a public API?

2019-07-20 Thread Serhiy Storchaka
17.07.19 03:26, Brett Cannon пише: I agree with Raymond that if the calendar module was following the leading underscore practice (which we should probably encourage all new modules to follow for consistency going forward) then I think the module should be updated to keep the practice going.

[Python-Dev] The order of operands in the comparison

2019-07-20 Thread Serhiy Storchaka
Usually the order of operands of the == operator does not matter. bool(a == b) should return the same as bool(b == a). Correct __eq__ should look like: def __eq__(self, other): if not know how to compare with other: return NotImplemented return the result of comp

[Python-Dev] Re: What is a public API?

2019-07-20 Thread Serhiy Storchaka
20.07.19 09:03, Kyle Stanley пише: Rather than it being on a case-by-case basis, would it be reasonable to establish a universal standard across stdlib for defining modules as public to apply to older modules as well? I think that it would prove to be quite beneficial to create an explicit def

[Python-Dev] Re: The order of operands in the comparison

2019-07-22 Thread Serhiy Storchaka
20.07.19 18:26, Guido van Rossum пише: In an ideal world, needle is on the right. Let's replace needle with a constant: which of the following looks more natural?   for x in sequence:   if x == 5: return True or   for x in sequence:   if 5 == x: return True For me, 'x == 5' wins

[Python-Dev] Re: The order of operands in the comparison

2019-07-22 Thread Serhiy Storchaka
22.07.19 11:04, Kyle Stanley пише: Serhiy Storchaka wrote: Thank you. The majority of the code uses needle on the right. There are just 6 places where it is on the left, and the half of them look copy-pasted, and in one place the C code differs from the corresponding Python implementation

[Python-Dev] Re: Comparing dict.values()

2019-07-23 Thread Serhiy Storchaka
23.07.19 23:59, Kristian Klette пише: During the sprints after EuroPython, I made an attempt at adding support for comparing the results from `.values()` of two dicts. Currently the following works as expected: ``` d = {'a': 1234} d.keys() == d.keys() d.items() == d.items() ``` but `d.values(

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