Re: [Python-Dev] 3to2 0.1 alpha 1 released

2009-08-31 Thread Joe Amenta
Thanks Brett and Sridhar for the info. 3to2's version info has been PEP386-ified, and the latest version can always be found at http://pypi.python.org/pypi/3to2/ (the previous link will now generate an error). --Joe On Mon, Aug 31, 2009 at 3:25 PM, Brett Cannon wrote: > On Mon, Aug 31, 2009 at

[Python-Dev] why different between staticmethod and classmethod on non-callable object?

2009-08-31 Thread xiaobing jiang
hi all: In the svn thunk tree, I find in file Object/funcobject.c, the two functions: sm_init and cm_init have a little different. the cm_init function will check the object is really callable, but the sm_init don't. the code like this: if (!PyCallable_Check(callable)) { PyErr_Format(Py

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Gregory P. Smith
On Mon, Aug 31, 2009 at 5:01 PM, Greg Ewing wrote: > Antoine Pitrou wrote: > > Did your coworker run any timings instead of basing his assumptions on >> bytecode >> size? >> > > In any case, what are you suggesting -- that the last value > returned by a function call in the body should be the > d

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Greg Ewing
Antoine Pitrou wrote: Did your coworker run any timings instead of basing his assumptions on bytecode size? In any case, what are you suggesting -- that the last value returned by a function call in the body should be the default return value? I don't think the unpredictability that would int

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Raymond Hettinger
I was just wondering if a bytecode for a superinstruction of the common sequence: 6 POP_TOP 7 LOAD_CONST 0 (None) 10 RETURN_VALUE might be worth it. [Collin Winter] I doubt it. You'd save a bit of stack manipulation, but since this will only appear at the end of a function, I'd be skeptica

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Antoine Pitrou
Gregory P. Smith krypto.org> writes: > > I was just wondering if a bytecode for a superinstruction of the common sequence: > 6 POP_TOP > 7 LOAD_CONST   0 (None) > 10 RETURN_VALUE > might be worth it. I think superinstructions in general would be a good thing to experiment, as wpytho

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Benjamin Peterson
2009/8/31 Gregory P. Smith : > I was just wondering if a bytecode for a superinstruction of the common > sequence: > > 6 POP_TOP >   7 LOAD_CONST   0 (None) > 10 RETURN_VALUE > > might be worth it. We could just utilize RETURN_VALUE's op argument.

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Collin Winter
On Mon, Aug 31, 2009 at 3:07 PM, Gregory P. Smith wrote: > > > On Mon, Aug 31, 2009 at 2:20 PM, Antoine Pitrou wrote: >> >> Gregory P. Smith krypto.org> writes: >> > >> > food for thought as noticed by a coworker who has been profiling some >> > hot code >> to optimize a library...If a function d

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Gregory P. Smith
On Mon, Aug 31, 2009 at 2:20 PM, Antoine Pitrou wrote: > Gregory P. Smith krypto.org> writes: > > > > food for thought as noticed by a coworker who has been profiling some hot > code > to optimize a library...If a function does not have a return statement we > return > None. Ironically this mak

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 15:06, P.J. Eby wrote: > At 02:57 PM 8/31/2009 -0700, Brett Cannon wrote: >> >> Ignoring that 'new' is not in Python 3.x (luckily 'types' is), I want >> a proper solution that doesn't require reconstructing every code >> object that I happen to import. > > Practicality beats

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread P.J. Eby
At 02:57 PM 8/31/2009 -0700, Brett Cannon wrote: Ignoring that 'new' is not in Python 3.x (luckily 'types' is), I want a proper solution that doesn't require reconstructing every code object that I happen to import. Practicality beats purity. ;-) (Especially if it allows importlib to run on

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Fred Drake
On Aug 31, 2009, at 4:47 PM, Antoine Pitrou wrote: I am really not opinionated on this one. I was just pointing out that choosing a non-obvious solution generally requires good reasons to do so. The marshal format compaction sounds like premature optimization, since nobody seems to have for

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 14:52, P.J. Eby wrote: > At 01:39 PM 8/31/2009 -0700, Brett Cannon wrote: >> >> On Mon, Aug 31, 2009 at 12:59, Brett Cannon wrote: >> > On Mon, Aug 31, 2009 at 12:27, Antoine Pitrou >> > wrote: >> >> Brett Cannon python.org> writes: >> >>> >> >>> I will plan to take this ap

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread P.J. Eby
At 01:39 PM 8/31/2009 -0700, Brett Cannon wrote: On Mon, Aug 31, 2009 at 12:59, Brett Cannon wrote: > On Mon, Aug 31, 2009 at 12:27, Antoine Pitrou wrote: >> Brett Cannon python.org> writes: >>> >>> I will plan to take this approach then; >>> http://bugs.python.org/issue6811 will track all of th

