Re: [Python-Dev] [Python-checkins] whatever happened to string.partition ?

2006-05-25 Thread skip
>> skip? was this a real design or a Py3K bluesky idea? Just about nothing I do is a real design. I don't remember the weather conditions that day either. I was probably just noodling around based upon discussions on python-dev that were mutated in my brain by gamma rays from Alpha Centau

Re: [Python-Dev] [Python-checkins] whatever happened to string.partition ?

2006-05-25 Thread Guido van Rossum
On 5/25/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Raymond Hettinger wrote: > > > IIRC, Skip had developed a smart version that returned lazy string > > objects that kept a reference and pointers to the original string > > (instead of making its own copy of the string components). The string

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Greg Ewing
Steve Holden wrote: > In actual fact the effbot has lately found itself so permeated with > Windows that it has become constituionally incapable of using a forward > slash. Don't know what's with the square brackets though ... I was thinking maybe that message had resulted from a Windows and a

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Greg Ewing
Tim Peters wrote: > PyLong_FromString() only sees the starting > address, and-- as it always does --parses until it hits a character > that doesn't make sense for the input base. This is the bug, then. long() shouldn't be using PyLong_FromString() to convert its argument, but something that takes

Re: [Python-Dev] whatever happened to string.partition ?

2006-05-25 Thread Shane Holloway (IEEE)
I will certainly look forward to using it. On May 25, 2006, at 16:21, Fredrik Lundh wrote: > does anyone remember? given what we're currently working on, > implementing it would take roughly no time at all. do people still > think it's a good idea ? > > > > __

Re: [Python-Dev] Returning int instead of long from struct when possible for performance

2006-05-25 Thread Tim Peters
[Bob Ippolito] > ... > Unfortunately, this change to the struct module slightly alters the > documented API for the following format codes: I, L, q, Q. Currently > it is documented that those format codes will always return longs, > regardless of their value. I view that more as having documented

[Python-Dev] Returning int instead of long from struct when possible for performance

2006-05-25 Thread Bob Ippolito
Python ints are a heck of a lot faster to work with than Python longs and have the additional benefit that psyco can optimize the hell out of int but can't do anything at all for long. This is important because psyco is currently in pretty wide-spread use amongst people who need to squeeze

Re: [Python-Dev] whatever happened to string.partition ?

2006-05-25 Thread Raymond Hettinger
Giovanni Bajo wrote: Fredrik Lundh wrote: does anyone remember? given what we're currently working on, implementing it would take roughly no time at all. do people still think it's a good idea ? I had enquired this before but got no answer. I assume nobody's workin

Re: [Python-Dev] This

2006-05-25 Thread Raymond Hettinger
Steve Holden wrote: > > This reminds me I am tasked with trying to find out what the interface > to timeit.py is supposed to look like. Raymond, your name has been > mentioned as someone who took part int he discussions. Google hasn't > given me a lot to go on. Anyone? > IIRC, Guido's words we

Re: [Python-Dev] whatever happened to string.partition ?

2006-05-25 Thread Giovanni Bajo
Fredrik Lundh wrote: > does anyone remember? given what we're currently working on, > implementing it would take roughly no time at all. do people still > think it's a good idea ? > > I had enquired this before but got no answer. I assume nobody's working on it at the moment. I also proposed

Re: [Python-Dev] [Python-checkins] whatever happened to string.partition ?

2006-05-25 Thread Raymond Hettinger
Fredrik Lundh wrote: Yes. It went to my todo list and is awaiting some free raymond-cycles to finish it up. I've been task saturated of late but would like to get this a number of other patches complete for Py2.5. no need to wait for any raymond-cycles here; just point me

Re: [Python-Dev] whatever happened to string.partition ?

2006-05-25 Thread Fredrik Lundh
Fredrik Lundh wrote: > no need to wait for any raymond-cycles here; just point me to the latest > version of the proposal, and it'll be in the trunk within 30 minutes. are these still valid? http://mail.python.org/pipermail/python-dev/2005-August/055764.html http://mail.python.org/pip

Re: [Python-Dev] 2.5a2 try/except slow-down: Convert to type?

2006-05-25 Thread Sean Reifschneider
>Brett provided the following direction: > >Right, I meant change how it (BaseException) is written. Right now > >it uses PyMethodDef for magic methods and just uses PyType_New() > >as a constructor. I was wondering if, for some reason, it would be > >faster if you used a PyType_Type defi

[Python-Dev] This

2006-05-25 Thread Steve Holden
Raymond Hettinger wrote: > Fredrik Lundh wrote: > > >>does anyone remember? given what we're currently working on, >>implementing it would take roughly no time at all. do people still >>think it's a good idea ? >> >> >> >> >> > > > Yes. It went to my todo list and is awaiting some free r

[Python-Dev] whatever happened to string.partition ?

