Re: [Python-Dev] The `for y in [x]` idiom in comprehensions

2018-02-25 Thread Nikolaus Rath
On Feb 25 2018, Chris Angelico <ros...@gmail.com> wrote: > On Sun, Feb 25, 2018 at 11:02 PM, Nikolaus Rath <nikol...@rath.org> wrote: >> On Feb 22 2018, Serhiy Storchaka <storch...@gmail.com> wrote: >>> 1. Inner generator expression: >>> >>>

Re: [Python-Dev] The `for y in [x]` idiom in comprehensions

2018-02-25 Thread Nikolaus Rath
On Feb 22 2018, Serhiy Storchaka wrote: > 1. Inner generator expression: > > result = [y + g(y) for y in (f(x) for x in range(10))] > [...] > > And maybe there are other ways. I think the syntax recently brough up by Nick is still the most beautiful: result = [

Re: [Python-Dev] Python startup time

2017-07-21 Thread Nikolaus Rath
On Jul 21 2017, David Mertz wrote: > How implausible is it to write out the actual memory image of a loaded > Python process? That is what Emacs does, and it causes them a lot of trouble. They're trying to move away from it at the moment, but the direction is not yet clear. The

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

2016-10-12 Thread Nikolaus Rath
On Oct 11 2016, 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?!

Re: [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-15 Thread Nikolaus Rath
On Sep 13 2016, Tim Peters <tim.pet...@gmail.com> wrote: > [Terry Reedy <tjre...@udel.edu>] >>> Tim Peters investigated and empirically determined that an >>> O(n*n) binary insort, as he optimized it on real machines, is faster >>> than O(n*logn) sortin

Re: [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-13 Thread Nikolaus Rath
On Sep 11 2016, Terry Reedy wrote: > Tim Peters investigated and empirically determined that an > O(n*n) binary insort, as he optimized it on real machines, is faster > than O(n*logn) sorting for up to around 64 items. Out of curiosity: is this test repeated periodically on

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

2016-06-27 Thread Nikolaus Rath
On Jun 21 2016, Serhiy Storchaka wrote: > 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

Re: [Python-Dev] BDFL ruling request: should we block forever waiting for high-quality random bits?

2016-06-16 Thread Nikolaus Rath
On Jun 16 2016, Nick Coghlan wrote: > On 16 June 2016 at 09:39, Paul Moore wrote: >> I'm willing to accept the view of the security experts that there's a >> problem here. But without a clear explanation of the problem, how can >> a non-specialist like

Re: [Python-Dev] BDFL ruling request: should we block forever waiting for high-quality random bits?

2016-06-09 Thread Nikolaus Rath
On Jun 09 2016, Larry Hastings <la...@hastings.org> wrote: > On 06/09/2016 07:38 PM, Nikolaus Rath wrote: >> On Jun 09 2016, Larry Hastings <la...@hastings.org> wrote: >>> Nope, I want the old behavior back. os.urandom() should read >>> /dev/random if getra

Re: [Python-Dev] BDFL ruling request: should we block forever waiting for high-quality random bits?

2016-06-09 Thread Nikolaus Rath
On Jun 09 2016, Guido van Rossum wrote: > I don't think we should add a new function. I think we should convince > ourselves that there is not enough of a risk of an exploit even if > os.urandom() falls back. That will be hard, because you have to consider an active, clever

Re: [Python-Dev] BDFL ruling request: should we block forever waiting for high-quality random bits?

2016-06-09 Thread Nikolaus Rath
On Jun 09 2016, Larry Hastings wrote: > On 06/09/2016 03:44 PM, Ethan Furman wrote: >> On 06/09/2016 03:22 PM, Larry Hastings wrote: >>> Okay, it's decided: os.urandom() must be changed for 3.5.2 to never >>> block on a getrandom() call. >> >> One way to not block is to raise

Re: [Python-Dev] file system path protocol PEP

2016-05-11 Thread Nikolaus Rath
On May 11 2016, Brett Cannon wrote: > This PEP proposes a protocol for classes which represent a file system > path to be able to provide a ``str`` or ``bytes`` representation. [...] As I said before, to me this seems like a lot of effort for a very specific use-case. So let me

Re: [Python-Dev] pathlib - current status of discussions

2016-04-13 Thread Nikolaus Rath
On Apr 13 2016, Ethan Furman <et...@stoneleaf.us> wrote: > On 04/13/2016 03:45 PM, Nikolaus Rath wrote: > >> When passing an object that is of type str and has a __fspath__ >> attribute, all approaches return the value of __fspath__(). >> >> However,

Re: [Python-Dev] pathlib - current status of discussions

2016-04-13 Thread Nikolaus Rath
On Apr 13 2016, Brett Cannon wrote: > On Tue, 12 Apr 2016 at 22:38 Michael Mysinger via Python-Dev < > python-dev@python.org> wrote: > >> Ethan Furman stoneleaf.us> writes: >> >> > Do we allow bytes to be returned from os.fspath()? If yes, then do we >> > allow bytes from

Re: [Python-Dev] Pathlib enhancements - acceptable inputs and outputs for __fspath__ and os.fspath()

2016-04-13 Thread Nikolaus Rath
On Apr 13 2016, Ethan Furman wrote: > (I'm not very good at keeping similar sounding functions separate -- > what's the difference between shutil.copy and shutil.copy2? I have to > look it up every time). Well, "2" is more than "" (or 1), so copy2() copies *more* than copy()

Re: [Python-Dev] Challenge: Please break this! (a.k.a restricted mode revisited)

2016-04-11 Thread Nikolaus Rath
On Apr 11 2016, Jon Ribbens wrote: >> What I see is that you asked to break your sandbox, and less than 1 >> hour later, a first vulnerability was found (exec called with two >> parameters). A few hours later, a second vulnerability was found >> (async generator

Re: [Python-Dev] Challenge: Please break this! (a.k.a restricted mode revisited)

2016-04-10 Thread Nikolaus Rath
On Apr 10 2016, Jon Ribbens wrote: > On Sat, Apr 09, 2016 at 02:43:19PM +0200, Victor Stinner wrote: >>Please don't loose time trying yet another sandbox inside CPython. It's >>just a waste of time. It's broken by design. >> >>Please read my email

Re: [Python-Dev] Defining a path protocol

2016-04-09 Thread Nikolaus Rath
On Apr 07 2016, Donald Stufft <don...@stufft.io> wrote: >> On Apr 7, 2016, at 6:48 AM, Nikolaus Rath <nikol...@rath.org> wrote: >> >> Does anyone anticipate any classes other than those from pathlib to come >> with such a method? > > > It seems like it

Re: [Python-Dev] Defining a path protocol

2016-04-07 Thread Nikolaus Rath
On Apr 06 2016, Ethan Furman wrote: > On 04/06/2016 11:15 PM, Greg Ewing wrote: >> Chris Barker - NOAA Federal wrote: >>> But fspath(), if it exists, would call __fspath__ on an arbitrary >>> object, and create a new string -- not a new Path. That may be >>> confusing... >> >>

[Python-Dev] Git for Mercurial Users

2016-02-03 Thread Nikolaus Rath
Hello, With the upcoming move to Git, I thought people might be interested in some thoughts that I wrote down when learning Git for the first time as a long-time Mercurial user: http://www.rath.org/mercurial-for-git-users-and-vice-versa.html Comments are welcome (but probably more

Re: [Python-Dev] More optimisation ideas

2016-02-01 Thread Nikolaus Rath
On Feb 01 2016, mike.romb...@comcast.net wrote: " " == Barry Warsaw writes: >> On Feb 01, 2016, at 11:40 AM, R. David Murray wrote: >> I don't know about anyone else, but on my own development >> systems it is not that unusual for me to *edit* the >>

Re: [Python-Dev] Third milestone of FAT Python

2015-12-07 Thread Nikolaus Rath
On Dec 04 2015, Victor Stinner wrote: > Hi, > > I implemented 3 new optimizations in FAT Python: loop unrolling, constant > folding and copy builtin functions to constants. In the previous thread, > Terry Reedy asked me if the test suite is complete enough to ensure that

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
On Sep 16 2015, Paul Moore wrote: > On 16 September 2015 at 06:10, Stephen J. Turnbull wrote: >> The only thing that hg really lost badly on >> IMO was "named branches", and that's been fixed with bookmarks. > > FWIW, I still find bookmarks confusing to

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
On Sep 16 2015, Chris Angelico wrote: > With git, there are infinite workflows possible - you aren't forced to > have a concept of "central server" and "clients" the way you would > with SVN. Mercurial's called a DVCS too, so presumably it's possible > to operate on a

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
On Sep 16 2015, "R. David Murray" wrote: > The DAG plus git branches-as-labels *fits in my head* in a way that the > DAG plus named-branches-and-other-things does not. Hmm, that's odd. As far as I know, the difference between the hg and git DAG model can be summarized like

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
ookmark bar > creates 2 bookmarks. If I then check in a change, I guess *both* > bookmarks move. No, only the active bookmark moves automatically: $ hg bookmark foo $ hg bookmark bar $ hg log -r tip changeset: 0:d1c121e915b8 bookmark:bar bookmark:foo tag: tip user:Nikolaus R

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
On Sep 17 2015, "Stephen J. Turnbull" <step...@xemacs.org> wrote: > Nikolaus Rath writes: > > > Hmm, that's odd. As far as I know, the difference between the hg and git > > DAG model can be summarized like this: > > > > * In git, leaves of the D

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
On Sep 16 2015, "R. David Murray" <rdmur...@bitdance.com> wrote: > On Wed, 16 Sep 2015 09:17:38 -0700, Nikolaus Rath <nikol...@rath.org> wrote: >> On Sep 16 2015, "R. David Murray" <rdmur...@bitdance.com> wrote: >> > The DAG plus git branche

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
On Sep 16 2015, Terry Reedy wrote: > On 9/16/2015 5:20 AM, Oleg Broytman wrote: > >> On Tue, Sep 15, 2015 at 07:44:28PM +, Augie Fackler >> wrote: > >>> There are a lot of reasons to prefer one tool over another. Common ones are >>> familiarity,

Re: [Python-Dev] PEP: Collecting information about git

2015-09-16 Thread Nikolaus Rath
On Sep 16 2015, Nikolaus Rath <nikol...@rath.org> wrote: > On Sep 16 2015, "R. David Murray" <rdmur...@bitdance.com> wrote: >> On Wed, 16 Sep 2015 09:17:38 -0700, Nikolaus Rath <nikol...@rath.org> wrote: >>> On Sep 16 2015, "R. David Murray&quo

Re: [Python-Dev] PEP: Collecting information about git

2015-09-15 Thread Nikolaus Rath
On Sep 16 2015, Chris Angelico wrote: > On Wed, Sep 16, 2015 at 5:44 AM, Augie Fackler wrote: >>> but git is still better at it: ``git add -p`` >>> allows me to review and edit patches before commit while ``hg record`` >>> commits immediately. >> >> FWIW, I

Re: [Python-Dev] PEP 501 Shell Command Examples

2015-09-05 Thread Nikolaus Rath
On Sep 05 2015, Nick Coghlan <ncogh...@gmail.com> wrote: > On 5 September 2015 at 12:36, Nikolaus Rath <nikol...@rath.org> wrote: >> Hi Nick, >> >> You are giving >> >> runcommand(sh(i"cat {filename}")) >> >> as an

Re: [Python-Dev] PEP 498: Literal String Interpolation is ready for pronouncement

2015-09-04 Thread Nikolaus Rath
On Sep 04 2015, "Eric V. Smith" wrote: > I've made a number of small changes to PEP 498. I don't think any of the > changes I've made in the last week are substantive. Mostly I've > clarified how it works and removing some limitations. The only > meaningful change is that

[Python-Dev] PEP 501 Shell Command Examples

2015-09-04 Thread Nikolaus Rath
Hi Nick, You are giving runcommand(sh(i"cat {filename}")) as an example that avoids injection attacks. While this is true, I think this is still a terrible anti-pattern[1] that should not be entombed in a PEP as a positive example. Could you consider removing it? (It doubly wastes resources

Re: [Python-Dev] PEP-498: Literal String Formatting

2015-08-17 Thread Nikolaus Rath
On Aug 16 2015, Paul Moore p.f.mo...@gmail.com wrote: 2. By far and away the most common use for me would be things like print(fIteration {n}: Took {end-start) seconds). I believe an even more common use willl be print(fIteration {n+1}: Took {end-start} seconds) Note that not allowing

Re: [Python-Dev] PEP-498: Literal String Formatting

2015-08-08 Thread Nikolaus Rath
On Aug 08 2015, Nick Coghlan ncogh...@gmail.com wrote: On 8 August 2015 at 11:39, Eric V. Smith e...@trueblade.com wrote: Following a long discussion on python-ideas, I've posted my draft of PEP-498. It describes the f-string approach that was the subject of the Briefer string format thread.

Re: [Python-Dev] PEP-498: Literal String Formatting

2015-08-08 Thread Nikolaus Rath
On Aug 08 2015, Nikolaus Rath nikol...@rath.org wrote: On Aug 08 2015, Nick Coghlan ncogh...@gmail.com wrote: On 8 August 2015 at 11:39, Eric V. Smith e...@trueblade.com wrote: Following a long discussion on python-ideas, I've posted my draft of PEP-498. It describes the f-string approach

Re: [Python-Dev] PEP 492 documentation

2015-08-02 Thread Nikolaus Rath
cache issue? Yury On 2015-08-02 12:38 AM, Nikolaus Rath wrote: Hello, Looking at the language reference for 3.5.0b4, I noticed that it mentions neither async nor await. Is this still going to get updated, or will the only documentation consist of the PEP itself? I think having a Python

[Python-Dev] PEP 492 documentation

2015-08-01 Thread Nikolaus Rath
Hello, Looking at the language reference for 3.5.0b4, I noticed that it mentions neither async nor await. Is this still going to get updated, or will the only documentation consist of the PEP itself? I think having a Python release recognize keywords that are not mentioned in the language

Re: [Python-Dev] Issues not responded to.

2015-07-30 Thread Nikolaus Rath
On Jul 31 2015, Mark Lawrence breamore...@yahoo.co.uk wrote: There are over 400 issues on the bug tracker that have not had a response to the initial message, roughly half of these within the last eight months alone. Is there a (relatively) simple way that we can share these out between us to

Re: [Python-Dev] Status on PEP-431 Timezones

2015-07-27 Thread Nikolaus Rath
On Jul 27 2015, Lennart Regebro rege...@gmail.com wrote: That you add one hour to it, and the datetime moves forward one hour in actual time? That's doable, but during certain circumstance this may mean that you go from 1AM to 1AM, or from 1AM to 3AM. Or do you expect that adding one hour

Re: [Python-Dev] How do we tell if we're helping or hindering the core development process?

2015-07-22 Thread Nikolaus Rath
On Jul 22 2015, Nick Coghlan ncogh...@gmail.com wrote: On 22 July 2015 at 13:23, Nikolaus Rath nikol...@rath.org wrote: If it were up to me, I'd focus all the resources of the PSF on reducing this backlog - be that by hiring some core developers to work full-time on just the open bugtracker

Re: [Python-Dev] How do we tell if we're helping or hindering the core development process?

2015-07-21 Thread Nikolaus Rath
On Jul 21 2015, Nick Coghlan ncogh...@gmail.com wrote: All of this is why the chart that I believe should be worrying people is the topmost one on this page: http://bugs.python.org/issue?@template=stats Both the number of open issues and the number of open issues with patches are steadily

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Nikolaus Rath
On Apr 20 2015, Chris Angelico ros...@gmail.com wrote: Maybe it'd be of value to have a quick code stripper that takes away all the annotations, plus any other junk/framing that you're not interested in, and gives you something you can browse in a text editor? If you need to preprocess your

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Nikolaus Rath
On Apr 21 2015, Paul Sokolovsky pmis...@gmail.com wrote: Hello, On Tue, 21 Apr 2015 08:05:59 -0700 Nikolaus Rath nikol...@rath.org wrote: On Apr 20 2015, Chris Angelico ros...@gmail.com wrote: Maybe it'd be of value to have a quick code stripper that takes away all the annotations, plus

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Nikolaus Rath
On Apr 20 2015, Harry Percival hj...@cantab.net wrote: My first reaction to type hints was yuck, and I'm sure I'm not the only one to think that. viz (from some pycon slides): def zipmap(f: Callable[[int, int], int], xx: List[int], yy: List[int]) - List[Tuple[int, int,

Re: [Python-Dev] Bytes path support

2014-08-26 Thread Nikolaus Rath
Nick Coghlan ncogh...@gmail.com writes: As some examples of where bilingual computing breaks down: * My NFS client and server may have different locale settings * My FTP client and server may have different locale settings * My SSH client and server may have different locale settings * I

Re: [Python-Dev] sum(...) limitation

2014-08-12 Thread Nikolaus Rath
Chris Barker chris.bar...@noaa.gov writes: What I fail to see is why it's better to raise an exception and point users to a better way, than to simply provide an optimization so that it's a mute issue. The only justification offered here is that will teach people that summing strings (and

[Python-Dev] Commit-ready patches in need of review

2014-08-11 Thread Nikolaus Rath
Hello, The following commit-ready patches have been waiting for review since May and earlier.It'd be great if someone could find the time to take a look. I'll be happy to incorporate feedback as necessary: * http://bugs.python.org/issue1738 (filecmp.dircmp does exact match only) *

Re: [Python-Dev] Updates to PEP 471, the os.scandir() proposal

2014-07-09 Thread Nikolaus Rath
Ben Hoyt benh...@gmail.com writes: So here's the ways in which option #2 is now more complicated than option #1: 1) it has an additional info argument, the values of which have to be documented ('os', 'type', 'lstat', and what each one means) 2) it has an additional onerror argument, the

Re: [Python-Dev] Why does _pyio.*.readinto have to work with 'b' arrays?

2014-06-15 Thread Nikolaus Rath
Nick Coghlan ncogh...@gmail.com writes: On 15 June 2014 14:57, Nikolaus Rath nikol...@rath.org wrote: On 06/14/2014 09:31 PM, Nick Coghlan wrote: On 15 June 2014 10:41, Benjamin Peterson benja...@python.org wrote: On Sat, Jun 14, 2014, at 15:39, Nikolaus Rath wrote: It seems to me that a much

Re: [Python-Dev] Why does _pyio.*.readinto have to work with 'b' arrays?

2014-06-15 Thread Nikolaus Rath
Victor Stinner victor.stin...@gmail.com writes: Le 15 juin 2014 02:42, Benjamin Peterson benja...@python.org a écrit : On Sat, Jun 14, 2014, at 15:39, Nikolaus Rath wrote: It seems to me that a much cleaner solution would be to simply declare _pyio's readinto to only work with bytearrays

[Python-Dev] Why does _pyio.*.readinto have to work with 'b' arrays?

2014-06-14 Thread Nikolaus Rath
Hello, The _pyio.BufferedIOBase class contains the following hack to make sure that you can read-into array objects with format 'b': try: b[:n] = data except TypeError as err: import array if not isinstance(b, array.array):

Re: [Python-Dev] Why does _pyio.*.readinto have to work with 'b' arrays?

2014-06-14 Thread Nikolaus Rath
On 06/14/2014 09:31 PM, Nick Coghlan wrote: On 15 June 2014 10:41, Benjamin Peterson benja...@python.org wrote: On Sat, Jun 14, 2014, at 15:39, Nikolaus Rath wrote: It seems to me that a much cleaner solution would be to simply declare _pyio's readinto to only work with bytearrays

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-13 Thread Nikolaus Rath
Benjamin Peterson benja...@python.org writes: On Thu, Jun 12, 2014, at 18:06, Nikolaus Rath wrote: Consider this simple example: $ cat test.py import io import warnings class StridedStream(io.IOBase): def __init__(self, name, stride=2): super().__init__() self.fh

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-12 Thread Nikolaus Rath
Benjamin Peterson benja...@python.org writes: On Wed, Jun 11, 2014, at 17:11, Nikolaus Rath wrote: MRAB pyt...@mrabarnett.plus.com writes: On 2014-06-11 02:30, Nikolaus Rath wrote: Hello, I recently noticed (after some rather protacted debugging) that the io.IOBase class comes

Re: [Python-Dev] subprocess shell=True on Windows doesn't escape ^ character

2014-06-12 Thread Nikolaus Rath
R. David Murray rdmur...@bitdance.com writes: Also notice that using a list with shell=True is using the API incorrectly. It wouldn't even work on Linux, so that torpedoes the cross-platform concern already :) This kind of confusion is why I opened http://bugs.python.org/issue7839. Can

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-11 Thread Nikolaus Rath
MRAB pyt...@mrabarnett.plus.com writes: On 2014-06-11 02:30, Nikolaus Rath wrote: Hello, I recently noticed (after some rather protacted debugging) that the io.IOBase class comes with a destructor that calls self.close(): [0] nikratio@vostro:~/tmp$ cat test.py import io class Foo

[Python-Dev] Why does IOBase.__del__ call .close?

2014-06-10 Thread Nikolaus Rath
Hello, I recently noticed (after some rather protacted debugging) that the io.IOBase class comes with a destructor that calls self.close(): [0] nikratio@vostro:~/tmp$ cat test.py import io class Foo(io.IOBase): def close(self): print('close called') r = Foo() del r [0]

Re: [Python-Dev] [numpy wishlist] Interpreter support for temporary elision in third-party classes

2014-06-05 Thread Nikolaus Rath
Nathaniel Smith n...@pobox.com writes: Such optimizations are important enough that numpy operations always give the option of explicitly specifying the output array (like in-place operators but more general and with clumsier syntax). Here's an example small-array benchmark that IIUC uses

Re: [Python-Dev] [numpy wishlist] Interpreter support for temporary elision in third-party classes

2014-06-05 Thread Nikolaus Rath
Nathaniel Smith n...@pobox.com writes: tmp1 = a + b tmp1 += c tmp1 /= c result = tmp1 Could this transformation be done in the ast? And would that help? I don't think it could be done in the ast because I don't think you can work with anonymous temporaries there. But,

[Python-Dev] Commit-ready patches in need of review

2014-05-24 Thread Nikolaus Rath
Hello, While my last appeal resulted in quite some commits (thanks!), I still have some more commit-ready patches waiting for review. It'd be great if some people could find time to take a look: * http://bugs.python.org/issue1738 (filecmp.dircmp does exact match only) Reviewed patch,

[Python-Dev] Aborting unit tests on first failure

2014-04-29 Thread Nikolaus Rath
Hello, I've just run the testsuite of hg tip with ./python -m test -u network,urlfetch -j 8 -G -v and it finished with , | [...] | test_extract_dir (test.test_zipfile.TestWithDirectory) ... ok | test_store_dir (test.test_zipfile.TestWithDirectory) ... ok | test_different_file

[Python-Dev] bytes with trailing \0?

2014-04-28 Thread Nikolaus Rath
Hello, I was surprised to find the following in bytesobject.c: , | [...] |As always, an extra byte is allocated for a trailing \0 byte (newsize |does *not* include that), and a trailing \0 byte is stored. | */ | | int | _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize) | { | [...]

[Python-Dev] Commit-ready patches needing review

2014-04-27 Thread Nikolaus Rath
Hello, While my last appeal resulted in quite some commits (thanks!), I still have some more commit-ready patches waiting for review. It'd be great if some people could find time to take a look: * http://bugs.python.org/issue1738 (filecmp.dircmp does exact match only) *

Re: [Python-Dev] Commit-ready patches needing review

2014-04-27 Thread Nikolaus Rath
Antoine Pitrou solip...@pitrou.net writes: On Sun, 27 Apr 2014 12:10:46 -0700 Nikolaus Rath nikol...@rath.org wrote: * http://bugs.python.org/issue20951 (SSLSocket.send() returns 0 for non-blocking socket) In this case someone just needs to decide if we want to (a) document

Re: [Python-Dev] Appeal for reviews

2014-04-13 Thread Nikolaus Rath
Terry Reedy tjre...@udel.edu writes: [Quote conveniently rearranged] I've accumulated a number of patches in the issue tracker that are waiting for someone to review/commit/reject them. I'm eager to make corrections as necessary, I just need someone to look the work that I've done so far: Do

Re: [Python-Dev] Appeal for reviews

2014-04-13 Thread Nikolaus Rath
Stephen J. Turnbull step...@xemacs.org writes: I apologize for the tone. I need to go *right* now, and can't fix that. Really, I'm sympathetic and my goal is not just to defend python-dev, but to help you get the reviews your work deserves. Please read with that in mind. Will do - but why

Re: [Python-Dev] Appeal for reviews

2014-04-13 Thread Nikolaus Rath
Martin v. Löwis mar...@v.loewis.de writes: Am 13.04.14 08:36, schrieb Stephen J. Turnbull: I admit the tone was biased toward nagging or blaming the victim, and again I apologize for causing misunderstanding. Nikolaus isn't wrong for posting here. My claim is that in current circumstances,

[Python-Dev] Appeal for reviews

2014-04-12 Thread Nikolaus Rath
Hello, I've accumulated a number of patches in the issue tracker that are waiting for someone to review/commit/reject them. I'm eager to make corrections as necessary, I just need someone to look the work that I've done so far: * http://bugs.python.org/issue20951 (SSLSocket.send() returns 0 for

[Python-Dev] Adding a readinto1 method to BufferedReader

2014-03-31 Thread Nikolaus Rath
Hello, The BufferedReader (and BufferedRWPair) classes both have a read1() method in addition to the regular read() method to bypass the internal buffer. This is quite useful if you need to do some buffered reading (e.g. to parse a header) followed by a lot of bulk data that you want to process

Re: [Python-Dev] SSLSocket.send() for non-blocking sockets

2014-03-25 Thread Nikolaus Rath
Chris Angelico ros...@gmail.com writes: On Wed, Mar 26, 2014 at 11:54 AM, Nikolaus Rath nikol...@rath.org wrote: 2. Change the behavior immediately, potentially breaking some applications that worked around it, but unbreaking others that relied on the documented behavior. If it's

Re: [Python-Dev] PEP 466 (round 2): Network security enhancements for Python 2.7

2014-03-24 Thread Nikolaus Rath
Nick Coghlan ncogh...@gmail.com writes: Maintainability --- This policy does NOT represent a commitment by volunteer contributors to actually backport network security related changes from the Python 3 series to the Python 2 series. Rather, it is intended to send a clear signal

Re: [Python-Dev] Confirming status of new modules in 3.4

2014-03-16 Thread Nikolaus Rath
Charles-François Natali cf.nat...@gmail.com writes: 2014-03-15 21:44 GMT+00:00 Nikolaus Rath nikol...@rath.org: Guido van Rossum gu...@python.org writes: This downside of using subclassing as an API should be well known by now and widely warned against. It wasn't known to me until now

Re: [Python-Dev] Confirming status of new modules in 3.4

2014-03-15 Thread Nikolaus Rath
Guido van Rossum gu...@python.org writes: This downside of using subclassing as an API should be well known by now and widely warned against. It wasn't known to me until now. Are these downsides described in some more detail somewhere? So far I have always thought that, as long as I avoid

Re: [Python-Dev] Requesting pronouncement on PEP 463: Exception-catching expressions

2014-03-13 Thread Nikolaus Rath
Tres Seaver tsea...@palladion.com writes: On 03/12/2014 04:49 PM, Chris Angelico wrote: You can use hasattr() in place of AttributeError I use: getattr(subject, attrname, default)? *all the time*. In my opinion that's almost as ugly, because it still forces you to specify the attribute

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-23 Thread Nikolaus Rath
Ethan Furman et...@stoneleaf.us writes: Example:: b'%4x' % 10 b' a' '%#4x' % 10 ' 0xa' '%04X' % 10 '000A' Shouldn't the second two examples also be bytes, ie. b'%#4x' instead of '%#4x'? Best, -Nikolaus -- Encrypted emails preferred. PGP fingerprint: 5B93 61F8

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Nikolaus Rath
Stephen J. Turnbull step...@xemacs.org writes: Ethan Furman writes: On 02/21/2014 07:46 PM, Chris Angelico wrote: but not this: value = expr except Exception: default except Exception: default This should be the way it works. Nothing is gained in readability by

Re: [Python-Dev] The docstring hack for signature information has to go

2014-02-03 Thread Nikolaus Rath
Larry Hastings la...@hastings.org writes: In the second attempt, the signature looked like this: sig=(arguments)\n [...] This all has caused no problems so far. But my panicky email last night was me realizing a problem we may see down the road. To recap: if a programmer writes a

Re: [Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-21 Thread Nikolaus Rath
Larry Hastings la...@hastings.org writes: A comment on your approach so far: I'm very much against giving default a default value in the constructor. You mean in the definition of the custom converter class? I realize that hack saves you having to say = NULL in a lot of places. But explicit

Re: [Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-21 Thread Nikolaus Rath
Larry Hastings la...@hastings.org writes: All is not lost! What follows is rough pseudo-C code, hopefully you can take it from here. typedef struct { int set; time_t when; } clinic_time_t; #define DEFAULT_CLINIC_TIME_T {0, 0} static int

Re: [Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-20 Thread Nikolaus Rath
with me too. I'd just like Larry to sign off on it, because as far as I know, he'll be the one to review my patch. Best, -Nikolaus [1] If you set a default value, or put it in brackets as Serhiy later recommends, it works the same. On Sun, Jan 19, 2014 at 8:19 PM, Nikolaus Rath nikol...@rath.org

Re: [Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-20 Thread Nikolaus Rath
Serhiy Storchaka storch...@gmail.com writes: 20.01.14 06:19, Nikolaus Rath написав(ла): This works if the user calls time.gmtime(None), but it fails for time.gmtime(). It seems that in that case my C converter function is never called. What's the trick that I'm missing? /*[clinic input

Re: [Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-19 Thread Nikolaus Rath
Larry Hastings la...@hastings.org writes: On 01/18/2014 09:52 PM, Ryan Smith-Roberts wrote: I still advise you not to use this solution. time() is a system call on many operating systems, and so it can be a heavier operation than you'd think. Best to avoid it unless it's needed (on FreeBSD it

Re: [Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-19 Thread Nikolaus Rath
Larry Hastings la...@hastings.org writes: On 01/18/2014 09:52 PM, Ryan Smith-Roberts wrote: I still advise you not to use this solution. time() is a system call on many operating systems, and so it can be a heavier operation than you'd think. Best to avoid it unless it's needed (on FreeBSD it

[Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-18 Thread Nikolaus Rath
Hello, I'm trying to convert functions using parse_time_t_args() (from timemodule.c) for argument parsing to argument clinic. The function is defined as: , | static int | parse_time_t_args(PyObject *args, char *format, time_t *pwhen) | { | PyObject *ot = NULL; | time_t whent; | |

Re: [Python-Dev] Using argument clinic to replace timemodule.c:parse_time_t_args()

2014-01-18 Thread Nikolaus Rath
the PyArgs_ParseTuple code from parse_time_t_args * Declare seconds as a plain object in Argument Clinic * Call the modified parse_time_t_args on seconds first thing in the _impl functions On Sat, Jan 18, 2014 at 4:56 PM, Nikolaus Rath nikol...@rath.org wrote: Hello, I'm trying to convert

Re: [Python-Dev] OrderedDict.values() behavior for modified instance

2013-10-26 Thread Nikolaus Rath
Ethan Furman et...@stoneleaf.us writes: Nikolaus, Good write-up. Please submit it to the bug tracker: http://bugs.python.org Submitted as http://bugs.python.org/issue19414. If someone gives me the go-ahead for one of the proposed solutions, I'd be happy to create a full patch. Best,

[Python-Dev] OrderedDict.values() behavior for modified instance

2013-10-25 Thread Nikolaus Rath
Hello, The documentation says the following about modifying a dict while iterating through its view: | Iterating views while adding or deleting entries in the dictionary may | raise a RuntimeError or fail to iterate over all entries. (http://docs.python.org/3/library/stdtypes.html#dict-views)

Re: [Python-Dev] PEP 435 - requesting pronouncement

2013-05-05 Thread Nikolaus Rath
Guido van Rossum gu...@python.org writes: 1. Having to enter the values is annoying. Sorry, I read the rationale and all that, and I *still* want to write a C-Like enum { A, B, C }. I fully expect to edit and reorder enums (if I ever use them) and get irritated with having to update the value

Re: [Python-Dev] enum instances

2013-04-30 Thread Nikolaus Rath
On 04/30/2013 07:05 PM, Nikolaus Rath wrote: Larry Hastings la...@hastings.org writes: On 04/29/2013 07:42 PM, Nikolaus Rath wrote: State is a class, it just inherits from enum. Thus: type(State) == type(enum) == type(EnumMetaclass) issubclass(State, enum) == True If you'd tried it, you'd

Re: [Python-Dev] Destructors and Closing of File Objects

2013-04-30 Thread Nikolaus Rath
Armin Rigo ar...@tunes.org writes: Hi Jeff, On Mon, Apr 29, 2013 at 11:58 PM, Jeff Allen ja...py@farowl.co.uk wrote: In Jython, (...) Thanks Jeff for pointing this out. Jython thus uses a custom mechanism similar to PyPy's, which is also similar to atexit's. It should not be too hard to

Re: [Python-Dev] Destructors and Closing of File Objects

2013-04-29 Thread Nikolaus Rath
Armin Rigo ar...@tunes.org writes: Hi Nikolaus, On Sat, Apr 27, 2013 at 4:39 AM, Nikolaus Rath nikol...@rath.org wrote: It's indeed very informative, but it doesn't fully address the question because of the _pyio module which certainly can't use any custom C code. Does that mean that when

Re: [Python-Dev] enum instances

2013-04-29 Thread Nikolaus Rath
Marco Hemmelrath marco.hemmelr...@googlemail.com writes: class State(enum): idle = 0 busy = 1 idling = idle ideling = 0 together with the premises: 1. type(State.busy) == State 2. type(State) == enum State is a class, it just inherits from

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-27 Thread Nikolaus Rath
Steven D'Aprano st...@pearwood.info writes: I'm sorry, but all these suggestions are getting the API completely backwards by making the common case harder than the rare case. We're creating an Enum, right? So the *common case* is to populate it with enum values. 99% of the time, enumerated

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-27 Thread Nikolaus Rath
Guido van Rossum gu...@python.org writes: On Sat, Apr 27, 2013 at 10:04 AM, Ethan Furman et...@stoneleaf.us wrote: While this will certainly work, it means you can't have class variables that happen to be the same type as the enum -- so no int in an IntEnum, for example. The solution I like

Re: [Python-Dev] Destructors and Closing of File Objects

2013-04-26 Thread Nikolaus Rath
Guido van Rossum gu...@python.org writes: On Monday, April 15, 2013, Nikolaus Rath wrote: Brian Curtin br...@python.org javascript:; writes: On Fri, Apr 12, 2013 at 12:04 AM, Nikolaus Rath nikol...@rath.orgjavascript:; wrote: [ Note: I already asked this on http://stackoverflow.com

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-26 Thread Nikolaus Rath
Steven D'Aprano st...@pearwood.info writes: On 26/04/13 13:22, Greg wrote: On 26/04/2013 3:12 p.m., Glenn Linderman wrote: On 4/25/2013 7:49 PM, Nick Coghlan wrote: You couldn't create an enum of callables, but that would be a seriously weird thing to do anyway But aren't all classes

Re: [Python-Dev] Destructors and Closing of File Objects

2013-04-15 Thread Nikolaus Rath
Brian Curtin br...@python.org writes: On Fri, Apr 12, 2013 at 12:04 AM, Nikolaus Rath nikol...@rath.org wrote: [ Note: I already asked this on http://stackoverflow.com/questions/15917502 but didn't get any satisfactory answers] Sorry, but that's not a reason to repost your question

[Python-Dev] Destructors and Closing of File Objects

2013-04-11 Thread Nikolaus Rath
[ Note: I already asked this on http://stackoverflow.com/questions/15917502 but didn't get any satisfactory answers] Hello, The description of tempfile.NamedTemporaryFile() says: , | If delete is true (the default), the file is deleted as soon as it is | closed. ` In some

  1   2   >