Re: [Python-Dev] A new JIT compiler for a faster CPython?

2012-07-17 Thread Stefan Behnel
Alex Gaynor, 18.07.2012 03:24: > Victor Stinner writes: >> Example: >> >> a = GETLOCAL(0); # "a" >> if (a == NULL) /* error */ >> b = GETLOCAL(1); # "b" >> if (b == NULL) /* error */ >> return PyNumber_Add(a, b); >> >> >> I don't expect to run a program 10x faster, but I would be happy if

Re: [Python-Dev] A new JIT compiler for a faster CPython?

2012-07-17 Thread Stefan Behnel
mar...@v.loewis.de, 18.07.2012 07:53: > [Victor Stinner] >> I don't want to write my own library to generate machine code. > > I plan to use nanojit. As I said, generating machine code is the uninteresting part of it and won't give you much of a win. The changes you make to the way the code works

[Python-Dev] PEP 366 is unclear about what it specifies

2012-08-07 Thread Stefan Behnel
Hi, could someone please add a sentence to PEP 366 that describes the actual content of the new "__package__" attribute (and thus, the PEP)? http://www.python.org/dev/peps/pep-0366/ I had to read through almost the entire document to be assured that "__package__" is really supposed to contain a

Re: [Python-Dev] AST optimizer implemented in Python

2012-08-11 Thread Stefan Behnel
Chris Angelico, 12.08.2012 01:22: >> Other idea to improve this optimizer: >> - move invariant out of loops. Example: "x=[]; for i in range(10): >> x.append(i)" => "x=[]; x_append=x.append; for i in range(10): >> x_append(i)". Require to infer the type of variables. > > But this is risky. It's th

Re: [Python-Dev] AST optimizer implemented in Python

2012-08-11 Thread Stefan Behnel
Stefan Behnel, 12.08.2012 06:42: > Chris Angelico, 12.08.2012 01:22: >>> Other idea to improve this optimizer: >>> - move invariant out of loops. Example: "x=[]; for i in range(10): >>> x.append(i)" => "x=[]; x_append=x.append; for i in range(10)

Re: [Python-Dev] AST optimizer implemented in Python

2012-08-11 Thread Stefan Behnel
Victor Stinner, 11.08.2012 20:30: > I started to implement an AST optimizer in Python. It's easy to create > a new AST tree, so I'm surprised that I didn't find any existing > project. > > https://bitbucket.org/haypo/misc/src/tip/python/ast_optimizer.py Since you're about to do pretty much the sa

Re: [Python-Dev] AST optimizer implemented in Python

