Re: [Python-Dev] Code highlighting in tracker

2011-04-07 Thread Eugene Toder
Because tracker is ugly. Is this an unbiased opinion? :) Eugene ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

[Python-Dev] abstractmethod doesn't work in classes

2011-04-07 Thread Eugene Toder
Hello, I've found that abstractmethod and similar decorators don't work in classes, inherited from built-in types other than object. For example: import abc class MyBase(metaclass=abc.ABCMeta): @abc.abstractmethod def foo(): pass MyBase() Traceback (most recent call last):

Re: [Python-Dev] Policy for making changes to the AST

2011-04-04 Thread Eugene Toder
Ok, so it sounds like ast is *not* limited to CPython? That makes it harder to justify changing it just so as to ease the compilation process in CPython (as opposed to add new language features). The changes above are not just for CPython, but to simplify processing of AST in general, by

Re: [Python-Dev] Policy for versions of system python

2011-04-04 Thread Eugene Toder
To answer Eugene's question, there's no official policy but the comment at the top of Python/makeopcodetargets.py can indeed serve as an useful guideline. I wonder if we still have buildbots with 2.3 as the system Python, by the way. Ok, I'll use 2.3 as my target. Thanks. Eugene

[Python-Dev] Policy for versions of system python

2011-04-03 Thread Eugene Toder
Hello, CPython source code currently contains a number of python scripts (e.g Python/makeopcodetargets.py, Objects/typeslots.py, Parser/asdl_c.py) that are used during the build of the python interpreter itself. For this reason they are run with system installed python. What is the policy

[Python-Dev] Policy for making changes to the AST

