Bill Janssen <[EMAIL PROTECTED]> added the comment:
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 <[EMAIL PROTECTED]>wrote:
>
> Guido van Rossum <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
> <http://bugs.python.org/issue3300>
> _______________________________________
>
Added file: http://bugs.python.org/file11106/unnamed
_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3300>
_______________________________________
<div dir="ltr">Feel free to take the function implementation from my patch, if
it speeds things up (and it should).<br><br>Bill<br><br><div
class="gmail_quote">On Wed, Aug 13, 2008 at 9:41 AM, Guido van Rossum <span
dir="ltr"><<a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204,
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
Guido van Rossum <<a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>> added the comment:<br>
<br>
</div><div class="Ih2E3d">>> Now that you've spent so much time
with this patch, can't you think<br>
>> of a faster way of doing this?<br>
><br>
> Well firstly, you could replace Quoter (the class) with a
"quoter"<br>
> function, which is nested inside quote. Would calling a nested function<br>
> be faster than a method call?<br>
<br>
</div>Yes, but barely.<br>
<div class="Ih2E3d"><br>
>> I wonder if mapping a defaultdict wouldn't work.<br>
><br>
> That is a good idea. Then, the "function" (as I describe above)
would be<br>
> just the inside of what currently is the except block, and that would
be<br>
> the default_factory of the defaultdict. I think that should speed things
up.<br>
<br>
</div>Yes, it would be tremendously faster, since the method would be called<br>
only once per byte value (for each value of 'safe'), and if that
byte<br>
is repeated in the input, further occurrences will use the __getitem__<br>
function of the defaultdict, which is implemented in C.<br>
<div class="Ih2E3d"><br>
> I'm very hazy about what is faster in the bytecode world of Python,
and<br>
> wary of making a change and proclaiming "this is faster!"
without doing<br>
> proper speed tests (which is why I think this optimisation could be<br>
> delayed until at least after the core interface changes are made).<br>
<br>
</div>That's very wise. But a first-order approximation of the speed of<br>
something is often "how many functions/methods implemented in Python<br>
(i.e. with def or lambda) does it call?"<br>
<div class="Ih2E3d"><br>
> But I'll have a go at that change tomorrow.<br>
><br>
> (I won't be able to work on this for up to 24 hours).<br>
<br>
</div>That's fine, as long as we have closure before beta3, which is next
Wednesday.<br>
<div><div></div><div class="Wj3C7c"><br>
_______________________________________<br>
Python tracker <<a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>><br>
<<a href="http://bugs.python.org/issue3300"
target="_blank">http://bugs.python.org/issue3300</a>><br>
_______________________________________<br>
</div></div></blockquote></div><br></div>
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com