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


Groups > comp.lang.python > #66741

Commonly-used names in the Python standard library

Date 2014-02-20 20:39 +1100
Subject Commonly-used names in the Python standard library
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.7178.1392889158.18130.python-list@python.org> (permalink)

Show all headers | View raw


In working on a proposal that might result in the creation of a new
keyword, I needed to ascertain what names were used extensively in
existing Python code. Out of random curiosity, I asked my script what
names were the most commonly used. The script responded with 21854
names and a total of 297164 references, averaging 13-14 refs per name.

A good number of names are referenced just once - set and never
referenced. They're there for applications to use. That takes out 6217
names. But I'm more interested in the ones that see a lot of use.

By far the most common name is 'self', for obvious reasons; after
that, it's a fairly steady drop-off. The most popular names in the
standard library are... *drumroll*

45298 - self
3750 - os
3744 - name
3166 - i
3140 - s
2685 - value
2648 - a
2451 - len
2348 - c
2331 - sys
2255 - b
2238 - line
2132 - print
2131 - x

Few surprises there. The os and sys modules are used extensively, and
short variable names are reused frequently. To the print-detractors:
That's two thousand uses in the standard library, more than any other
single function bar 'len'! (And by the way, this is ignoring any file
with /test/ in the name.)

I find the pairing of 'name' and 'value' interesting. There are 40%
more names than values in Python, apparently. And on that bombshell,
as they say on Top Gear, it's time to end!

ChrisA

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


Thread

Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 20:39 +1100
  Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 12:22 +0200
    Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 21:43 +1100
      Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 13:28 +0200
        Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 22:37 +1100
        Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 22:47 +1100
          Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 14:09 +0200
            Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-20 23:19 +1100
              Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 14:46 +0200
                Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 00:34 +1100
                Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 17:14 +0200
                Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 02:48 +1100
                Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-20 18:26 +0200
                Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 03:36 +1100
                Re: Commonly-used names in the Python standard library 88888 Dihedral <dihedral88888@gmail.com> - 2014-02-21 12:57 -0800
                Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:49 +0000
            Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:43 +0000
    Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:59 +0000
      Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 18:10 +1100
      Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 09:21 +0200
        Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 19:21 +1100
          Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 12:26 +0200
            Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 21:49 +1100
              Re: Commonly-used names in the Python standard library Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 14:03 +0200
                Re: Commonly-used names in the Python standard library Ethan Furman <ethan@stoneleaf.us> - 2014-02-21 11:16 -0800
        Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 09:12 +0000
  Re: Commonly-used names in the Python standard library Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 06:51 +0000
    Re: Commonly-used names in the Python standard library Chris Angelico <rosuav@gmail.com> - 2014-02-21 18:02 +1100

csiph-web