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">&lt;<a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>&gt;</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 &lt;<a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>&gt; added the comment:<br>
<br>
</div><div class="Ih2E3d">&gt;&gt; Now that you&#39;ve spent so &nbsp;much time 
with this patch, can&#39;t you think<br>
&gt;&gt; of a faster way of doing this?<br>
&gt;<br>
&gt; Well firstly, you could replace Quoter (the class) with a 
&quot;quoter&quot;<br>
&gt; function, which is nested inside quote. Would calling a nested function<br>
&gt; be faster than a method call?<br>
<br>
</div>Yes, but barely.<br>
<div class="Ih2E3d"><br>
&gt;&gt; I wonder if mapping a defaultdict wouldn&#39;t work.<br>
&gt;<br>
&gt; That is a good idea. Then, the &quot;function&quot; (as I describe above) 
would be<br>
&gt; just the inside of what currently is the except block, and that would 
be<br>
&gt; 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 &#39;safe&#39;), 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>
&gt; I&#39;m very hazy about what is faster in the bytecode world of Python, 
and<br>
&gt; wary of making a change and proclaiming &quot;this is faster!&quot; 
without doing<br>
&gt; proper speed tests (which is why I think this optimisation could be<br>
&gt; delayed until at least after the core interface changes are made).<br>
<br>
</div>That&#39;s very wise. But a first-order approximation of the speed of<br>
something is often &quot;how many functions/methods implemented in Python<br>
(i.e. with def or lambda) does it call?&quot;<br>
<div class="Ih2E3d"><br>
&gt; But I&#39;ll have a go at that change tomorrow.<br>
&gt;<br>
&gt; (I won&#39;t be able to work on this for up to 24 hours).<br>
<br>
</div>That&#39;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 &lt;<a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>&gt;<br>
&lt;<a href="http://bugs.python.org/issue3300"; 
target="_blank">http://bugs.python.org/issue3300</a>&gt;<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

Reply via email to