Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44096
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <blindanagram@nowhere.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.050 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; 'exercise': 0.04; 'method.': 0.07; 'plenty': 0.07; 'builtin': 0.09; 'high-level': 0.09; 'python': 0.11; '(and,': 0.16; '(however,': 0.16; 'algorithmic': 0.16; 'benjamin': 0.16; 'inclined': 0.16; 'internals,': 0.16; 'libraries.': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subclass': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'decide': 0.24; 'question': 0.24; 'extension': 0.26; 'push': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'wondering': 0.29; 'that.': 0.31; 'libraries': 0.31; 'class': 0.32; 'lists': 0.32; 'this.': 0.32; 'probably': 0.32; 'quite': 0.32; 'worked': 0.33; 'brian': 0.33; 'implemented': 0.33; 'sense': 0.34; 'could': 0.34; 'problem': 0.35; 'basic': 0.35; 'received:84': 0.35; 'but': 0.35; 'add': 0.35; 'building': 0.35; 'there': 0.35; 'really': 0.36; 'subject:List': 0.36; 'doing': 0.36; 'thanks': 0.36; 'wrong': 0.37; 'application': 0.37; 'list': 0.37; 'list.': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'does': 0.39; 'realize': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'how': 0.40; 'easy': 0.60; 'hardware': 0.61; 'full': 0.61; 'simple': 0.61; 'first': 0.61; 'offer': 0.62; "you'll": 0.62; 'more': 0.64; 'different': 0.65; 'here': 0.66; 'natural': 0.68; 'limit': 0.70; 'obvious': 0.74; 'prime': 0.74; 'special': 0.74; 'oscar': 0.84; 'received:192.168.1.7': 0.84; 'tribute': 0.84; 'approach.': 0.91; 'directly.': 0.95; '2013': 0.98 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=LONfHvm9 c=1 sm=1 tr=0 a=nO6JWm9Dsne7RoCvRGnC0w==:117 a=nO6JWm9Dsne7RoCvRGnC0w==:17 a=0Bzu9jTXAAAA:8 a=fr8gcSRtuOIA:10 a=IVHPnoOXeGEA:10 a=8nJEP1OIZ-IA:10 a=BRpsHpjDAAAA:8 a=sXOIDwgukokA:10 a=EMmKpQHunZ5CCfKhgZsA:9 a=wPNLvfGTeEIA:10 a=VMCyCadrP7MA:10 |
| X-AUTH | gladman+brg:2500 |
| Date | Mon, 22 Apr 2013 17:38:01 +0100 |
| From | Blind Anagram <blindanagram@nowhere.org> |
| User-Agent | Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.python |
| To | python-list@python.org |
| Subject | Re: List Count |
| References | <sridnffI6YhxuOjMnZ2dnUVZ7tSdnZ2d@brightview.co.uk> <5175377f$0$29977$c3e8da3$5496439d@news.astraweb.com> <517545F7.5090209@nowhere.org> <mailman.927.1366644147.3114.python-list@python.org> <51755C38.4000204@nowhere.org> <mailman.929.1366646795.3114.python-list@python.org> |
| In-Reply-To | <mailman.929.1366646795.3114.python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.931.1366648708.3114.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366648708 news.xs4all.nl 2254 [2001:888:2000:d::a6]:55116 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44096 |
Show key headers only | View raw
On 22/04/2013 17:06, Oscar Benjamin wrote: > On 22 April 2013 16:50, Blind Anagram <blindanagram@nowhere.org> wrote: >>> >>> It would be very easy to subclass list and add this functionality in >>> cython if you decide that you do need a builtin method. > [snip] >> >> But I was really wondering if there was a simple solution that worked >> without people having to add libraries to their basic Python installations. > > There are simple solutions and some have already been listed. You are > attempting to push your program to the limit of your hardware > capabilities and it's natural that in a high-level language you'll > often want special libraries for that. Hi Oscar Yes, but it is a tribute to Python that I can do this quite fast for huge lists provided that I only count on the full list. And, unless I have completely misunderstood Python internals, it would probably be just as fast on a sub-sequence if I had a list.count(value, limit) function (however, I admit that I could be wrong here since the fact that count on lists does not offer this may mean that it is not as easy to implement as it might seem). > I don't know what your application is but I would say that my first > port of call here would be to consider a different algorithmic > approach. An obvious question would be about the sparsity of this data > structure. How frequent are the values that you are trying to count? > Would it make more sense to store a list of their indices? Actually it is no more than a simple prime sieve implemented as a Python class (and, yes, I realize that there are plenty of these around). > If the problem needs to be solved the way that you are currently doing > it and the available methods are not fast enough then you will need to > consider additional libraries. >> >> As I have never tried building an extension with cython, I am inclined >> to try this as a learning exercise if nothing else. > > I definitely recommend this over writing a C extension directly. Thanks again - I will definitely look at this. Brian
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 12:58 +0100
Re: List Count Dave Angel <davea@davea.name> - 2013-04-22 08:51 -0400
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 14:03 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 14:03 +0100
Re: List Count Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-22 13:13 +0000
Re: List Count Skip Montanaro <skip@pobox.com> - 2013-04-22 08:57 -0500
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 15:15 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-22 16:14 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 16:50 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-22 17:06 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 17:38 +0100
Re: List Count Skip Montanaro <skip@pobox.com> - 2013-04-22 12:48 -0500
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 20:22 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-22 21:18 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 22:25 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 00:06 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 07:45 +0100
Re: List Count Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-22 23:28 +0000
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 08:00 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-22 22:03 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 22:32 +0100
Re: List Count Dave Angel <davea@davea.name> - 2013-04-22 21:47 -0400
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 08:02 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 17:38 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-22 16:50 +0100
Re: List Count Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-22 23:01 +0000
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 08:05 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 12:08 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 12:45 +0100
Re: List Count Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-23 15:01 -0400
Re: List Count Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 14:49 +0000
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 17:57 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 18:45 +0100
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 19:30 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 20:16 +0100
Re: List Count Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-23 16:00 -0400
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-23 21:41 +0100
Re: List Count Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 21:38 +0100
Re: List Count Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-24 01:59 +0000
Re: List Count Blind Anagram <blindanagram@nowhere.org> - 2013-04-24 10:01 +0100
Re: List Count Peter Otten <__peter__@web.de> - 2013-04-22 15:22 +0200
Re: List Count 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-22 06:36 -0700
csiph-web