2012-08-11 Thread Stefan Behnel
"Martin v. Löwis", 11.08.2012 23:27: >>> +1 We should add some form of setastoptimizer API in 3.4. Please start a >>> PEP for this. It would be nice to include the ability to properly cache >>> the >>> ast optimizer output so that it does not have to run every time (in pyc >>> files or similar,

Re: [Python-Dev] AST optimizer implemented in Python

2012-08-12 Thread Stefan Behnel
Stefan Behnel, 12.08.2012 08:00: > Victor Stinner, 11.08.2012 20:30: >> I started to implement an AST optimizer in Python. It's easy to create >> a new AST tree, so I'm surprised that I didn't find any existing >> project. >> >> https://bitbucke

Re: [Python-Dev] 3.3 str timings

2012-08-21 Thread Stefan Behnel
Xavier Morel, 21.08.2012 19:56: > On 21 août 2012, at 19:25, Steven D'Aprano wrote: >> On 21/08/12 23:04, Victor Stinner wrote: >>> I don't like the timeit module for micro benchmarks, it is really >>> unstable (default settings are not written for micro benchmarks). >> [...] >>> I wrote my own be

Re: [Python-Dev] Release of astoptimizer 0.3

2012-09-11 Thread Stefan Behnel
Nick Coghlan, 11.09.2012 14:57: > On Tue, Sep 11, 2012 at 8:41 PM, Victor Stinner wrote: >> * Loop: replace range() with xrange() on Python 2, and list with >> tuple. Examples: >> >> - for x in range(n): ... => for x in xrange(n): ... >> - for x in [1, 2, 3]: ... => for x in (1, 2, 3): ... >

Re: [Python-Dev] Release of astoptimizer 0.3

2012-09-11 Thread Stefan Behnel
Serhiy Storchaka, 11.09.2012 20:48: > set([1, 2, 3]) => {1, 2, 3} > set([x for ...]) => {x for ...} > dict([(k, v) for ...]) => {k: v for ...} > dict((k, v) for ...) => {k: v for ...} > ''.join([s for ...]) => ''.join(s for ...) > a.extend([s for ...]) => a.extend(s for ...) > (f(x) for x in a) =>

Re: [Python-Dev] [Python-checkins] cpython: Add a few entries to whatsnew/3.3.rst.

2012-09-27 Thread Stefan Behnel
Ezio Melotti, 26.09.2012 18:30: > """ > The problem is that the standard allows some charref to end without a > ';', but not all of them. > > So both "Éric" and Éric" will be parsed as "Éric", but > only "αcentauri" will result in "αcentauri" -- "&alphacentauri" > will be returned unchanged. > """

Re: [Python-Dev] Python 3.3 vs. Python 2.7 benchmark results (again, but this time more solid numbers)

2012-10-28 Thread Stefan Behnel
Tim Delaney, 27.10.2012 22:53: On 28 October 2012 07:40, Mark Shannon wrote: I suspect that stating and loading the .pyc files is responsible for most of the overhead. PyRun starts up quite a lot faster thanks to embedding all the modules in the executable: http://www.egenix.com/**products/pyth

Re: [Python-Dev] Python 3.3 vs. Python 2.7 benchmark results (again, but this time more solid numbers)

2012-10-28 Thread Stefan Behnel
Stefan Behnel, 28.10.2012 08:22: Tim Delaney, 27.10.2012 22:53: How much of an effect would it have on startup times and these benchmarks if Cython-compiled extensions were used? Depends on what and how much code you use. If you compile everything into one big module that "imports"

Re: [Python-Dev] Python 3.3 vs. Python 2.7 benchmark results (again, but this time more solid numbers)

2012-10-30 Thread Stefan Behnel
Tim Delaney, 28.10.2012 20:48: On 28 October 2012 18:22, Stefan Behnel wrote: How much of an effect would it have on startup times and these benchmarks if Cython-compiled extensions were used? Depends on what and how much code you use. If you compile everything into one big module that

[Python-Dev] Make extension module initialisation more like Python module initialisation

2012-11-08 Thread Stefan Behnel
Hi, I suspect that this will be put into a proper PEP at some point, but I'd like to bring this up for discussion first. This came out of issues 13429 and 16392. http://bugs.python.org/issue13429 http://bugs.python.org/issue16392 Stefan The problem === Python modules and extension mo

Re: [Python-Dev] Make extension module initialisation more like Python module initialisation

2012-11-08 Thread Stefan Behnel
M.-A. Lemburg, 08.11.2012 14:01: > On 08.11.2012 13:47, Stefan Behnel wrote: >> I suspect that this will be put into a proper PEP at some point, but I'd >> like to bring this up for discussion first. This came out of issues 13429 >> and 16392. >> >> http:/

Re: [Python-Dev] Make extension module initialisation more like Python module initialisation

2012-11-08 Thread Stefan Behnel
Stefan Behnel, 08.11.2012 14:20: > M.-A. Lemburg, 08.11.2012 14:01: >> On 08.11.2012 13:47, Stefan Behnel wrote: >>> I suspect that this will be put into a proper PEP at some point, but I'd >>> like to bring this up for discussion first. This came out of issues 1

[Python-Dev] Update - Re: Make extension module initialisation more like Python module initialisation

2012-11-08 Thread Stefan Behnel
Hi, here's an updated proposal, adopting Marc-Andre's improvement that uses a new field in the PyModuleDef struct to register the callback. Note that this change no longer keeps up binary compatibility, which may or may not be acceptable for Python 3.4. Stefan The problem === Python mo

Re: [Python-Dev] Make extension module initialisation more like Python module initialisation

2012-11-08 Thread Stefan Behnel
Hi Brett, thanks for the feedback. Brett Cannon, 08.11.2012 15:41: > On Thu, Nov 8, 2012 at 7:47 AM, Stefan Behnel wrote: >> I propose to split the extension module initialisation into two steps in >> Python 3.4, in a backwards compatible way. >> >> Step 1: The curre

Re: [Python-Dev] Make extension module initialisation more like Python module initialisation

2012-11-08 Thread Stefan Behnel
Brett Cannon, 08.11.2012 16:06: > On Thu, Nov 8, 2012 at 10:00 AM, Stefan Behnel wrote: > >> Hi Brett, >> >> thanks for the feedback. >> >> Brett Cannon, 08.11.2012 15:41: >>> On Thu, Nov 8, 2012 at 7:47 AM, Stefan Behnel wrote: >>>> I

Re: [Python-Dev] performance of {} versus dict()

2012-11-14 Thread Stefan Behnel
Chris Angelico, 14.11.2012 14:18: > On Wed, Nov 14, 2012 at 8:12 PM, Chris Withers wrote: >> I suspect I'm not the only one who finds: >> >> a_dict = dict( >> x = 1, >> y = 2, >> z = 3, >> ... >> ) >> >> ...easier to read than: >> >> a_dict = { >> 'x':1, >> 'y':2, >>

Re: [Python-Dev] performance of {} versus dict()

2012-11-14 Thread Stefan Behnel
Donald Stufft, 15.11.2012 00:00: > $ pypy -m timeit 'dict()' > 10 loops, best of 3: 0.000811 usec per loop > > $ pypy -m timeit '{}' > 10 loops, best of 3: 0.000809 usec per loop > > $ pypy -m timeit 'def md(**kw): return kw; md()' > 1 loops, best of 3: 0.0182 usec per

Re: [Python-Dev] performance of {} versus dict()

2012-11-14 Thread Stefan Behnel
Chris Withers, 15.11.2012 08:14: > On 15/11/2012 06:32, Stefan Behnel wrote: >> Donald Stufft, 15.11.2012 00:00: >>> $ pypy -m timeit 'dict()' >>> 10 loops, best of 3: 0.000811 usec per loop >>> >>> $ pypy -m timeit '

Re: [Python-Dev] performance of {} versus dict(), de fmd(**kw): return kw trumps all ; -)