2011-04-02 Thread Eugene Toder
Hello, While working on a rewrite of peephole optimizer that works on AST (http://bugs.python.org/issue11549) I had to make a few changes to the structure of AST. The changes are described in the issue. This raises the question -- what is the policy for making changes to the AST? Documentation

Re: [Python-Dev] Policy for making changes to the AST

2011-04-02 Thread Eugene Toder
However, I'm not sure we *can* do a general-purpose AST transformation that handles both new nodes and changes to existing nodes correctly for all applications. As long as both versions contain the same information we can write a transformation that does a near-perfect job. E.g. for my changes

Re: [Python-Dev] Policy for making changes to the AST

2011-04-02 Thread Eugene Toder
If it's do-able, your option 2 is probably the way to go. Out of the box, it may just need to raise an exception if asked to down-convert code that uses new constructs that can't readily be expressed using the old AST (I'm specifically thinking of the challenge of converting PEP 380's

Re: [Python-Dev] utf-8 encoding in checkins?

2011-03-27 Thread Eugene Toder
I'm not disputing that, and I understand that my current choice of mail reader limits me.  I was just asking if it would be possible (read: fairly easy) to only generate utf-8 when it was necessary. Isn't utf-8 itself same as ascii where no non-ascii symbols are used? Eugene

Re: [Python-Dev] Draft PEP and reference implementation of a Python launcher for Windows

2011-03-19 Thread Eugene Toder
Out of curiosity, what is your objection to having the child process? One of the problems is that parent process will not be able to kill launched script. Simply doing TerminateProcess will kill the launcher, leaving interpreter running. This can be partially fixed with job objects, though.

Re: [Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-15 Thread Eugene Toder
I think you guys are forgetting about FOR_ITER, listcomps, and the like. That is, IIRC, the reason loops use the block stack is because they put things on the regular stack, that need to be cleared off the stack when the loop is exited (whether normally or via an exception). Good point.

Re: [Python-Dev] Suggest reverting today's checkin (recursive constant folding in the peephole optimizer)

2011-03-14 Thread Eugene Toder
To give this a positive spin, here's a patch that implements constant folding on AST (it does few other optimizations on compiler data structures, so it replaces peephole over bytecode completely). http://bugs.python.org/issue11549 It passes make test, but of course more testing is needed.

Re: [Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-12 Thread Eugene Toder
There are also with blocks :-) (which use separate opcodes, although they are similar in principle to try/finally blocks) IIUC they use separate opcode, but the same block type (SETUP_FINALLY). There may be complications with nested try/finally blocks. You either need to generate separate

Re: [Python-Dev] Builtin open() too slow

2011-03-12 Thread Eugene Toder
Hi What OS and what file system you are using? Many file systems (e,g. ext2/3fs) handle large directories very poorly. A quick way to check if this has anything to do with Python is writing a small C program that opens these files and time it. Eugene On Sat, Mar 12, 2011 at 10:13 AM, Lukas Lueg

Re: [Python-Dev] Python3 regret about deleting list.sort(cmp=...)

2011-03-12 Thread Eugene Toder
Can sort have an option (and/or try to figure it itself) to calculate key for every comparison instead of caching them? This will have the same memory requirements as with cmp, but doesn't require rewriting code if you decide to trade speed for memory. Will this be much slower than with cmp? If

[Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP

2011-03-11 Thread Eugene Toder
Hello, What is the purpose of SETUP_LOOP instruction? From a quick look it seems like it just pushes the size of the loop into blocks stack; that size is only used by BREAK_LOOP instruction. BREAK_LOOP could just contain the target address directly, like CONTINUE_LOOP does. This would avoid

Re: [Python-Dev] Suggest reverting today's checkin (recursive constant folding in the peephole optimizer)

2011-03-11 Thread Eugene Toder
Experience shows that optimizations are always error prone, no matter what framework or internal representation you use. I don't think we should assume that simply rewriting all optimizations to work on AST will make them bug free once and for all. On the contrary, I think such a rewrite will

Re: [Python-Dev] Suggest reverting today's checkin (recursive constant folding in the peephole optimizer)

2011-03-11 Thread Eugene Toder
Experience shows that optimizations are always error prone, no matter what framework or internal representation you use. On that basis, I believe that we ought to declare peephole.c as being somewhat off-limits for further development (except for small adaptations if the underlying opcodes

Re: [Python-Dev] Suggest reverting today's checkin (recursive constant folding in the peephole optimizer)

2011-03-11 Thread Eugene Toder
One note on the patch: it allocates an extra stack which is dynamically grown; but there is no unittest to exercise the stack-growing code. Isn't this doing it? 1.20 +# Long tuples should be folded too. 1.21 +asm = dis_single(repr(tuple(range(1 1.22 +# One

Re: [Python-Dev] Bugs in thread_nt.h

2011-03-10 Thread Eugene Toder
I guess all this advice doesn't really apply to this case, though. The Microsoft API declares the parameter as a volatile*, indicating that they consider it proper usage of the API to declare the storage volatile. So ISTM that we should comply regardless of whether volatile is considered

Re: [Python-Dev] constant folding of -0

2011-03-10 Thread Eugene Toder
I've posted a patch. Eugene On Thu, Mar 10, 2011 at 3:30 PM, Mark Dickinson dicki...@gmail.com wrote: On Thu, Mar 10, 2011 at 2:17 AM, Eugene Toder elto...@gmail.com wrote: Indeed, see http://bugs.python.org/issue11244 Yes, I've noticed that too. However, if I'm not missing something, your

Re: [Python-Dev] constant folding of -0

2011-03-10 Thread Eugene Toder
(UTC) Eugene Toder elto...@gmail.com wrote: Indeed, see http://bugs.python.org/issue11244 Yes, I've noticed that too. However, if I'm not missing something, your patches do not address folding of -0. Btw, there's an alternative approach to allow recursive constant folding. Instead of keeping

[Python-Dev] constant folding of -0

2011-03-09 Thread Eugene Toder
Hello, I've noticed since version 3.2 python doesn't fold -0: Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07) def foo(): return -0 dis(foo) 1 0 LOAD_CONST 1 (0) 3 RETURN_VALUE Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) def foo(): return -0

Re: [Python-Dev] constant folding of -0

2011-03-09 Thread Eugene Toder
Indeed, see http://bugs.python.org/issue11244 Yes, I've noticed that too. However, if I'm not missing something, your patches do not address folding of -0. Btw, there's an alternative approach to allow recursive constant folding. Instead of keeping a stack of last constants, you can keep a