On Sat, 2002-04-06 at 16:39, Matt Feifarek wrote:
> I've patched WebUtils.HTTPRequest.py as per our discussion. The patch is on
> sourceforge, and is attached. I've tested it pretty thoroughly.
>
> I'm cc'ing the webware-devel list.
>
> Thank you everyone for your input and advice! This is my first ever patch
> submission to an open source project (now don't let that discourage you from
> considering my code ;-))

Hey, congratulations!  Good stuff.

I'm not an Webware maintainer, but I've got a couple of comments:

1. I'd consider moving this procedure into a separate function, since it's
    fairly long -- although maybe it's not considered good style to call
    other member functions from __init__. <shrug>

2. You asked about optimization.  My suggestion would be to not do the sort at
all; it's the most expensive operation (on the order of n * log(n) if there are
n fields in the request).  It's much cheaper to do just the linear search
(order n).

But since you're only interested in fields named _action_*, you could do
something
to quickly filter out most fields you're not interested in, so you can quickly
decide whether you need to do any further work.

    tmpKeys = filter( lambda s: s[:2] == '_a', self._fields.keys() )
    if len(tmpKeys) >= 2 ):
        put the rest of your routine here

You could compare against the full string "_action_", but in the most common
case, there will be very few fields starting with "_a" compared to the total
number of
fields, so this is a quicker comparison.  In the rest of your code you compare
against the full string, so it won't affect the result.

hope this helps,
Jason


_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to