[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

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: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive

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 _

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 red

[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 regardin

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 yie

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 chang

[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 for

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] Proposal for Python 3.3: dependence injection

2011-03-24 Thread Eugene Toder
> 2. The level at which the dependency injection works (function > arguments, class attributes, module globals) needs to be decided +1. The scope of parameter needs to be specified. If the scope is global, this can be achieved pretty easily -- declare some of the imports in particular modules to b

Re: [Python-Dev] Attributes access with dict

2011-03-24 Thread Eugene Toder
> My point is that I don't see the distinction between avoiding using dicts > with well-known keys and wanting to access a dict with attribute access > (which is where this started). Seems the same to me. I think using dict with well-known keys is what makes people want dict with attribute access.

Re: [Python-Dev] Attributes access with dict

2011-03-24 Thread Eugene Toder
> Although we do something similar with namedtuple (instead of using a > dict), so it's not like we have a strict distinction. Named tuple is a convenience to avoid creating boilerplate classes (or resorting to use dict with well-known keys). Names in named tuple are not data, only values. In dict

Re: [Python-Dev] Hg: inter-branch workflow

2011-03-21 Thread Eugene Toder
> Not if the changes you want to suppress are actually also on the same > branch as the one whose mainline you are trying to see (which they > typically are, with the branch typically being "default"). Right, that would amount to not using named branches. But if you develop on a named feature-bran

Re: [Python-Dev] Hg: inter-branch workflow

2011-03-21 Thread Eugene Toder
> Bazaar apparently has a notion of mainline whereas Mercurial believes > that all changesets are created equal.  The tools are different. Mercurial has named branches. When viewing history you can restrict it to just one named branch, which, I think, will have an effect similar to "mainline". Eu

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. Eug

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. Comm

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 go

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] 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 separa

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 LOAD

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 op

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 intro

[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 SETUP_

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

2011-03-10 Thread Eugene Toder
Well, that was just a though. You're right that long runs of constants can appear, and it's better to avoid pathological behaviour in such cases. Your second path looks good. Eugene On Thu, Mar 10, 2011 at 6:30 PM, Antoine Pitrou wrote: > On Thu, 10 Mar 2011 02:17:34 + (UTC) &

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 wrote: > On Thu, Mar 10, 2011 at 2:17 AM, Eugene Toder wrote: >>> Indeed, see http://bugs.python.org/issue11244 >> >> Yes, I've noticed that too. However, if I'm not missin

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 considere

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 po

[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