Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Steve Dower
It's only a macro system when you generate code in unexpected/unobvious places with it. This is more like inspect.getsource(), but going straight to the AST. Cheers, Steve Top-posted from my Windows Phone From: Greg Ewing Sent:

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Ben Hoyt
Thanks. Good point about python-ideas -- I was thinking that after I sent it too. I'll repost there soon. Out of interest, what specifically were you referring to as "definitely cool" here: LINQ-style generator expressions that build SQL ala PonyORM, or the more general feature of enabling AST acc

[Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread Eric Snow
(see http://bugs.python.org/issue16991) I an working on resolving an intermittent segfault that my C OrderedDict patch introduces. The failure happens in test_configparser (RawConfigParser uses OrderedDict internally), but only sporadically. However, Ned pointed out to me that it appears to be r

Re: [Python-Dev] Status of PEP 484 and the typing module

2015-05-21 Thread Guido van Rossum
Hi Mark, We're down to the last few items here. I'm CC'ing python-dev so folks can see how close we are. I'll answer point by point. On Thu, May 21, 2015 at 6:24 AM, Mark Shannon wrote: > Hi, > > The PEP itself is looking fairly good. > I hope you'll accept it at least provisionally so we can

Re: [Python-Dev] Status of PEP 484 and the typing module

2015-05-21 Thread Mark Shannon
On 21/05/15 16:01, Guido van Rossum wrote: Hi Mark, We're down to the last few items here. I'm CC'ing python-dev so folks can see how close we are. I'll answer point by point. On Thu, May 21, 2015 at 6:24 AM, Mark Shannon mailto:m...@hotpy.org>> wrote: Hi, The PEP itself is looking

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread MRAB
On 2015-05-21 15:55, Eric Snow wrote: (see http://bugs.python.org/issue16991) I an working on resolving an intermittent segfault that my C OrderedDict patch introduces. The failure happens in test_configparser (RawConfigParser uses OrderedDict internally), but only sporadically. However, Ned p

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Guido van Rossum
Dang it. :-) I just want to encourage you to continue pursuing this idea, one way or another. On Thu, May 21, 2015 at 7:01 AM, Ben Hoyt wrote: > Thanks. Good point about python-ideas -- I was thinking that after I sent > it too. I'll repost there soon. > > Out of interest, what specifically were

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Ben Hoyt
Heh, thanks. :-) On Thu, May 21, 2015 at 2:17 PM, Guido van Rossum wrote: > Dang it. :-) I just want to encourage you to continue pursuing this idea, > one way or another. > > On Thu, May 21, 2015 at 7:01 AM, Ben Hoyt wrote: > >> Thanks. Good point about python-ideas -- I was thinking that afte

Re: [Python-Dev] Status of PEP 484 and the typing module

