Re: [Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure

2013-07-16 Thread Serhiy Storchaka
17.07.13 00:09, victor.stinner написав(ла): http://hg.python.org/cpython/rev/533eb9ab895a changeset: 84669:533eb9ab895a user:Victor Stinner date:Tue Jul 16 21:36:02 2013 +0200 summary: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure bytes is NULL on _PyBytes_Re

Re: [Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure

2013-07-16 Thread Serhiy Storchaka
17.07.13 01:03, Victor Stinner написав(ла): 2013/7/16 Serhiy Storchaka : http://hg.python.org/cpython/rev/533eb9ab895a summary: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure bytes is NULL on _PyBytes_Resize() failure Why not Py_DECREF? Because Py_DECREF(NULL) does crash

Re: [Python-Dev] Misc re.match() complaint

2013-07-17 Thread Serhiy Storchaka
16.07.13 20:21, Guido van Rossum написав(ла): The situation is most egregious if the target string is a bytearray, where there is currently no way to get the result as an immutable bytes object without an extra copy. (There's no API that lets you create a bytes object directly from a slice of a b

[Python-Dev] Dash

2013-07-18 Thread Serhiy Storchaka
What type of dash is preferable in the documentation? The en dash (–) or the em dash (—)? ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-d

Re: [Python-Dev] Dash

2013-07-18 Thread Serhiy Storchaka
18.07.13 20:48, Guido van Rossum написав(ла): I believe there are only a few places where en-dashes should be used, for most things you should use either em-dash or hyphen. Consult your trusted typography source (for US English, please, punctuation preferences vary by locale). E.g. Google for "em

Re: [Python-Dev] Dash

2013-07-19 Thread Serhiy Storchaka
18.07.13 21:54, Brian Curtin написав(ла): Besides visual consistency in a couple of places, is there a reason to care enough to make a wholesale change? Single hyphen instead of a dash just looks too ugly to me. Trying to fix this I noticed that the documentation is inconsistent regarding the

Re: [Python-Dev] Dash

2013-07-19 Thread Serhiy Storchaka
18.07.13 21:55, Guido van Rossum написав(ла): On Thu, Jul 18, 2013 at 11:46 AM, Serhiy Storchaka wrote: Or we should replace a half-dozen of em-dashes found in Python documentation to en-dashes? If my theory is right that makes sense. Especially if it's only a half-dozen. I'm sor

Re: [Python-Dev] Dash

2013-07-19 Thread Serhiy Storchaka
19.07.13 00:49, Ezio Melotti написав(ла): On Thu, Jul 18, 2013 at 7:38 PM, Serhiy Storchaka wrote: What type of dash is preferable in the documentation? The en dash (–) or the em dash (—)? Both should be used where appropriate [0]. Of course I looked in Wikipedia before asking on this

Re: [Python-Dev] Dash

2013-07-19 Thread Serhiy Storchaka
19.07.13 10:25, Ben Finney написав(ла): Serhiy Storchaka writes: What type of dash is preferable in the documentation? The en dash (–) or the em dash (—)? They have different purposes; use whichever is appropriate for the context. I mean only a context where a dash is used to denote a

Re: [Python-Dev] Dash

2013-07-19 Thread Serhiy Storchaka
19.07.13 07:51, Steven D'Aprano написав(ла): Optimistically, I think it would probably be safe[1] to replace " -- " or " --- " in text with "\N{THIN SPACE}\N{EM DASH}\N{THIN SPACE}" (or \N{HAIR SPACE} if you prefer) without human review, but for any other changes, I wouldn't even try to automate

Re: [Python-Dev] Dash

2013-07-20 Thread Serhiy Storchaka
19.07.13 22:32, Ben Finney написав(ла): Serhiy Storchaka writes: I'm asking only about this case, when the dash is used to denote a break in a sentence or to set off parenthetical statements. That's two separate cases: * denote a break in a sentence * set off parenthetical state

Re: [Python-Dev] cpython: Use strncat() instead of strcat() to silence some warnings.

2013-07-20 Thread Serhiy Storchaka
20.07.13 15:12, christian.heimes написав(ла): http://hg.python.org/cpython/rev/c92f4172d122 changeset: 84723:c92f4172d122 user:Christian Heimes date:Sat Jul 20 14:11:28 2013 +0200 summary: Use strncat() instead of strcat() to silence some warnings. CID 486616, CID 486617, CI

Re: [Python-Dev] cpython: Use strncat() instead of strcat() to silence some warnings.

2013-07-20 Thread Serhiy Storchaka
20.07.13 15:36, Antoine Pitrou написав(ла): On Sat, 20 Jul 2013 15:23:46 +0300 Serhiy Storchaka wrote: 20.07.13 15:12, christian.heimes написав(ла): http://hg.python.org/cpython/rev/c92f4172d122 changeset: 84723:c92f4172d122 user:Christian Heimes date:Sat Jul 20 14:11:28

Re: [Python-Dev] cpython: Use strncat() instead of strcat() to silence some warnings.

2013-07-20 Thread Serhiy Storchaka
20.07.13 16:27, Christian Heimes написав(ла): This will wrong when strlen(fname) is 30. strncat() will copy only 30 bytes, without terminal NUL. That's not how strncat() works. strncat(dest, src, n) writes n+1 chars to the end of dest: n chars from src and +1 for the final NUL char. For this re

Re: [Python-Dev] Dash

2013-07-22 Thread Serhiy Storchaka
I have opened an issue (http://bugs.python.org/issue18529) for patches. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-a

[Python-Dev] Reaping threads and subprocesses

2013-08-11 Thread Serhiy Storchaka
Some tests uses the following idiom: def test_main(): try: test.support.run_unittest(...) finally: test.support.reap_children() Other tests uses the following idiom: def test_main(): key = test.support.threading_setup() try: test.support.run_unittest(...)

Re: [Python-Dev] Deprecating the formatter module

2013-08-13 Thread Serhiy Storchaka
12.08.13 22:22, Brett Cannon написав(ла): I have created http://bugs.python.org/issue18716 to deprecate the formatter module for removal in Python 3.6 unless someone convinces me otherwise that deprecation and removal is the wrong move. The formatter module doesn't look such buggy as the audioo

[Python-Dev] format and int subclasses (Was: format, int, and IntEnum)

2013-08-14 Thread Serhiy Storchaka
15.08.13 01:07, Ethan Furman написав(ла): From http://bugs.python.org/issue18738: Actually the problem not only in IntEnum, but in any in subclass. Currently for empty format specifier int.__format__(x, '') returns str(x). But __str__ can be overloaded in a subclass. I think that for less s

Re: [Python-Dev] format and int subclasses (Was: format, int, and IntEnum)

2013-08-15 Thread Serhiy Storchaka
15.08.13 06:23, Eli Bendersky написав(ла): Yes, the problem here is certainly not IntEnum - specific; it's just that IntEnum is the first "for real" use case of subclassing 'int' in the stdlib. Even not the first. >> '{}'.format(True) 'True' >>> '{:10}'.format(True) ' 1'

Re: [Python-Dev] cpython: Cleanup test_builtin

2013-08-22 Thread Serhiy Storchaka
22.08.13 02:59, victor.stinner написав(ла): http://hg.python.org/cpython/rev/0a1e1b929665 changeset: 85308:0a1e1b929665 user:Victor Stinner date:Thu Aug 22 01:58:12 2013 +0200 summary: Cleanup test_builtin files: Lib/test/test_builtin.py | 16 1 files

Re: [Python-Dev] cpython: Cleanup test_builtin

2013-08-22 Thread Serhiy Storchaka
22.08.13 14:48, Victor Stinner написав(ла): You forgot self.addCleanup(unlink, TESTFN) (here and in other places). These functions call write_testfile() which creates the file but also schedules its removal when the test is done (since my changeset): def write_testfile(self): # N

Re: [Python-Dev] Test the test suite?

2013-08-28 Thread Serhiy Storchaka
28.08.13 14:37, Victor Stinner написав(ла): No, my question is: how can we detect that a test is never run? Do we need test covertage on the test suite? Or inject faults in the code to test the test suite? Any other idea? Currently a lot of tests are skipped silently. See issue18702 [1]. Perha

Re: [Python-Dev] PEP 450 adding statistics module

2013-09-09 Thread Serhiy Storchaka
08.09.13 20:52, Guido van Rossum написав(ла): Well, to me zip(*x) is unnatural, and it's inefficient when the arrays are long. Perhaps we need zip.from_iterable()? ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/lis

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
There is a question about specifying the transform function. There are three ways to do this: 1. Positional argument of the constructor. d = TransformDict(str.casefold, Foo=5) 2. Subclassing. class CaseInsensitiveDict(TransformDict): def transform(self, key): return key.casefold()

[Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
I work on enhancement of audio modules testing [1], and I need free (in both senses) small sample audio files in different formats. We already have audiotest.au (mono, and sunau has a bug in processing multichannel files [2]) and Sine-1000Hz-300ms.aif, but this is not enough. I have generated a

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
11.09.13 12:52, Antoine Pitrou написав(ла): Le Wed, 11 Sep 2013 12:38:13 +0300, Serhiy Storchaka a écrit : 2. Subclassing. class CaseInsensitiveDict(TransformDict): def transform(self, key): return key.casefold() d = CaseInsensitiveDict(Foo=5) I thought about this first, and

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
11.09.13 14:07, Antoine Pitrou написав(ла): But I don't think the "type generator" API would be easier to implement in C, anyway. No, I mean subclassing approach. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/list

Re: [Python-Dev] Add a "transformdict" to collections

2013-09-11 Thread Serhiy Storchaka
11.09.13 16:50, Stephen J. Turnbull написав(ла): Which modules in the stdlib would benefit from rewriting using "transformdict"? How about on PyPI? At least _threading_local, cProfile, doctest, json, and perhaps future implementations of __sizeof__ for some classes would benefit from rewriti

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 15:45, Antoine Pitrou написав(ла): If you want to edit, shorten, convert sounds between different formats, you can try Audacity, a free sound editor: http://audacity.sourceforge.net/ Yes, Audacity is great. ___ Python-Dev mailing list Pytho

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 15:46, Victor Stinner написав(ла): Use your microphone, say "python" and save the file in your favorite file format. Try for example Audacity. I suppose that you don't need specific audio content and you don't need a huge file. My voice is even more ugly than my English. I don't want p

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 17:10, Oleg Broytman написав(ла): Wouldn't his name be enough? http://www.python.org/~guido/guido.au It is Lib/test/audiotest.au. 1-channel and 8-bit. No, it wouldn't enough. ___ Python-Dev mailing list Python-Dev@python.org https://mai

Re: [Python-Dev] Need testing audio files

2013-09-11 Thread Serhiy Storchaka
11.09.13 17:10, Barry Warsaw написав(ла): I have some pro-audio recording capabilities and would be happy to generate some copyright-donated clips for Python. Please contact me off-list if needed. Thank you. ___ Python-Dev mailing list Python-Dev@p

Re: [Python-Dev] PEP 455: TransformDict

2013-09-13 Thread Serhiy Storchaka
13.09.13 21:40, Antoine Pitrou написав(ла): Both are instances of a more general pattern, where a given transformation function is applied to keys when looking them up: that function being ``str.lower`` in the former example and the built-in ``id`` function in the latter. Please use str.casefol

Re: [Python-Dev] PEP 455: TransformDict

2013-09-13 Thread Serhiy Storchaka
13.09.13 21:40, Antoine Pitrou написав(ла): Alternative proposals and questions === Yet one alternative proposal is to add the dict.__transform__() method. Actually this not contradict TransformDict, but generalize it. TransformDict will be just handly interfac

Re: [Python-Dev] PEP 455: TransformDict

2013-09-13 Thread Serhiy Storchaka
13.09.13 23:02, Antoine Pitrou написав(ла): On Fri, 13 Sep 2013 16:54:01 -0300 "Joao S. O. Bueno" wrote: I see the PEP does not contemplate a way to retrieve the original key - like we've talked about somewhere along the thread. Indeed. If that's important I can add it. I was hoping to keep v

Re: [Python-Dev] PEP 455: TransformDict

2013-09-13 Thread Serhiy Storchaka
13.09.13 22:37, Antoine Pitrou написав(ла): That's true. But it's only important if TransformDict is the bottleneck. I doubt the memoizing dictionary is a bottleneck in e.g. the pure Python implementation of pickle or json. It can be used in the C implementation. _

Re: [Python-Dev] PEP 455: TransformDict

2013-09-13 Thread Serhiy Storchaka
13.09.13 23:21, Antoine Pitrou написав(ла): On Fri, 13 Sep 2013 23:16:10 +0300 Serhiy Storchaka wrote: 13.09.13 21:40, Antoine Pitrou написав(ла): Alternative proposals and questions === Yet one alternative proposal is to add the dict.__transform__() method

Re: [Python-Dev] PEP 455: TransformDict

2013-09-14 Thread Serhiy Storchaka
14.09.13 20:41, Antoine Pitrou написав(ла): On Sat, 14 Sep 2013 09:43:13 -0700 Ethan Furman wrote: Still, I think it would be useful to expose the transform function. Any good reason not to? No good reason. What's the name? transform_func? There is one reason -- serialization. For example p

Re: [Python-Dev] PEP 455: TransformDict

2013-09-14 Thread Serhiy Storchaka
14.09.13 20:41, Antoine Pitrou написав(ла): No good reason. What's the name? transform_func? transform_func looks... truncated. Why not transform_function or trans_func? ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailma

Re: [Python-Dev] PEP 455: TransformDict

2013-09-14 Thread Serhiy Storchaka
15.09.13 00:58, Antoine Pitrou написав(ла): On Sun, 15 Sep 2013 00:55:35 +0300 Serhiy Storchaka wrote: 14.09.13 20:41, Antoine Pitrou написав(ла): No good reason. What's the name? transform_func? transform_func looks... truncated. Why not transform_function or trans_func? The s

Re: [Python-Dev] PEP 455: TransformDict

2013-09-15 Thread Serhiy Storchaka
15.09.13 14:23, Antoine Pitrou написав(ла): On Sun, 15 Sep 2013 13:56:26 +0900 Larry Hastings wrote: On 09/14/2013 07:30 PM, Antoine Pitrou wrote: On Sat, 14 Sep 2013 14:33:56 +0900 Larry Hastings wrote: Whenever I read a discussion about the dict, I always wonder whether the same thing appl

Re: [Python-Dev] PEP 455: TransformDict

2013-09-15 Thread Serhiy Storchaka
15.09.13 16:57, Antoine Pitrou написав(ла): I don't really care. What's the point in the end? TransformDict is non-trivial to implement, while the so-called "TransformSet" is just a dict with a different API. I don't see a difference. To me TransformDict is just a dict (or two). _

Re: [Python-Dev] cpython: Use cached builtins.

2013-10-02 Thread Serhiy Storchaka
02.10.13 20:31, Antoine Pitrou написав(ла): On Wed, 2 Oct 2013 18:16:48 +0200 (CEST) serhiy.storchaka wrote: http://hg.python.org/cpython/rev/d48ac94e365f changeset: 85931:d48ac94e365f user:Serhiy Storchaka date:Wed Oct 02 19:15:54 2013 +0300 summary: Use cached builtins

[Python-Dev] PEP 456

2013-10-03 Thread Serhiy Storchaka
Just some comments. > the first time time with a bit shift of 7 Double "time". > with a 128bit seed and 64-bit output Inconsistancy with hyphen. There are same issues in other places. > bytes_hash provides the tp_hash slot function for unicode. Typo. Should be "unicode_hash". > len = PyUnic

Re: [Python-Dev] Make str/bytes hash algorithm pluggable?

2013-10-03 Thread Serhiy Storchaka
03.10.13 23:47, Guido van Rossum написав(ла): On Thu, Oct 3, 2013 at 12:55 PM, Christian Heimes mailto:christ...@python.org>> wrote: Am 03.10.2013 21:45, schrieb Guido van Rossum: > But fixing that shouldn't need all the extra stuff you're > proposing. I have proposed some of

[Python-Dev] Optimization

2013-10-05 Thread Serhiy Storchaka
Please remember me, what was common decision about CPython-only optimizations which change computation complexity? I.g. constant amortization time of += for byte objects and strings, or linear time of sum() for sequences? ___ Python-Dev mailing list

Re: [Python-Dev] Optimization

2013-10-05 Thread Serhiy Storchaka
05.10.13 23:11, Georg Brandl написав(ла): Am 05.10.2013 21:42, schrieb Serhiy Storchaka: Please remember me, what was common decision about CPython-only optimizations which change computation complexity? I.g. constant amortization time of += for byte objects and strings, or linear time of sum

Re: [Python-Dev] PEP 455: TransformDict

2013-10-05 Thread Serhiy Storchaka
06.10.13 00:08, Victor Stinner написав(ла): 2013/10/4 Raymond Hettinger >: > This contrasts with other tools like OrderedDict, ChainMap, > and namedtuple which started their lives outside the standard > library where we we able observe their fitness for real problems > being solved by real us

Re: [Python-Dev] Optimization

2013-10-05 Thread Serhiy Storchaka
06.10.13 00:06, Victor Stinner написав(ла): The str type is immutable, bytearray is not. It's easier to justify optimisations on mutable types, like overallocate lists for example. We can resize str or bytes if its refcount is 1. And resize is cheap in some circumstances. This optimization is

Re: [Python-Dev] Optimization

2013-10-05 Thread Serhiy Storchaka
06.10.13 02:37, Antoine Pitrou написав(ла): It's only strange because you don't understand the main use case for bytearrays. They may look like arrays of 8-bit integers but they are really used for buffers, so optimizing for stuff like FIFO operation makes sense. Could you please provide severa

Re: [Python-Dev] [Python-checkins] cpython (3.3): PythonCAD is now on PyQt, use Wing as a prominent PyGtk example.

2013-10-07 Thread Serhiy Storchaka
07.10.13 16:54, A.M. Kuchling написав(ла): On Mon, Oct 07, 2013 at 12:13:18AM +0100, Michael Foord wrote: Wing is only a good example of PyGtk until Wing 5 is out of beta. They too have switched to PyQt... Perhaps Gramps is a good example: http://www.gramps-project.org/ I just glanced at their

Re: [Python-Dev] Python startup time

2013-10-10 Thread Serhiy Storchaka
10.10.13 15:25, Christian Heimes написав(ла): Benchmark of 1000 times "python -c ''" What about "python -S -c ''"? ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.pytho

Re: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().

2013-10-11 Thread Serhiy Storchaka
11.10.13 13:33, Eric V. Smith написав(ла): And Antoine has again taught me a new word: polysemic: having more than one meaning; having multiple meanings There is no such word in my dictionaries. :( Only polysemous and polysemantic. ___ Python-Dev m

Re: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().

2013-10-11 Thread Serhiy Storchaka
11.10.13 10:24, Antoine Pitrou написав(ла): Ezio was -1 on the tracker, and Eric Smith was -0. I'd like to add my -1 too. This is a useless addition (the traditional idiom is perfectly obvious) and makes reading foreign code more tedious by adding superfluous API calls. I am -1 too. But I want

Re: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().

2013-10-11 Thread Serhiy Storchaka
11.10.13 21:41, Glenn Linderman написав(ла): Seriously, "with" is the wrong spelling for this using. It should be while ignorning(FileNotFoundError) We need extended bool for while condition: http://thedailywtf.com/Articles/What_Is_Truth_0x3f_.aspx __

Re: [Python-Dev] Support for marking limited API elements in C API docs

2013-10-12 Thread Serhiy Storchaka
12.10.13 21:04, Georg Brandl написав(ла): in light of the recent thread about PEPs not forming part of the docs, I've just pushed a change that allows to document C API elements not part of the limited API as such. It is done like this: ... c:function:: int _PyTuple_Resize(PyObject **p, Py_ssiz

Re: [Python-Dev] Support for marking limited API elements in C API docs

2013-10-12 Thread Serhiy Storchaka
12.10.13 22:19, Georg Brandl написав(ла): Am 12.10.2013 20:20, schrieb Serhiy Storchaka: 12.10.13 21:04, Georg Brandl написав(ла): in light of the recent thread about PEPs not forming part of the docs, I've just pushed a change that allows to document C API elements not part of the limite

Re: [Python-Dev] Support for marking limited API elements in C API docs

2013-10-12 Thread Serhiy Storchaka
12.10.13 22:56, Antoine Pitrou написав(ла): On Sat, 12 Oct 2013 21:19:16 +0200 Georg Brandl wrote: Am 12.10.2013 20:20, schrieb Serhiy Storchaka: 12.10.13 21:04, Georg Brandl написав(ла): in light of the recent thread about PEPs not forming part of the docs, I've just pushed a change

Re: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().

2013-10-13 Thread Serhiy Storchaka
13.10.13 15:50, Nick Coghlan написав(ла): On 13 October 2013 22:34, Antoine Pitrou wrote: There's actually more typing involved, and one more API to know about... It is just another case of those "one-liners" that we generally refrain from adding to the stdlib. It meets my threshold for inclu

Re: [Python-Dev] Right place for PBKDF2 wrapper

2013-10-14 Thread Serhiy Storchaka
13.10.13 13:39, Christian Heimes написав(ла): Am 13.10.2013 08:32, schrieb Nick Coghlan: +1 to hashlib from me (especially since we used that as the best available home for compare_digest). I'm afraid your memory doesn't serve you well. :( compare_digest is implemented in _operator.c. Its offi

Re: [Python-Dev] Right place for PBKDF2 wrapper

2013-10-14 Thread Serhiy Storchaka
14.10.13 13:07, Antoine Pitrou написав(ла): Le Mon, 14 Oct 2013 12:47:03 +0300, Serhiy Storchaka a écrit : 13.10.13 13:39, Christian Heimes написав(ла): Am 13.10.2013 08:32, schrieb Nick Coghlan: +1 to hashlib from me (especially since we used that as the best available home for

Re: [Python-Dev] Checking in Argument Clinic early?

2013-10-15 Thread Serhiy Storchaka
15.10.13 15:55, Larry Hastings написав(ла): So, quick poll: do you approve of me checking Argument Clinic in to Python 3.4 trunk in its current state before 3.4a4? Could you get us a week for preliminary review before checking? I remember I proposed a little different syntax and I don't know w

Re: [Python-Dev] PEP: Ordered Class Definition Namespace

2016-06-07 Thread Serhiy Storchaka
On 07.06.16 20:51, Eric Snow wrote: Hi all, Following discussion a few years back (and rough approval from Guido [1]), I started work on using OrderedDict for the class definition namespace by default. The bulk of the effort lay in implementing OrderedDict in C, which I got landed just in time

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Serhiy Storchaka
On 07.06.16 23:28, Ethan Furman wrote: Minor changes: updated version numbers, add punctuation. The current text seems to take into account Guido's last comments. Thoughts before asking for acceptance? PEP: 467 Title: Minor API improvements for binary sequences Version: $Revision$ Last-Modi

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 11:04, Victor Stinner wrote: Currently, the ``bytes`` and ``bytearray`` constructors accept an integer argument and interpret it as meaning to create a zero-initialised sequence of the given size:: (...) This PEP proposes to deprecate that behaviour in Python 3.6, and remove it entire

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 02:03, Nick Coghlan wrote: That said, it occurs to me that there's a reasonably strong composability argument in favour of a view-based approach: a view will work with operator.itemgetter() and other sequence consuming APIs, while special methods won't. The "like-memoryview-but-not" v

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 13:37, Paul Sokolovsky wrote: The obvious way to create the bytes object of length n is b'\0' * n. That's very inefficient: it requires allocating useless b'\0', then a generic function to repeat arbitrary memory block N times. If there's a talk of Python to not be laughed at for be

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 14:26, Paul Sokolovsky wrote: On Wed, 8 Jun 2016 14:05:19 +0300 Serhiy Storchaka wrote: On 08.06.16 13:37, Paul Sokolovsky wrote: The obvious way to create the bytes object of length n is b'\0' * n. That's very inefficient: it requires allocating useless b'

[Python-Dev] When to use EOFError?

2016-06-21 Thread Serhiy Storchaka
There is a design question. If you read file in some format or with some protocol, and the data is ended unexpectedly, when to use general EOFError exception and when to use format/protocol specific exception? For example when load truncated pickle data, an unpickler can raise EOFError, Unpick

Re: [Python-Dev] When to use EOFError?

2016-06-25 Thread Serhiy Storchaka
On 22.06.16 00:17, Victor Stinner wrote: When loading truncated data with pickle, I expect a pickle error, not a generic ValueError nor EOFError. Many modules raise EOFError when read truncated data. ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] When to use EOFError?

2016-06-25 Thread Serhiy Storchaka
On 22.06.16 19:22, André Malo wrote: I often concatenate multiple pickles into one file. When reading them, it works like this: try: while True: yield pickle.load(fp) except EOFError: pass In this case the truncation is not really unexpected. Maybe it should distinguish betwe

Re: [Python-Dev] Rewrite @contextlib.contextmanager in C

2016-08-09 Thread Serhiy Storchaka
On 09.08.16 00:59, Chris Angelico wrote: class TooSimpleContextManager: """Now this time you've gone too far.""" def __init__(self, func): self.func = func def __call__(self): self.gen = self.func() return self def __enter__(self): next(self.gen)

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Serhiy Storchaka
On 28.08.16 01:25, Terry Reedy wrote: 0. Do nothing. The problem is not in pathological __index__. The problem is in executing Python code and releasing GIL. In multithread production code one thread can read a slice when other thread modifies a collection. In very very rare case it causes a

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Serhiy Storchaka
On 30.08.16 15:31, Dima Tisnek wrote: On 30 August 2016 at 14:13, Serhiy Storchaka wrote: 1. Detect length change and raise. It would be simpler solution. But I afraid that this can break third-party code that "just works" now. For example slicing a list "just works"

Re: [Python-Dev] Update on PEP 523 and adding a co_extra field to code objects

2016-08-30 Thread Serhiy Storchaka
On 30.08.16 21:20, Antoine Pitrou wrote: On Tue, 30 Aug 2016 18:12:01 + Brett Cannon wrote: Why not make it always a list? List objects are reasonably cheap in memory and access time... (unlike dicts) Because I would prefer to avoid any form of unnecessary performance overhead for the co

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Serhiy Storchaka
On 30.08.16 20:42, Nick Coghlan wrote: On 28 August 2016 at 08:25, Terry Reedy wrote: Slicing can be made to malfunction and even crash with an 'evil' __index__ method. https://bugs.python.org/issue27867 The crux of the problem is this: PySlice_GetIndicesEx receives a slice object and a sequen

Re: [Python-Dev] What's the status of PEP 515?

2016-09-07 Thread Serhiy Storchaka
On 07.09.16 07:21, Eric V. Smith wrote: The implementation of '_' in numeric literals is here: http://bugs.python.org/issue26331 And to add '_' in int.__format__ is here: http://bugs.python.org/issue27080 But I don't want to add support in int.__format__ unless numeric literal support is added.

Re: [Python-Dev] PEP 467: last round (?)

2016-09-10 Thread Serhiy Storchaka
On 01.09.16 22:36, Ethan Furman wrote: * Add ``bytes.iterbytes`` and ``bytearray.iterbytes`` alternative iterators Could you please add a mention of alternative: seqtools.chunks()? seqtools.chunks(bytes, 1) and seqtools.chunks(bytearray, 1) should be equivalent to bytes.iterbytes() and bytear

Re: [Python-Dev] Python 3.7: remove all private C functions from the Python C API?

2016-09-12 Thread Serhiy Storchaka
On 12.09.16 11:41, Victor Stinner wrote: 2016-09-12 8:23 GMT+02:00 Benjamin Peterson : That seems like a good idea in abstract. However, the boundaries will have to be delineated. Many functions beginning _Py are effectively part of the public API even for "well-behaved" 3rd-party extensions O

Re: [Python-Dev] Python 3.6 dict becomes compact and gets a private version; and keywords become ordered

2016-09-14 Thread Serhiy Storchaka
On 08.09.16 23:22, Victor Stinner wrote: I pushed INADA Naoki's implementation of the "compact dict". The hash table now stores indices pointing to a new second table which contains keys and values: it adds one new level of indirection. The table of indices is "compact": use 1, 2, 4 or 8 bytes pe

Re: [Python-Dev] [RELEASE] Python 3.6.0b1 is now available

2016-09-14 Thread Serhiy Storchaka
On 14.09.16 17:36, Guido van Rossum wrote: Fortunately that page isn't linked from anywhere on the home page AFAIK. If it is, could someone file an issue in the pydotorg tracker? The url is at the bottom of every page. This is on of the first results (actually the first besides manually edited

Re: [Python-Dev] Python 3.6 dict becomes compact and gets a private version; and keywords become ordered

2016-09-15 Thread Serhiy Storchaka
On 15.09.16 11:02, INADA Naoki wrote: Are two Pythons built with same options? Both are built from clean checkout with default options (hg update -C 3.x; ./configure; make -s). The only difference is -std=c99 and additional warnings in 3.6: Python 3.5: gcc -pthread -c -Wno-unused-result -Ws

Re: [Python-Dev] Python 3.6 dict becomes compact and gets a private version; and keywords become ordered

2016-09-15 Thread Serhiy Storchaka
On 15.09.16 11:57, Victor Stinner wrote: Stop! Please stop using timeit, it's lying! * You must not use the minimum but average or median * You must run a microbenchmark in multiple processes to test different randomized hash functions and different memory layouts In short: you should use m

Re: [Python-Dev] Python 3.6 dict becomes compact and gets a private version; and keywords become ordered

2016-09-15 Thread Serhiy Storchaka
On 15.09.16 12:43, Raymond Hettinger wrote: On Sep 14, 2016, at 11:31 PM, Serhiy Storchaka wrote: Note that this is made at the expense of the 20% slowing down an iteration. $ ./python -m timeit -s "d = dict.fromkeys(range(10**6))" -- "list(d)" Python 3.5: 66.1 msec per l

Re: [Python-Dev] Python 3.6 dict becomes compact and gets a private version; and keywords become ordered

2016-09-15 Thread Serhiy Storchaka
On 15.09.16 19:13, Antoine Pitrou wrote: Since this micro-benchmark creates the keys in order just before filling the dict with them, randomizing the insertion order destroys the temporal locality of object header accesses when iterating over the dict keys. *This* looks like the right explanation

Re: [Python-Dev] [python-committers] [RELEASE] Python 3.6.0b1 is now available

2016-09-16 Thread Serhiy Storchaka
On 15.09.16 09:48, Berker Peksağ wrote: Fixed, it should redirect to https://www.python.org/blogs/ now. Thanks for noticing this! Thanks Berker! ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Un

Re: [Python-Dev] Missing PY_ prefixes in structmember.h

2016-10-03 Thread Serhiy Storchaka
On 03.10.16 16:37, Skip Montanaro wrote: I'm sure this has a simple explanation (and is probably only of historical interest at this point), but ... While starting to port the Python Sybase module to Python 3, among other hurdles, I noticed that RO is no longer defined. Looking in structmember.h

[Python-Dev] Is explicit registration of Iterators needed?

2016-10-07 Thread Serhiy Storchaka
A number of builtin iterator classes (but not all builtin iterator classes) are registered with the Iterator ABC in Lib/_collections_abc.py. But isinstance(it, Iterable) check works without explicit registration, because Iterable has __subclasshook__ that checks iterator methods. Is there a n

Re: [Python-Dev] Is explicit registration of Iterators needed?

2016-10-07 Thread Serhiy Storchaka
On 07.10.16 17:37, Guido van Rossum wrote: On Fri, Oct 7, 2016 at 6:36 AM, Serhiy Storchaka wrote: A number of builtin iterator classes (but not all builtin iterator classes) are registered with the Iterator ABC in Lib/_collections_abc.py. But isinstance(it, Iterable) check works without

Re: [Python-Dev] Is explicit registration of Iterators needed?

2016-10-08 Thread Serhiy Storchaka
On 07.10.16 18:08, Guido van Rossum wrote: On Fri, Oct 7, 2016 at 7:47 AM, Serhiy Storchaka wrote: Should we register missed builtin iterators? For example longrange_iterator. I don't feel strongly about this either way. Let sleeping dogs lie, etc. (Is this related to issue 26906?)

[Python-Dev] Check dict implementation details

2016-10-08 Thread Serhiy Storchaka
Since dict is ordered in CPython 3.6, it can be used instead of OrderedDict in some places (e.g. for implementing simple limited caches). But since this is implementation detail, it can't be used in the stdlib unconditionally. Needed a way to check whether dict is ordered. Actually there are t

Re: [Python-Dev] Adding bytes.frombuffer() constructor to PEP 467 (was: [Python-ideas] Adding bytes.frombuffer() constructor

2016-10-11 Thread Serhiy Storchaka
On 12.10.16 07:08, INADA Naoki wrote: Sample code: def read_line(buf: bytearray) -> bytes: try: n = buf.index(b'\r\n') except ValueError: return b'' line = bytes(buf)[:n] # bytearray -> bytes -> bytes Wouldn't be more correct to write this

Re: [Python-Dev] Adding bytes.frombuffer() constructor to PEP 467 (was: [Python-ideas] Adding bytes.frombuffer() constructor

2016-10-11 Thread Serhiy Storchaka
On 12.10.16 08:03, Nathaniel Smith wrote: On Tue, Oct 11, 2016 at 9:08 PM, INADA Naoki wrote: From Python 3.4, bytearray is good solution for I/O buffer, thanks to #19087 [1]. Actually, asyncio uses bytearray as I/O buffer often. Whoa what?! This is awesome, I had no idea that bytearray had O

Re: [Python-Dev] O(1) deletes from the front of bytearray (was: Re: Adding bytes.frombuffer() constructor to PEP 467 (was: [Python-ideas] Adding bytes.frombuffer() constructor)

2016-10-12 Thread Serhiy Storchaka
On 12.10.16 09:31, Nathaniel Smith wrote: But amortized O(1) deletes from the front of bytearray are totally different, and more like amortized O(1) appends to list: there are important use cases[1] that simply cannot be implemented without some feature like this, and putting the implementation i

Re: [Python-Dev] O(1) deletes from the front of bytearray (was: Re: Adding bytes.frombuffer() constructor to PEP 467 (was: [Python-ideas] Adding bytes.frombuffer() constructor)

2016-10-13 Thread Serhiy Storchaka
On 13.10.16 00:14, Nathaniel Smith wrote: AFAIK basically the only project that would be affected by this is PyPy, And MicroPython. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: h

Re: [Python-Dev] Benchmarking Python and micro-optimizations

2016-10-20 Thread Serhiy Storchaka
On 20.10.16 13:56, Victor Stinner wrote: Last months, I worked a lot on benchmarks. I ran benchmarks, analyzed results in depth (up to the hardware and kernel drivers!), I wrote new tools and enhanced existing tools. Great work! Thank you Victor. __

[Python-Dev] Default formatting

2016-10-25 Thread Serhiy Storchaka
Classes that doesn't define the __format__ method for custom PEP 3101 formatting inherits it from parents. Originally the object.__format__ method was designed as [1]: def __format__(self, format_spec): return format(str(self), format_spec) An instance is converted to string and re

Re: [Python-Dev] Default formatting

2016-10-27 Thread Serhiy Storchaka
On 27.10.16 02:44, Eric V. Smith wrote: But on the other hand, the existing behavior is well specified and has been around since object.__format__ was added. I'm not sure it needs changing. What's the harm in leaving it? More complicated code. And maybe this behavior is less intuitive. It cont

Re: [Python-Dev] Default formatting

2016-10-27 Thread Serhiy Storchaka
On 27.10.16 19:59, Steve Dower wrote: Having the default __format__ behave like this makes me happiest: def __format__(self, fmt): return format(str(self), fmt) My 2c. YMMV. etc. See issue7994 [1] for arguments against this. [1] http://bugs.python.org/issue7994 __

Re: [Python-Dev] Python 2.7.13 release dates

2016-11-28 Thread Serhiy Storchaka
On 28.11.16 09:06, Benjamin Peterson wrote: I've have just updated PEP 373 to say that Python 2.7.13 release candidate 1 will be released on December 3. The final will follow two weeks later on December 17. If there are delays in the process, the final will likely to pushed into January. Could

<    3   4   5   6   7   8   9   10   11   12   >