[Tutor] List comprehensions

Alan Gauld alan.gauld at btinternet.com
Thu Apr 10 09:52:23 CEST 2008


"Dinesh B Vadhia" <dineshbvadhia at hotmail.com> wrote i

> I'm using a Javascript autocomplete plugin for an online 
> web application/service.  Each time a user inputs a character, 
> the character is sent to the backend Python program which 
> searches for the character in a list of >10,000 string items.  

Eeek! 
That will be incredibly slow over any kind of network 
other than fast gigabit! try doing a ping from the client to the 
server. If it over the internet you will be lucky to get less that 
100ms, over a fast LAN it might be around 30ms. 
Add in the transmission time for your data 
- (ie 150*ave string length*10/average bandwidth) 
That network delay will swamp any optimisation of a for loop.

It is likely to come out around 10ms so your total delay 
between each character becomes 40-110ms or a maximum 
typing rate of 9-25 characters per second. The latter will feel
slightly clunky but the former will feel very sluggish. And on 
anything less than a good internet connection the rate could 
drop off to around 1 character per second! And anyone using 
a mobile GPRS connection for access would be crippled.

Alan G.



More information about the Tutor mailing list