Re: [Python-Dev] PEP 3144: IP Address Manipulation Library for the Python Standard Library

2009-08-31 Thread Peter Moody
On Fri, Aug 28, 2009 at 2:31 AM, Nick Coghlan wrote: > Peter Moody wrote: >> If there are any more suggestions on the PEP or the code, please let me know. > > I noticed the new paragraphs on the IPv4 vs IPv6 types not being > comparable - is there a canonical ordering for mixed address lists > defi

Re: [Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Antoine Pitrou
Gregory P. Smith krypto.org> writes: > > food for thought as noticed by a coworker who has been profiling some hot code to optimize a library...If a function does not have a return statement we return None.  Ironically this makes the foo2 function below faster than the bar2 function at least as m

[Python-Dev] default of returning None hurts performance?

2009-08-31 Thread Gregory P. Smith
food for thought as noticed by a coworker who has been profiling some hot code to optimize a library... If a function does not have a return statement we return None. Ironically this makes the foo2 function below faster than the bar2 function at least as measured using bytecode size: Python 2.6.

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is s et to?

2009-08-31 Thread Antoine Pitrou
Brett Cannon python.org> writes: > > I should also mention that I am +0 on the marshal.load* change. I > could be convinced to try to pursue a mutable co_filenme direction, > but considering the BDFL likes the marshal.load* approach and it opens > up the possibility of compacting the marshal form

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 12:59, Brett Cannon wrote: > On Mon, Aug 31, 2009 at 12:27, Antoine Pitrou wrote: >> Brett Cannon python.org> writes: >>> >>> I will plan to take this approach then; >>> http://bugs.python.org/issue6811 will track all of this. Since this is >>> a 3.2 thing I am not going to

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 12:27, Antoine Pitrou wrote: > Brett Cannon python.org> writes: >> >> I will plan to take this approach then; >> http://bugs.python.org/issue6811 will track all of this. Since this is >> a 3.2 thing I am not going to rush to implement this. > > I still don't understand what

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is s et to?

2009-08-31 Thread Antoine Pitrou
Brett Cannon python.org> writes: > > I will plan to take this approach then; > http://bugs.python.org/issue6811 will track all of this. Since this is > a 3.2 thing I am not going to rush to implement this. I still don't understand what the point is of this complicated approach (adding an argumen

Re: [Python-Dev] 3to2 0.1 alpha 1 released

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 12:18, Sridhar Ratnakumar wrote: > On Wed, 26 Aug 2009 15:55:54 -0700, Joe Amenta wrote: > >> -- 3to2 is now registered with PyPI.  Did I do it right? > >> http://pypi.python.org/pypi/3to2/0.1%20alpha%201 > > Please fix the version number to not contain any whitespace chara

Re: [Python-Dev] runpy.py

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 06:36, Nick Coghlan wrote: > Chris Withers wrote: >> Nick Coghlan wrote: >>> The PEPs don't go into the process of how we actually hook the command >>> line up to the runpy module though - that's something you need to dig >>> into the main.c code to really understand. >> >>

Re: [Python-Dev] 3to2 0.1 alpha 1 released

2009-08-31 Thread Sridhar Ratnakumar
On Wed, 26 Aug 2009 15:55:54 -0700, Joe Amenta wrote: -- 3to2 is now registered with PyPI. Did I do it right? http://pypi.python.org/pypi/3to2/0.1%20alpha%201 Please fix the version number to not contain any whitespace characters. Also set the `version` argument in setup(..) in your set

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread P.J. Eby
At 09:33 AM 8/31/2009 -0700, Guido van Rossum wrote: Of course, tracking down all the code objects in the return value of marshal.load*() might be a bit tricky -- API-wise I still think that making it an argument to marshal.load*() might be simpler. Also it would preserve the purity of code objec

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 10:02, Guido van Rossum wrote: > On Mon, Aug 31, 2009 at 9:57 AM, Brett Cannon wrote: >> On Mon, Aug 31, 2009 at 09:33, Guido van Rossum wrote: >>> Hm... I still wonder if there would be bad side effects of making >>> co_filename writable, but I can't think of any, so maybe

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Guido van Rossum
On Mon, Aug 31, 2009 at 9:57 AM, Brett Cannon wrote: > On Mon, Aug 31, 2009 at 09:33, Guido van Rossum wrote: >> Hm... I still wonder if there would be bad side effects of making >> co_filename writable, but I can't think of any, so maybe you can make >> this work... The next step would be to not w

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 09:33, Guido van Rossum wrote: > On Mon, Aug 31, 2009 at 9:27 AM, Brett Cannon wrote: >> On Mon, Aug 31, 2009 at 08:10, Antoine Pitrou wrote: >>> Benjamin Peterson python.org> writes: > Why can't we simply make co_filename a writable attribute instead of >>> inven

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 06:13, Nick Coghlan wrote: > Brett Cannon wrote: >>> You can use the C implementation of io, _io, which has a full >>> buffering implementation. Of course, that also makes it a better >>> harder for other implementations which may wish to use importlib >>> because the io lib

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Guido van Rossum
On Mon, Aug 31, 2009 at 9:27 AM, Brett Cannon wrote: > On Mon, Aug 31, 2009 at 08:10, Antoine Pitrou wrote: >> Benjamin Peterson python.org> writes: >>> >>> > Why can't we simply make co_filename a writable attribute instead of >> inventing >>> > some complicated API? >>> >>> Because code objects

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Brett Cannon
On Mon, Aug 31, 2009 at 08:10, Antoine Pitrou wrote: > Benjamin Peterson python.org> writes: >> >> > Why can't we simply make co_filename a writable attribute instead of > inventing >> > some complicated API? >> >> Because code objects are supposed to be a immutable hashable object? > > Right, but

Re: [Python-Dev] deleting setdefaultencoding iin site.py is evil

2009-08-31 Thread Guido van Rossum
On Mon, Aug 31, 2009 at 7:49 AM, Robert Brewer wrote: > CherryPy 3.2 is now in beta, and mod_wsgi is nearly ready as well. Both > support Python 3. :) Excellent news! I just saw that PyYAML also suports 3.1. Slowly but surely, 3.1 is gaining traction... -- --Guido van Rossum (home page: http://w

Re: [Python-Dev] web apps in python 3

2009-08-31 Thread Robert Brewer
Chris Withers wrote: > Robert Brewer wrote: you could switch to Python 3.1, >>> I would love to, once Python 3 has a viable web app story... >> >> CherryPy 3.2 is now in beta, and mod_wsgi is nearly ready as well. Both >> support Python 3. :) > > My understanding was that the wsgi spec for Py

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is s et to?