2015-05-21 Thread Guido van Rossum
Things are looking up. I think we're down to a very small number of issues where we still disagree -- hopefully you'll allow me some leeway. :-) On Thu, May 21, 2015 at 8:45 AM, Mark Shannon wrote: > > > On 21/05/15 16:01, Guido van Rossum wrote: > >> Hi Mark, >> >> We're down to the last few it

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread Eric Snow
Good catch. Unfortunately, sticking "keys = ((PyDictObject *)od)->ma_keys;" right after "hash = ..." did not make a difference. I still get the same segfault. -eric On Thu, May 21, 2015 at 11:17 AM, MRAB wrote: > On 2015-05-21 15:55, Eric Snow wrote: >> >> (see http://bugs.python.org/issue16991

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread MRAB
On 2015-05-21 22:52, Eric Snow wrote: > Good catch. Unfortunately, sticking "keys = ((PyDictObject > *)od)->ma_keys;" right after "hash = ..." did not make a difference. > I still get the same segfault. So, does it change sometimes? > > On Thu, May 21, 2015 at 11:17 AM, MRAB wrote: > > On 20

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread Eric Snow
On Thu, May 21, 2015 at 4:06 PM, MRAB wrote: > On 2015-05-21 22:52, Eric Snow wrote: >> Good catch. Unfortunately, sticking "keys = ((PyDictObject >> *)od)->ma_keys;" right after "hash = ..." did not make a difference. >> I still get the same segfault. > > So, does it change sometimes? The segfa

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread MRAB
On 2015-05-21 23:17, Eric Snow wrote: > On Thu, May 21, 2015 at 4:06 PM, MRAB wrote: > > On 2015-05-21 22:52, Eric Snow wrote: > >> Good catch. Unfortunately, sticking "keys = ((PyDictObject > >> *)od)->ma_keys;" right after "hash = ..." did not make a difference. > >> I still get the same segfa

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread Eric Snow
On Thu, May 21, 2015 at 4:41 PM, MRAB wrote: > On 2015-05-21 23:17, Eric Snow wrote: >> The segfault is consistent if I use the same seed (e.g. 7): >> >> PYTHONHASHSEED=7 ./python -m test.regrtest -m test_basic >> test_configparser >> >> Some seeds always segfault and some seeds never segfault.

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Greg Ewing
Steve Dower wrote: It's only a macro system when you generate code in unexpected/unobvious places with it. This is more like inspect.getsource(), but going straight to the AST. Is it really that much different? The end result is the same -- the user writes something that looks like a Python ex

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread MRAB
On 2015-05-22 00:22, Eric Snow wrote: On Thu, May 21, 2015 at 4:41 PM, MRAB wrote: > On 2015-05-21 23:17, Eric Snow wrote: >> The segfault is consistent if I use the same seed (e.g. 7): >> >> PYTHONHASHSEED=7 ./python -m test.regrtest -m test_basic >> test_configparser >> >> Some seeds alway

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread Eric Snow
On Thu, May 21, 2015 at 5:55 PM, MRAB wrote: > I'm not looking at the use of "PyTuple_Pack". As I understand it, > "PyTuple_Pack" borrows the > references of the objects passed, and when the tuple itself is DECREFed, > those objects will be > DECREFed >From the docs [1] it seems that PyTuple_Pack

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Ethan Furman
On 05/21/2015 04:33 PM, Greg Ewing wrote: Steve Dower wrote: It's only a macro system when you generate code in unexpected/unobvious places with it. This is more like inspect.getsource(), but going straight to the AST. Is it really that much different? The end result is the same -- the user

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread MRAB
On 2015-05-22 01:12, Eric Snow wrote: On Thu, May 21, 2015 at 5:55 PM, MRAB wrote: > I'm not looking at the use of "PyTuple_Pack". As I understand it, > "PyTuple_Pack" borrows the > references of the objects passed, and when the tuple itself is DECREFed, > those objects will be > DECREFed >From

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Greg Ewing
Ethan Furman wrote: I think the key difference is that the AST is not going to be converted to run different Python code under Python, but under some other language -- presumably to implement the semantics of the Python snippet. If the semantics were exactly the same as the Python snippet, the

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread Eric Snow
On Thu, May 21, 2015 at 6:22 PM, MRAB wrote: > Oh, well, I'll keep looking... Thanks! -eric ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/pyth

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Peter Ludemann via Python-Dev
On 21 May 2015 at 17:12, Ethan Furman wrote: > On 05/21/2015 04:33 PM, Greg Ewing wrote: > >> Steve Dower wrote: >> >>> >>> It's only a macro system when you generate code in unexpected/unobvious >>> places with it. This is more like inspect.getsource(), but going straight >>> to the AST. >>> >>

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Steve Dower
The semantics could be the same while the execution plan is different, just like numba compiled code runs with the same semantics as the original. A better way of getting the AST than decompiling byte code is all that's being asked for. Maybe not easy to do in the general case, but certainly not

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Ben Hoyt
FYI, I've re-posted this on python-ideas now: https://mail.python.org/pipermail/python-ideas/2015-May/033621.html -Ben On Wed, May 20, 2015 at 10:31 PM, Guido van Rossum wrote: > Hey Ben, this is probably a better topic for python-ideas. I'll warn you > that a hurdle for ideas like this is that

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Ethan Furman
On 05/21/2015 05:28 PM, Greg Ewing wrote: Ethan Furman wrote: I think the key difference is that the AST is not going to be converted to run different Python code under Python, but under some other language -- presumably to implement the semantics of the Python snippet. If the semantics wer

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Greg
On 22/05/2015 1:33 p.m., Ethan Furman wrote: Going back to the OP: select(c for c in Customer if sum(c.orders.price) > 1000) which compile into and run SQL like this: SELECT "c"."id" FROM "Customer" "c" LEFT JOIN "Order" "order-1" ON "c"."id" = "order-1"."customer" GROUP B

Re: [Python-Dev] segfaults due to hash randomization in C OrderedDict

2015-05-21 Thread Eric Snow
On Thu, May 21, 2015 at 6:22 PM, MRAB wrote: > Oh, well, I'll keep looking... I've posted some data to http://bugs.python.org/issue16991 that I hope will shed some light on the issue. We can continue the conversation there. -eric ___ Python-Dev mailin