2006-05-25 Thread Fredrik Lundh
does anyone remember? given what we're currently working on, implementing it would take roughly no time at all. do people still think it's a good idea ? ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Georg Brandl
Georg Brandl wrote: > Martin v. Löwis wrote: >> Fredrik Lundh wrote: >>> >>> -1 * (1, 2, 3) >>> () >>> >>> -(1, 2, 3) >>> Traceback (most recent call last): >>>File "", line 1, in >>> TypeError: bad operand type for unary - >>> >>> We Really Need To Fix This! >> >> I can't find this incons

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Georg Brandl
Tim Peters wrote: > [Raymond Hettinger] > ... >> Also, I'm not clear on the rationale for transforming negative >> repetition counts to zero instead of raising an exception. > > There are natural use cases. Here's one: you have a string and want > to right-justify it to 80 columns with blanks if

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Steve Holden
Fredrik Lundh wrote: > Guido van Rossum wrote: > > >>>We Really Need To Fix This! >>> >>>[\F] >> >>Doesn't the real effbot have /F as sig? > > > yeah, we've had some trouble with fake bots lately. I mean, there's a > timbot posting to this thread, but I know for sure that the real Tim got >

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Fredrik Lundh
Guido van Rossum wrote: >> We Really Need To Fix This! >> >> [\F] > > Doesn't the real effbot have /F as sig? yeah, we've had some trouble with fake bots lately. I mean, there's a timbot posting to this thread, but I know for sure that the real Tim got tired of hacking on Python earlier tonig

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Tim Peters
[Raymond Hettinger] ... > Also, I'm not clear on the rationale for transforming negative > repetition counts to zero instead of raising an exception. There are natural use cases. Here's one: you have a string and want to right-justify it to 80 columns with blanks if it's shorter than 80. s

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Guido van Rossum
On 5/25/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > Fredrik Lundh wrote: > > > >>> -1 * (1, 2, 3) > >() > > >>> -(1, 2, 3) > >Traceback (most recent call last): > > File "", line 1, in > >TypeError: bad operand type for unary - > > > >We Really Need To Fix This! > > > > > > The second one

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Tim Peters
[Fredrik] > >>> -1 * (1, 2, 3) > () > >>> -(1, 2, 3) > Traceback (most recent call last): >File "", line 1, in > TypeError: bad operand type for unary - > > We Really Need To Fix This! What's broken? It's generally true that n*s == s*n == empty_container_of_type_type(s) whenever s is

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Raymond Hettinger
Fredrik Lundh wrote: > >>> -1 * (1, 2, 3) >() > >>> -(1, 2, 3) >Traceback (most recent call last): > File "", line 1, in >TypeError: bad operand type for unary - > >We Really Need To Fix This! > > The second one doesn't bug me. Unary minus on a sequence is meaningless. The first is a bit o

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Sean Reifschneider
On Thu, May 25, 2006 at 09:06:49PM +, Georg Brandl wrote: >Don't tell me that! I was actually working on a patch right now... While undoubtedly a performance patch, it wasn't on the list of tasks to do today. You risk Steve's wrath! Thanks, Sean -- In the end, we will remember not the word

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Martin v. Löwis
Ronald Oussoren wrote: > I don't know which one Fredrik thinks is wrong, but I think the result > of -1*(1,2,3) is very surprising. I'd expect an exception here. I agree, but this has nothing to do with whether or not the unary - is supported. Regards, Martin _

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Ronald Oussoren
On 25-mei-2006, at 23:04, Martin v. Löwis wrote: > Fredrik Lundh wrote: > -1 * (1, 2, 3) >> () > -(1, 2, 3) >> Traceback (most recent call last): >>File "", line 1, in >> TypeError: bad operand type for unary - >> >> We Really Need To Fix This! > > I can't find this inconsistency hor

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Guido van Rossum
You're joking right? On 5/25/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >>> -1 * (1, 2, 3) > () > >>> -(1, 2, 3) > Traceback (most recent call last): >File "", line 1, in > TypeError: bad operand type for unary - > > We Really Need To Fix This! > > [\F] Doesn't the real effbot have /F

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Georg Brandl
Martin v. Löwis wrote: > Fredrik Lundh wrote: >> >>> -1 * (1, 2, 3) >> () >> >>> -(1, 2, 3) >> Traceback (most recent call last): >>File "", line 1, in >> TypeError: bad operand type for unary - >> >> We Really Need To Fix This! > > I can't find this inconsistency horrible. > > py> +"Hell

