Let's take a look at identity comparison vs integer comparison...
import timeit
setup = """
def isequalItems(itemone, itemtwo):
    return itemone is itemtwo

def isequalInts(itemone, itemtwo):
    return itemone == itemtwo

def testOne():
    a = 1
    b = 2
    isequalItems(a,b)

def testTwo():
    a = 1
    b = 2
    isequalInts(a,b)
    
"""
print "isequalitems", timeit.timeit(stmt="testOne()", setup=setup, 
number=10000000)
print "isequalints", timeit.timeit(stmt="testTwo()", setup=setup, 
number=10000000)

I get 
isequalitems 2.77487170111
isequalints 2.73482146489

So, integer comparison is faster. This is with Python 2.7.
PyPy 1.9...
isequalitems 0.067024457849
isequalints 0.0263884617855

Integer comparison is still faster.

On Friday, May 3, 2013 10:36:10 AM UTC-7, Anthony wrote:
>
>
> RDBMS are built for complex filtering - this is (part) of what SQL is 
>> allabout - I wouldn't want to dismiss that - it would be a bad choice 
>> all-around.
>>
>
> A complex filter on a small set of items might be faster in Python than 
> doing another database hit. And a simple filter might belong in the db if 
> it has to go over lots of records. As I said, these are orthogonal 
> considerations.
>  
>
>> Conversely, simple-filtering is way too verbose using the DAL - it's an 
>> overkill for that, and makes the code much less readable.
>>
>
> Don't know why you think that.
>   
>
>> For simple filtering, well, I'd rather do it in python and get 
>> readability, becuase the performance-benefits are negligible.
>>
>
> But I thought you were a fan of achieving negligible performance benefits 
> at great cost (see below).
>  
>
>> Now you've really lost me -- what does any of this have to do with RDBMS 
>>> vs. NoSQL? And why shouldn't you do complex filtering in Python?
>>>
>>
>> See above.
>>
>
> Still don't know why you would want a NoSQL database or what it has to do 
> with this topic. 
>  
>
>> db.Country(france).select().find(lambda r: r.Language != spanish and r.
>>> Population > 1000000)
>>>
>>
>> That's actully pretty nice - I didn't know I can do that - but what would 
>> the "france" and "spanish" objects be in this case? Ids? 
>>
>
> Well, you've sure made a lot of claims about what web2py needs without 
> knowing much about what it already has. Those are ids. If they were rows, 
> then you would just do france.id and spanish.id.
>  
>
>> OK, please provide some benchmarks. What percentage decrease in CPU usage 
>>> can we expect if we compare object identities rather than integer 
>>> equivalencies?
>>>  
>>>
>>
>> Really? You think I need to?
>>
>
> Yes, I think you need to. If this is only going to save a half a second of 
> CPU time per day, I'm not going to build an ORM to get it. The question 
> isn't how much faster the identity check is (and I don't think it's that 
> much faster) -- the question is how much of your overall application CPU 
> time is spent doing this kind of thing?
>
> Anthony
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to