Message71089
Feel free to take the function implementation from my patch, if it speeds
things up (and it should).
Bill
On Wed, Aug 13, 2008 at 9:41 AM, Guido van Rossum <report@bugs.python.org>wrote:
>
> Guido van Rossum <guido@python.org> added the comment:
>
> >> Now that you've spent so much time with this patch, can't you think
> >> of a faster way of doing this?
> >
> > Well firstly, you could replace Quoter (the class) with a "quoter"
> > function, which is nested inside quote. Would calling a nested function
> > be faster than a method call?
>
> Yes, but barely.
>
> >> I wonder if mapping a defaultdict wouldn't work.
> >
> > That is a good idea. Then, the "function" (as I describe above) would be
> > just the inside of what currently is the except block, and that would be
> > the default_factory of the defaultdict. I think that should speed things
> up.
>
> Yes, it would be tremendously faster, since the method would be called
> only once per byte value (for each value of 'safe'), and if that byte
> is repeated in the input, further occurrences will use the __getitem__
> function of the defaultdict, which is implemented in C.
>
> > I'm very hazy about what is faster in the bytecode world of Python, and
> > wary of making a change and proclaiming "this is faster!" without doing
> > proper speed tests (which is why I think this optimisation could be
> > delayed until at least after the core interface changes are made).
>
> That's very wise. But a first-order approximation of the speed of
> something is often "how many functions/methods implemented in Python
> (i.e. with def or lambda) does it call?"
>
> > But I'll have a go at that change tomorrow.
> >
> > (I won't be able to work on this for up to 24 hours).
>
> That's fine, as long as we have closure before beta3, which is next
> Wednesday.
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3300>
> _______________________________________
> |
File name |
Uploaded |
unnamed
|
janssen,
2008-08-13.16:56:10
|
|
Date |
User |
Action |
Args |
2008-08-13 16:56:13 | janssen | set | recipients:
+ janssen, gvanrossum, loewis, jimjjewett, orsenthil, pitrou, thomaspinckney3, mgiuca |
2008-08-13 16:56:12 | janssen | link | issue3300 messages |
2008-08-13 16:56:12 | janssen | create | |
|