Re: [Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Martin v. Löwis
Fredrik Lundh wrote: > >>> -1 * (1, 2, 3) > () > >>> -(1, 2, 3) > Traceback (most recent call last): >File "", line 1, in > TypeError: bad operand type for unary - > > We Really Need To Fix This! I can't find this inconsistency horrible. py> +"Hello" Traceback (most recent call last): F

[Python-Dev] A Horrible Inconsistency

2006-05-25 Thread Fredrik Lundh
>>> -1 * (1, 2, 3) () >>> -(1, 2, 3) Traceback (most recent call last): File "", line 1, in TypeError: bad operand type for unary - We Really Need To Fix This! [\F] ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/

Re: [Python-Dev] Import hooks falling back on built-in import machinery?

2006-05-25 Thread Georg Brandl
Guido van Rossum wrote: > Good catch. I think this would save a certain number of unnecessary > stat() calls. > > But it does change semantics, so we can't fix this in 2.4. In 2.5, we > should warn hook authors that this might affect them. > > The PEP ought to be updated to clarify this. Okay. T

Re: [Python-Dev] Import hooks falling back on built-in import machinery?

2006-05-25 Thread Guido van Rossum
Good catch. I think this would save a certain number of unnecessary stat() calls. But it does change semantics, so we can't fix this in 2.4. In 2.5, we should warn hook authors that this might affect them. The PEP ought to be updated to clarify this. --Guido On 5/25/06, Georg Brandl <[EMAIL PRO

[Python-Dev] Import hooks falling back on built-in import machinery?

2006-05-25 Thread Georg Brandl
While working on a patch involving sys.path_importer_cache, I discovered that if a path_hooks import hook has been found for a given sys.path entry, but isn't able to import a specific module, find_module() tries to import the module from this sys.path entry as a regular file. This results in e.g.

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Tim Peters
[Jean-Paul Calderone] >> ... >> Hmm, one reason could be that the general solution doesn't work: >> >> [EMAIL PROTECTED]:~$ python >> Python 2.4.3 (#2, Apr 27 2006, 14:43:58) >> [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 >> Type "help", "copyright", "credits" or "license" for more inform

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Martin Blais
On 5/25/06, Runar Petursson <[EMAIL PROTECTED]> wrote: > > On 5/25/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > > > If you really need this for speed, I recommend you make it a custom > extension. > > > > > The custom extension is a good idea, and what we do now. But now that the > long al

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Runar Petursson
On 5/25/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: If you really need this for speed, I recommend you make it a custom extension. The custom extension is a good idea, and what we do now.  But now that the long algorithm is so fast, it would be nice to expose it at least at the C level to use a

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Josiah Carlson
Bob Ippolito <[EMAIL PROTECTED]> wrote: > One problem with buffer() is that it does a memcpy of the buffer. A > zero-copy version of buffer (a view on some object that implements > the buffer API) would be nice. Did buffers change? I seem to remember that there were segfaulting conditions wh

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Bob Ippolito
On May 25, 2006, at 3:28 PM, Jean-Paul Calderone wrote: > On Thu, 25 May 2006 15:01:36 +, Runar Petursson > <[EMAIL PROTECTED]> wrote: >> We've been talking this week about ideas for speeding up the >> parsing of >> Longs coming out of files or network. The use case is having a >> larg

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Raymond Hettinger
Runar Petursson wrote: > We've been talking this week about ideas for speeding up the parsing > of Longs coming out of files or network. The use case is having a > large string with embeded Long's and parsing them to real longs. One > approach would be to use a simple slice: > long(mystring[x

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Guido van Rossum
On 5/25/06, Sean Reifschneider <[EMAIL PROTECTED]> wrote: > Conversion functions taking a start and end are the low-hanging fruit, but > I think in the long term something that does that described I would prefer. > I believe that Martin is expecting expecting to have something this week > to try.

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Jean-Paul Calderone
On Thu, 25 May 2006 15:01:36 +, Runar Petursson <[EMAIL PROTECTED]> wrote: >We've been talking this week about ideas for speeding up the parsing of >Longs coming out of files or network. The use case is having a large string >with embeded Long's and parsing them to real longs. One approach wo

Re: [Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Sean Reifschneider
On Thu, May 25, 2006 at 03:01:36PM +, Runar Petursson wrote: >simply limit the scope of the parsing. There are other solutions, using >buffer-like objects and such, but this seems like a simple win for anyone >parsing a lot of text. I implemented it in a branch I'll expand on that a little

[Python-Dev] Cost-Free Slice into FromString constructors--Long

2006-05-25 Thread Runar Petursson
We've been talking this week about ideas for speeding up the parsing of Longs coming out of files or network.  The use case is having a large string with embeded Long's and parsing them to real longs.  One approach would be to use a simple slice: long(mystring[x:y]) an expensive operation in a tigh

[Python-Dev] extensions and multiple source files with the same basename

2006-05-25 Thread Ronald Oussoren
Hi, I'm trying to port ctypes to darwin/x86 (aka the new intel macs), which went pretty smooth. I am running into some odd behaviour of distutils now that I'm trying to port those changes to the trunk. ctypes uses libffi, which contains source files in various platform- specific directories,

Re: [Python-Dev] 2.5a2 try/except slow-down: Convert to type?

2006-05-25 Thread Neal Norwitz
This is probably orthogonal to the problem, however, you may want to look into trying to speed up Python/errors.c. This link will probably not work due to sessions, but click on the latest run for python and Python/errors.c http://coverage.livinglogic.de/coverage/web/selectEntry.do?template=2850&