Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64620

Re: Case insensitive exists()?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'debugging': 0.07; 'see.': 0.07; 'string': 0.09; '22,': 0.09; 'app,': 0.09; 'http': 0.09; 'slow.': 0.09; 'python': 0.11; 'django': 0.11; 'jan': 0.12; '2.03': 0.16; "os'": 0.16; 'query,': 0.16; 'subject:Case': 0.16; 'subject:exists': 0.16; 'subject:insensitive': 0.16; 'apps': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'coding': 0.22; 'header:User-Agent:1': 0.23; "i've": 0.25; 'script': 0.25; 'header :In-Reply-To:1': 0.27; 'converting': 0.30; 'matching': 0.30; 'said,': 0.30; 'serve': 0.31; "skip:' 10": 0.31; '-0700,': 0.31; 'easy,': 0.31; 'larry': 0.31; 'run': 0.32; 'linux': 0.33; 'checking': 0.33; 'guess': 0.33; 'something': 0.35; 'hundreds': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'entry': 0.36; 'charset:us-ascii': 0.36; "i'll": 0.36; 'too': 0.37; 'list': 0.37; 'skip:o 20': 0.38; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'issue': 0.38; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'users': 0.40; 'how': 0.40; 'serving': 0.60; 'further': 0.61; 'back': 0.62; 'content-disposition:inline': 0.62; 'high': 0.63; 'today': 0.64; 'here': 0.66; 'revealed': 0.68; 'containing': 0.69; 'user,': 0.69; 'receive': 0.70; 'upper': 0.74; 'browser.': 0.78; 'informed': 0.78; 'milliseconds': 0.84; 'oscar': 0.84; 'working,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=rDpMldfhHJyFLeMX7F/eJOTO9NvdrMaxHsYm2M5LLkA=; b=Gt1mPF8+h4p6yAPnyBuEMYzozkzjpWV+5/Ruc0IKUNK3svwdrUdRdKB82/1VF1L5m5 3nw2CxRZhYIOxbWXE9I++gbcBPlN7JEKOyrqBcI9LDizfhV81j2zoDpcCdGvCofBu9Cy QadSIK/IHt5aHA76dcA7e5pblmHcszsWcIm+XIv0tpy3vuzrKy2X1Urb7F4BLJGCAuAe kP4JPZPkb14LIjK9H/pKVzQmZMcAvwkzdAzNHwuB63+zbxnaOfOofTtTmtWer28mOWjw L/rYyh2rLGhALmV8e6BQsOmiCOLNy++QYfdlevMMt8Nm92MHAm3Z653rWGd5cOjg8DIG t+Rg==
X-Received by 10.180.188.230 with SMTP id gd6mr8351499wic.15.1390491826469; Thu, 23 Jan 2014 07:43:46 -0800 (PST)
Date Thu, 23 Jan 2014 15:43:41 +0000
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
To python-list@python.org
Subject Re: Case insensitive exists()?
References <mailman.5853.1390438708.18130.python-list@python.org> <roy-7A7FAE.20082622012014@news.panix.com> <mailman.5855.1390439920.18130.python-list@python.org> <roy-1771A1.20270322012014@news.panix.com> <CACwCsY6Lq=x=XSc6Edqh+v0RH2Q-9t+2cgJ+xbsC+ADfsh90pA@mail.gmail.com>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <CACwCsY6Lq=x=XSc6Edqh+v0RH2Q-9t+2cgJ+xbsC+ADfsh90pA@mail.gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5897.1390491833.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1390491833 news.xs4all.nl 2968 [2001:888:2000:d::a6]:47308
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64620

Show key headers only | View raw


On Wed, Jan 22, 2014 at 09:24:54PM -0700, Larry Martell wrote:
> 
> I am writing something that is part of a django app, that based on
> some web entry from the user, I run a query, get back a list of files
> and have to go receive them and serve them up back to the browser. My
> script is all done and seem to be working, then today I was informed
> it was not serving up all the images. Debugging revealed that it was
> this case issue - I was matching with exists(). As I've said, coding a
> solution is easy, but I fear it will be too slow. Speed is important
> in web apps - users have high expectations. Guess I'll just have to
> try it and see.

How long does it actually take to serve a http request? I would expect it to
be orders of magnitudes slower than calling os.listdir on a directory
containing hundreds of files.

Here on my Linux system there are 2000+ files in /usr/bin. Calling os.listdir
takes 1.5 milliseconds (warm cache):

$ python -m  timeit -s 'import os' 'os.listdir("/usr/bin")'
1000 loops, best of 3: 1.42 msec per loop

Converting those to upper case takes a further .5 milliseconds:

$ python -m  timeit -s 'import os' 'map(str.upper, os.listdir("/usr/bin"))'
1000 loops, best of 3: 1.98 msec per loop

Checking a string against that list takes .05 milliseconds:

$ python -m  timeit -s 'import os' \
  '"WHICH" in map(str.upper, os.listdir("/usr/bin"))'
1000 loops, best of 3: 2.03 msec per loop


Oscar

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 17:58 -0700
  Re: Case insensitive exists()? Roy Smith <roy@panix.com> - 2014-01-22 20:08 -0500
    Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 18:18 -0700
      Re: Case insensitive exists()? Roy Smith <roy@panix.com> - 2014-01-22 20:27 -0500
        Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 21:24 -0700
        Re: Case insensitive exists()? Chris Angelico <rosuav@gmail.com> - 2014-01-23 15:29 +1100
        Re: Case insensitive exists()? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-01-23 15:43 +0000
        Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-23 12:02 -0700
      Re: Case insensitive exists()? Dan Sommers <dan@tombstonezero.net> - 2014-01-23 07:51 +0000
  Re: Case insensitive exists()? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-23 12:06 +0000
  Re: Case insensitive exists()? Grant Edwards <invalid@invalid.invalid> - 2014-01-23 14:58 +0000

csiph-web