2012-11-15 Thread Stefan Behnel
Greg Ewing, 15.11.2012 11:48: > mar...@v.loewis.de wrote: >> It's faster than calling dict() because the dict code will >> create a second dictionary, and discard the keywords dictionary. > > Perhaps in the case where dict() is called with keyword > args only, it could just return the passed-in ke

Re: [Python-Dev] Proposing "Argument Clinic", a new way of specifying arguments to builtins for CPython

2012-12-04 Thread Stefan Behnel
Larry Hastings, 03.12.2012 23:29: > Say there, the Python core development community! Have I got > a question for you! > > *ahem* > > Which of the following four options do you dislike least? ;-) > > 1) CPython continues to provide no "function signature" >objects (PEP 362) or inspect.getf

Re: [Python-Dev] Boost Software License

2013-01-27 Thread Stefan Behnel
Serhiy Storchaka, 27.01.2013 17:52: > Is Boost Software License [1] compatible with Python license? Can I steal > some code from Boost library [2]? > > [1] http://www.boost.org/LICENSE_1_0.txt > [2] http://www.boost.org/ Depends on what you want to do with it after stealing it. Assuming you want

[Python-Dev] Why does Signature.from_function() have to check the type of its argument?

2013-02-08 Thread Stefan Behnel
Hi, I'm wondering about the purpose of this code in inspect.Signature.from_function(): """ if not isinstance(func, types.FunctionType): raise TypeError('{!r} is not a Python function'.format(func)) """ Is there any reason why this method would have to explicitly check the type of its

Re: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?

2013-02-08 Thread Stefan Behnel
Nick Coghlan, 08.02.2013 16:08: > On Sat, Feb 9, 2013 at 12:09 AM, Stefan Behnel wrote: >> I'm wondering about the purpose of this code in >> inspect.Signature.from_function(): >> >> """ >> if not isinstance(func, types.FunctionType): >

Re: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?

2013-02-08 Thread Stefan Behnel
Nick Coghlan, 08.02.2013 16:20: > On Sat, Feb 9, 2013 at 1:06 AM, Benjamin Peterson wrote: >> 2013/2/8 Stefan Behnel: >>> I'm wondering about the purpose of this code in >>> inspect.Signature.from_function(): >>> >>> """ >&

Re: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?

2013-02-08 Thread Stefan Behnel
PJ Eby, 08.02.2013 19:46: > On Fri, Feb 8, 2013 at 10:54 AM, Stefan Behnel wrote: >> Nick Coghlan, 08.02.2013 16:20: >>> On Sat, Feb 9, 2013 at 1:06 AM, Benjamin Peterson wrote: >>>> 2013/2/8 Stefan Behnel: >>>>> I'm wondering about the purpose of

Re: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?

2013-02-08 Thread Stefan Behnel
Stefan Behnel, 08.02.2013 22:14: > PJ Eby, 08.02.2013 19:46: >> On Fri, Feb 8, 2013 at 10:54 AM, Stefan Behnel wrote: >>> Nick Coghlan, 08.02.2013 16:20: >>>> On Sat, Feb 9, 2013 at 1:06 AM, Benjamin Peterson wrote: >>>>> 2013/2/8 Stefan Behnel: >&g

Re: [Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement

2013-02-10 Thread Stefan Behnel
Antoine Pitrou, 10.02.2013 15:28: > On Mon, 11 Feb 2013 00:09:55 +1000 Nick Coghlan wrote: >> As far as the maintenance burden goes, the patch to enable PEP 422 for >> types.new_class() is trivial: >> >> -return meta(name, bases, ns, **kwds) >> +cls = meta(name, bases, ns, **kwds) >> +t

<    2   3   4   5   6   7