2009-08-31 Thread Antoine Pitrou
Benjamin Peterson python.org> writes: > > > Why can't we simply make co_filename a writable attribute instead of inventing > > some complicated API? > > Because code objects are supposed to be a immutable hashable object? Right, but co_filename is used neither in tp_hash nor in tp_richcompare.

Re: [Python-Dev] web apps in python 3

2009-08-31 Thread Chris Withers
Robert Brewer wrote: you could switch to Python 3.1, I would love to, once Python 3 has a viable web app story... CherryPy 3.2 is now in beta, and mod_wsgi is nearly ready as well. Both support Python 3. :) My understanding was that the wsgi spec for Python 3 wasn't finished... Chris -- Si

Re: [Python-Dev] deleting setdefaultencoding iin site.py is evil

2009-08-31 Thread Robert Brewer
Chris Withers wrote: > Guido van Rossum wrote: > > Being adults about it also means when to give up. Chris, please stop > > arguing about this. > > Sure. Even if people had agreed to this change, it wouldn't end up in a > python release I could use for this project. > > > There are plenty of tech

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Benjamin Peterson
2009/8/31 Antoine Pitrou : > Brett Cannon python.org> writes: >> >> Now I can't change >> co_filename from Python as it's a read-only attribute and thus can't >> match this functionality in importlib w/o creating some custom code to >> allow me to specify the co_filename somewhere > > Why can't we

