I don't know but you'd better do some profiling if you really want to
find out. IMHO, try...except might be fast, but wrapping it inside a
user-defined function could be another story, because defining a
function is expensive in python, so we shall call native function
(implemented by C) whenever possible.

On Jun10, 0:48am, mdipierro <[email protected]> wrote:
> good point. Anyway, the function is no longer called as often as
> Alexey originally pointed out, so it would make a negligible
> difference. I will change it though.
>
> Massimo
>
> On Jun 9, 11:24 am, AchipA <[email protected]> wrote:
>
> > Any particular reason not doing is_integer via a 'try: int(i) except:
> > return False'  statement ? It should be faster than regexes.
>
> > On Jun 7, 1:49 pm, Iceberg <[email protected]> wrote:
>
> > > On Jun7, 6:35pm, Alexey Nezhdanov <[email protected]> wrote:
>
> > > > > 2) is_integer is a fast call, but with 1.1k (!) calls ...
>
> > > > Replaced it with my own version:
> > > > integer_pat=re.compile('[0-9]+$')
> > > > is_integer=lambda x: integer_pat.match(x)
> > > > it's about 2.3 times faster. C version would be even better.
>
> > > If so, perhaps this is even better:
>
> > >   integer_pat=re.compile('[0-9]+$')
> > >   is_integer=integer_pat.match
>
> > > Because lambda is considered as much slower than built-in functions,
> > > AFAIK.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to