Re: [Python-Dev] runpy.py

2009-08-31 Thread Nick Coghlan
Chris Withers wrote: > Nick Coghlan wrote: >> The PEPs don't go into the process of how we actually hook the command >> line up to the runpy module though - that's something you need to dig >> into the main.c code to really understand. > > Yeah, main.c does quite a lot... ;-) > > This all spawned

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Antoine Pitrou
Nick Coghlan gmail.com> writes: > > I thought of that question as well, but the later exchange between Guido > and Brett made me realise that a lot more than the top level module code > object is affected here - the adjustment also needs to be propagated to > the code objects created by the modul

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Michael Foord
Nick Coghlan wrote: Antoine Pitrou wrote: Brett Cannon python.org> writes: Now I can't change co_filename from Python as it's a read-only attribute and thus can't match this functionality in importlib w/o creating some custom code to allow me to specify the co_filename somewhere

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Nick Coghlan
Antoine Pitrou wrote: > Brett Cannon python.org> writes: >> Now I can't change >> co_filename from Python as it's a read-only attribute and thus can't >> match this functionality in importlib w/o creating some custom code to >> allow me to specify the co_filename somewhere > > Why can't we simply

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Nick Coghlan
Brett Cannon wrote: >> You can use the C implementation of io, _io, which has a full >> buffering implementation. Of course, that also makes it a better >> harder for other implementations which may wish to use importlib >> because the io library would have to be completely implemented... > > True

Re: [Python-Dev] deleting setdefaultencoding iin site.py is evil

2009-08-31 Thread Chris Withers
Guido van Rossum wrote: Being adults about it also means when to give up. Chris, please stop arguing about this. Sure. Even if people had agreed to this change, it wouldn't end up in a python release I could use for this project. There are plenty of techniques you can use to get what you w

Re: [Python-Dev] Excluding the current path from module search path?

2009-08-31 Thread Chris Withers
Nick Coghlan wrote: Ah, OK - I see the problem now. However, I think the current behaviour is correct, it just needs to be documented better (probably noted in both the command line doco Not sure what you mean by this? regarding sys.path manipulation and in the doco for site.py). Agreed :-

Re: [Python-Dev] runpy.py

2009-08-31 Thread Chris Withers
Nick Coghlan wrote: The PEPs don't go into the process of how we actually hook the command line up to the runpy module though - that's something you need to dig into the main.c code to really understand. Yeah, main.c does quite a lot... ;-) This all spawned from a suggestion by Jim Fulton over

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is s et to?

2009-08-31 Thread Antoine Pitrou
Brett Cannon python.org> writes: > > Now I can't change > co_filename from Python as it's a read-only attribute and thus can't > match this functionality in importlib w/o creating some custom code to > allow me to specify the co_filename somewhere Why can't we simply make co_filename a writable

Re: [Python-Dev] Fast Implementation for ZIP decryption

2009-08-31 Thread Shashank Singh
On Mon, Aug 31, 2009 at 12:08 PM, Gregory P. Smith wrote: > > > On Sun, Aug 30, 2009 at 10:40 PM, Jeroen Ruigrok van der Werven < > asmo...@in-nomine.org> wrote: > >> -On [20090831 06:29], Collin Winter (coll...@gmail.com) wrote: >> >Are there any application

Re: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

2009-08-31 Thread Gregory P. Smith
On Sun, Aug 30, 2009 at 5:24 PM, Guido van Rossum wrote: > On Sun, Aug 30, 2009 at 4:28 PM, Brett Cannon wrote: > > I am going through and running the entire test suite using importlib > > to ferret out incompatibilities. I have found a bunch, although all > > rather minor (raising a different ex