Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Python Moving into the Enterprise 818

Qa1 writes "Seems that Python is moving into the enterprise. At the recent PyCon it has become apparent that it's not just Google, GIS, Nokia or even Microsoft anymore. The article points out that Python is increasingly becoming a perfectly viable and even preferred choice for the enterprise. More and more companies are looking at Python as a good alternative to past favorites like Java. Will we finally be able to code for living in a language that's not painful? Exciting times!"
This discussion has been archived. No new comments can be posted.

Python Moving into the Enterprise

Comments Filter:
  • Jython? (Score:4, Interesting)

    by Crono ( 62230 ) on Sunday April 03, 2005 @08:59AM (#12125844)
    Aren't some of them using Jython, which is really just Python on top of Java anyway.
  • Advantages? (Score:4, Interesting)

    by voss, sometimes... ( 873034 ) on Sunday April 03, 2005 @09:02AM (#12125857)
    Im not a coder my self, altough I hahe programmed in Java and in python, but I fail to see Python's advantages comparing to Java in an enterprise environment.

    Besides... wasn't Star Trek cancelled?
  • python performance (Score:4, Interesting)

    by khuber ( 5664 ) on Sunday April 03, 2005 @09:04AM (#12125867)
    Python is a nice language, but it's excruciatingly slow. It's below Tcl on The Computer Language Shootout [debian.org], which is telling.
  • Re:Advantages? (Score:2, Interesting)

    by m50d ( 797211 ) on Sunday April 03, 2005 @09:05AM (#12125868) Homepage Journal
    http://netpub.cstudies.ubc.ca/oleary/images/python _java_comparison.gif [cstudies.ubc.ca] may give you an idea. Quite simply it's easier to program in, and you're more productive using it.
  • by m50d ( 797211 ) on Sunday April 03, 2005 @09:07AM (#12125874) Homepage Journal
    Happy. It's open, and could be a sign that MS is actually "getting it". Besides, it's already possible to do python under java, but IronPython looks better, and MS is employing the guy who does it.
  • by thammoud ( 193905 ) on Sunday April 03, 2005 @09:25AM (#12125919)
    for Python jobs. It returned 312 jobs. Java returned 9196. I don't think Python will ever dent Java's dominance in the enterprise. Do you really expect Python to do what .NET has failed to do? Not a chance. It is a cute scripting language. No more and no less. Python competes with Perl and Ruby.
  • by vidarlo ( 134906 ) <vidarlo@bitsex.net> on Sunday April 03, 2005 @09:27AM (#12125923) Homepage
    It [webmasterworld.com] seems [python.org] Google is using Python for a good deal of stuff... And I thought google was enteprise
  • Re:Advantages? (Score:2, Interesting)

    by rmccann ( 792082 ) on Sunday April 03, 2005 @09:36AM (#12125948) Homepage Journal
    A poor example. The java code is only longer because of all the braces. That example implies the only strength python has is lack of braces.
  • Re:Advantages? (Score:3, Interesting)

    by platypus ( 18156 ) on Sunday April 03, 2005 @09:49AM (#12125985) Homepage
    Really, try Zope [zope.org].
    Yes, it's a little bit of a learning courve, but (and I did all of them for a living) it be beats Java/Tomcat/Struts and PHP hands down in productivity/maintainability once you get a grip on it.

  • by FidelCatsro ( 861135 ) <.fidelcatsro. .at. .gmail.com.> on Sunday April 03, 2005 @09:58AM (#12126029) Journal
    Alot of us never thought PHP could make a Dent in perl , but it did.
    if you had checked for python jobs just 2 years ago i would be amazed if you could find any .312 is a dent although a small one , and yes i do expect it to do what .Net has failed to do this as .NET has no real advantages over Java in the enterprise market , and the dependance on MS OSs is a real disadvantage in a market where Solaris etc still play a sizable part
    (mono is not an option right now).
    Python is able to run on all of these systems , Python has been proven over the years as a strong language and most importantly Python has the support of the OSS world which is becoming an increasingly large force in the industry .
    So maybe right now python cant take over , but 5-10 years down the line you may just see a very difrent picture
  • by Sweetshark ( 696449 ) on Sunday April 03, 2005 @09:58AM (#12126030)
    If you feel you have better python code to perform a task on the benchmark, feel free to submit it.
    Actually I tweaked around with the code - but the rule of the game are just wrong. Just look at the fibonacci test. It requires you to do the stuff completely recursively - thats one of the rules. So you not only generate a huge return stack, you also calculate all the fibonacci numbers far too often. This is just braindead. A good requirement would say: "Calculate the nth fibonacci number". A simple solution would be to start from the beginning and not recursively calulate every fibonacci number bazillion times.

    Ok, the test description says that its task is to show the performance of recursion. But then they have to find a task where recursion is an merit - not a flaw. Otherwise you could claim your language is best because it has the best performing idle loops [slashdot.org] ....
  • by Nelson ( 1275 ) on Sunday April 03, 2005 @10:08AM (#12126087)
    I think that the database connectivity could be standardized a little more, perhaps with an ORM. It's not bad now but as a postgresql user, I'm not really happy, the "best" connector needs some janked up mx library, there are a few dead connectors. It seems like python.org could take this over or some kind of packager could.


    Then the newer pythons allow you to import from a zip. That needs polish, there should be a standard way to package a whole app in a zip (just to make it harder to screw up the file distribution. Having a single unit that contains all the needed code is a huge positive; it's just that much harder to screw stuff up.


    Then there are people working on compiler speed, really it isn't as bad as you might think from some of the benchmarks. It can use some improvment though and people are working on it.

  • Re:Advantages? (Score:1, Interesting)

    by Anonymous Coward on Sunday April 03, 2005 @10:17AM (#12126120)
    Exactly. I can literally rewrite the core of Zope in under three pages of APL. It's an extremely expressive and compact language. But don't ask me to maintain it.

    Hello world examples are contrived. In the enterprise, no-one gets paid to do hello world.
  • Re:Advantages? (Score:1, Interesting)

    by Anonymous Coward on Sunday April 03, 2005 @10:26AM (#12126161)
    2D Drawing Libraries?
  • No CPAN == GOOD (Score:2, Interesting)

    by Anonymous Coward on Sunday April 03, 2005 @10:48AM (#12126264)
    Typical Example Mr. Golfplayer. Found a great little OSS application, needs compiling, uses Perl, running make, opps need to use CPAN, "Oh crap, company firewall blocks FTP", "No problem, I'll download the packages one at a time.", followed by individual downloads, packages added only to find out a package requires another package!

    Bzzzt! Wrong!

    Interdependencies of packages on CPAN are a clusterfuck. All the hack work is paid for by us compilers.

    You tell me to make a backup of CPAN or what? You can't call these packages easily, it's crap work you have to make a offline mirror of CPAN. No. No. No. CPAN is the plague. You customize your Perl env and build and start using non-standard hack libs just because you can and you quote CPAN!

    Python might not have so many libraries OR a so-called package repository but the standard libraries accomplish as much as the fancy CPAN calling Perl code.
  • Divide and conquer (Score:1, Interesting)

    by what about ( 730877 ) on Sunday April 03, 2005 @11:15AM (#12126373) Homepage

    So, instead of Java we could use perl, pyton, php (remember that?) .net and I am sure someone will come up with many more. They all are simple, fast, exciting, new, wonderful... etc.

    I am beginning to think that this is a plot of Microsoft to dilute the only alternative to .net (.net is a clone of java, but of course -SARCASM- much better, faster, newer, more portable etc. -/SARCASM- )

    It was Caesar that used the method to conquer an empire, and it did work.

  • Re:No CPAN. (Score:2, Interesting)

    by rakanishu ( 670638 ) on Sunday April 03, 2005 @11:18AM (#12126387)
    Call me when Python has CPAN's 7848 modules. Then we can talk about "productivity".
    I hear this over and over, but I have to wonder what percentage of CPAN's 7848 modules are actually used? Which ones have been replaced by better ones?

    Python has PYPI which is growing. Python also comes with a pile of standard modules. I'll admit something closer to CPAN would be helpful. On the other hand, I haven't had any issues finding modules. Sometimes all you need to do is google or ask on one of the python lists.
  • by Anonymous Coward on Sunday April 03, 2005 @11:33AM (#12126469)
    Does exist in Python. Guido, last I heard, believed firmly that tabs stops should always be 8 characters apart. Almost every other programmer likes 4 or 3, but some like 2 or even 1. Some have their editors set to use and save tabs, some have their editors set to get rid of all the worthless tab characters. You've got to enforce some kind of standard on a shop of multiple python programmers to make this work at all.
  • by Anonymous Coward on Sunday April 03, 2005 @11:35AM (#12126477)
    If you use a lazy language like haskell, you can recursively create an infinite stream of the fibonnacci sequence. It takes 2 lines, and you'll get performance similar if you wrote it in C++ depending on compiler.

    fibs = 0 : 1 : join (+) fibs (tail fibs)

    join f (x:xs) (y:ys) = (f x y) : join f xs ys

    now isn't that just way too easy?
    If you're not familiar with the language, check it out. And if you're confused by the infinite stream, there's no problems with infinite loops as long as you use "take" to get the 0-nth item, or "!!" to get the nth item
  • by Bob9113 ( 14996 ) on Sunday April 03, 2005 @11:51AM (#12126554) Homepage
    And most enterprise apps are not CPU limited anyway.

    Say what? You must be living in a very different world than I. If it's an enterprise app, then it has a few thousand internal users. Multiply a few seconds by a few thousand people by a few times an hour by a few dollars per hour. Performance matters. Middle of last year my company pulled two people off their primary project to add a feature that saved our primary users two mouse clicks. Those 4,000 users now save 3 seconds, 10 times an hour, 8 hours a day. It's like getting an extra 33 employees for free.

    Now, I hasten to add that performance isn't the only thing - if it takes three extra months to add a new feature then you've got to multiply 3 months by all those people not doing what they could be doing with the new feature. But claiming it's a non-issue is shortsighted.
  • by Cajal ( 154122 ) on Sunday April 03, 2005 @12:12PM (#12126672)

    I'm a big fan of Python. I used it almost exclusively before taking my current job. But let's be honest, Python and Java just aren't intended for the same type of applications.

    Python's standard library just doesn't have the breadth of Java's. For small apps, the CPython VM is lighter than Sun's JVM, but CPython's VM is lacking several capabilities that I'd consider pretty essential -- chief among them is the ability to return unused memory back to the OS [evanjones.ca]. And for many tasks, CPython is still effectively single-threaded due to its global interpreter lock [python.org]. Java has never suffered from either of these problems. These aren't trivial issues or the result of nitpicking -- they're rather severe limits (which make me seriously question the suitably of Python for enterprise apps, eg. Zope). Of course, once CPython does get decent threading, it's likely that it's GC subsystem will need to be totally rewritten. I apologize if it sounds like I'm beating up on Python. That's not my intent here. I love Python, and I only wish I could stop more people from using Perl :)

    In fairness, it does look like the Python community is trying to address some of these problems. I just read a paper presented last week at PyCon 2005 [python.org] on CPython's memory management. The author is developing some patches to let CPython return unused memory to the OS [python.org] for most object types (except for Number, List and Dictionary). The memory manager still can't defragment its heap, so this isn't a perfect solution. As of a few weeks ago [python.org] it looks like these patches haven't yet been accepted.

  • by hagbard5235 ( 152810 ) on Sunday April 03, 2005 @12:21PM (#12126726)
    I love python. It's by far my prefered language for development, but it has one major impediment that makes it very hard to take seriously in many rolls in an enterprise: the GIL (global interpreter lock).

    You see Python has quite good support for threads, but there are a number of operations in the interpreter that are hacked into being thread safe by providing a global lock on the whole interpreter. One of them is reference counts on objects. So everytime I do an assignment, I have to queue for the GIL. This effectively means that I only really run one thread at a time, even if I have multiple CPUs in the box (or soon, multiple cores).

    As more and more applications start shifting to multicpu (or multicore boxes) this problem becomes a much more noticable issue.

    Kill the GIL.
  • Re:Advantages? (Score:1, Interesting)

    by Anonymous Coward on Sunday April 03, 2005 @12:45PM (#12126860)
    That doesn't open a file; it creates an instance of a filename. You can't read from a File instance.
  • by Liquidrage ( 640463 ) on Sunday April 03, 2005 @01:11PM (#12126973)
    See my other post to the same parent. How can you say it hasn't dented it?

    You can repeat the same ol' tired mantra, over and over, it doesn't make it true.

    .Net is getting heavy use in the enterprise, and in this thread, has about 80% of the jobs that Java has advertised. Now personally, I don't think that's the best possibly way to determine use. But it is what is used in this thread. .NET is about 3 years old, Java's about 10. That's a dent.

    And I'll even make the logical case showing how it is a *dent*, and not just a VB rollover (which I'm sure much of it is).

    Apps, that due to scope and criticality, would never have been done in VB (mostly due to it's lack of support for true OO design) are getting done in .NET now. For certain apps, there really was no competition for Java. Now there is. And it comes down to a few criteria for the managers (experience of the current staff if any, what marketing smoke was blown up their ass and by who, what buzzwords their boss is big on at the moment, and if there's anyone actually technical in the decision making process that actually is able to point out the best tool for the task at hand, amongst others).

    Also, it used to be split, you had MS goons writing ASP for web (with maybe some really crappy custom COM being a DAL, or some specialized functionality), VB for desktop. Now, it's all wrapped into one package, .NET

    And it is being heavily used in Enterprise development.
  • by Berfert ( 831562 ) on Sunday April 03, 2005 @01:13PM (#12126993)
    My issue with using indentation as a block delimiter is in the time it takes to do it. When programming in Tcl (my language of choice), I just hit tab and the code is indented to where it should be. If I add an open or close curly, the indentation knows where to go next (in order to be the most readable to me). How do Python programmers handle having to indent every line? I assume tab will (generaly) indent to whereever you were last indented to. Do you need to backspace/space mutliple times each time you switch to a new block level?
  • by zorander ( 85178 ) on Sunday April 03, 2005 @01:33PM (#12127123) Homepage Journal
    I agree with a lot of what you are saying, though it doesn't tend to stop me from using python.

    If you want a language that's consistently unsurprising and surprisingly efficient, then try ruby. Performance is not a dream, but that's what compiled languages are for. It lacks most of python's inconsistencies and is really quite pleasant to work with. in ruby there are two sort methods, sort and sort!. One does it in place and one returns a new list. (the ! suffix for mutation and ? suffix for predicates is a gem. I'm pretty sure it was stolen from scheme. It really, really helps make your code clearer)

    I still find python more practical for large projects, though, because of the large library and potential for rapid development. I generally use python (possibly with C underpinnings) for larger apps and ruby (with its perl heritage) for scripting. Blocks are the greates when you're dealing with ssh sessions, opening and closing files/database connections, etc. As for per,l I've generally avoided after a few bad experiences trying to decipher six month old code. I really don't think it has a place when ruby has most of its features and enough of it's syntax along with the slickest object system around short of smalltalk.
  • Re:Too bad... (Score:2, Interesting)

    by jgrahn ( 181062 ) on Sunday April 03, 2005 @02:08PM (#12127313)
    "Bad programming" has many points to it. I'd include using an old-fashioned language like C or C++ in a system which does not require huge speed or efficiency (which is almost everything these days). It increases the development time of a project, increases the code complexity, increases the chances of runtime bugs, and increases the potential severity of what bugs you do have.

    C may be old-fashioned, but please don't lump C++ in with it. Chances are you haven't even seen modern C++ source code, which in practice has little to do with C source other than that you can link to C libraries easily.

    That said, I'm all for programming in higher-order languages (e.g. Python) and I prefer to do so, but some problems are better solved in C++ or even C. It doesn't even have to be about efficiency; things like static type checking can be essential in large programs when it's hard to test all code paths.

  • hmmm (Score:2, Interesting)

    by Anonymous Coward on Sunday April 03, 2005 @02:19PM (#12127376)
    There are a lot of things wrong with what you are saying. It looks like while you learned the language, you have a lot of trouble adapting to some of the "paradigms".

    Asking for functions to return None instead of raising exceptions on errors ruins a fundamental concept of "focus on what the program should do" which makes exceptions useful. A significant percentage of C code is "if - else" statements dealing with such return codes.

    In C or Perl, writing a file is a painful operation, along these lines:

    open file for writing()
    if open failed {
    handle error
    } else {
    while not finished {
    retvalue = write content to file
    if retvalue not good {
    handle error
    }
    }
    close file
    if close failed {
    handle error
    }
    }

    Note how inline error checking not only makes the bulk of the code, but also makes it less obvious what the code does. In Python, you'd do something along these lines:

    try:
    open file for writing
    while not finished:
    write to file
    close file

    except open failed or write failed or close failed:
    handle error

    That is even assuming we want to handle the error and not let it propagate up, which is made possible by the exception mechanism, and would be made difficult if all those functions would return on error.
  • by ibm1130 ( 123012 ) on Sunday April 03, 2005 @02:45PM (#12127531)
    Last week I realised I needed some way of generating a bunch of stuff on the fly as prep work for a current project.
    It had been mentioned in my hearing that Python was acceptable within the constraints for the overall program.
    Figuring it was at least worth a look, I spent a day playing with Python basically putting together the things I needed to to do the task. In spite of a couple of disruptions, my code was fully functional and more or less ready for primetime by COB Friday.
    I wouldn't use it for the real-time parts of what I'm doing if only because the framework being used is suitable as it stands ( C++/C/FORTRAN ) but for most other things it rocks.
    I plan to push for making Python the standard glue language at the office.
  • Re:Too bad... (Score:3, Interesting)

    by masklinn ( 823351 ) <slashdot.org@mCO ... t minus language> on Sunday April 03, 2005 @02:49PM (#12127550)
    Another poster already made a clarification on this. I didn't "mis-speak" I was just a bit obscure with my meaning. Point being, if you code in C/C++ you'll spend a lot of time making the program work correctly. If you write in eg Java or Python you can get the program working correctly in a fraction of the time. This means you can add polish or move on to new stuff. Point being, you are more productive in other languages as you don't have to mess with the details so much.
    One of the very important features of Python (i don't know much about java as i hate that language, but i'd assume it's close even though it'd be tought to be better than Python in that field) is the ease of creating C/C++ modules/extensions to the language.

    That's where i'll desagree with whateverparent who said that high level "so called scripting languages" should only be used for prototyping/testing and should be cast aside for final app:
    It's well known that ~10% of an application's codebase consumes ~90% of the application's resource needs (source: my ass), high level modular languages with easy ASM/C/C++ integration such as Python therefore allow you to:
    • Develop the whole application in a fraction of the time you'd need to develop C/C++ version
    • Using it as a "proof of concept" of the app's viability
    • Fully test both application and test-cases (including unit tests
    • Identify performances "roadblocks" modules/parts
    • Recode these modules in a more efficient language using the already perfect testing tools
    You'll use maybe 10% of the "full C/C++ approach" coding time to code the initial java/python/ruby/whatever high-level language you prefer version, 5% or maybe 10% top to recode the performance-critical modules in low-level languages, and you'll get... 99% of the low level version performances for under 20% of the dev time (with less chances of memory leaks and better portability to boot)

    The stupid part is that most people don't even realise the ease of embedding low level modules into modern high level languages, and therefore use a "all or nothing approach", either full high level or full low...
    Learn how to use your tools guys, low level compiled and high level interpreted language do not oppose themselves, they're complementary and both are necessary to get the best out of your dev teams
  • Re:Advantages? (Score:1, Interesting)

    by Anonymous Coward on Sunday April 03, 2005 @03:20PM (#12127716)
    I call bullshit. I took 6 months for myself and my team to try to build a real application with Zope, with terrible results. It turns out that Zope uses all of the wonderful Python features such as monkey patching to achieve a situation where anyone coding a non-trivial application on Zope must read through most of Zope code to understand weird regressions and even to be able to write non-trivial features. The Zope Book covers only the most trivial of uses, completely unlike J2EE documentation and the interface Javadocs for any available Java libraries.

    To us, results are more important than the tools used to achieve them, and therefore investing 6 unproductive months into reading low-level Zope code instead of using them to develop our product was a tremendous waste.

    In the end, we were unable to deliver a working Zope system because the only Oracle and LDAP libraries for Python available in the whole wide universe leaked memory and had threading problems, and the ZODB system had extreme rollback regressions.

    We had to scratch the Python development and start again in Java, using Spring and Hibernate, and were able to deliver the product barely in time.

    If I was irrationally fond of Python and Zope over the alternatives which have been proven to work today, and are widely supported, I suppose I could ignore all these clear and severe problems with Python in enterprise space, but since I'm a rationalist, I cannot simply close my eyes from reality.
  • Re:Advantages? (Score:4, Interesting)

    by fyngyrz ( 762201 ) on Sunday April 03, 2005 @03:21PM (#12127723) Homepage Journal
    There's another advantage for me, not quite so obvious, that Python's indentation mechanism brings to the table.

    I program a lot. In the course of my job, I have to review a lot of other people's code. I have a particular bracing style I use; and sure enough, I've not only become accustomed to it but also "tuned" to it to the point where it becomes difficult to read someone else's code if (for instance) they use the "K&R" style:

    if (condition) {
    ....do_this_stuff();
    }

    Because at my company, code looks like this:

    if (condition)
    {
    ....do_this_stuff();
    }

    Those two styles lead to a considerable difference in code density, and so affect readability and my "tuned" response to what I see. And there are so many other C/Java coding styles re bracing and indentation, or lack thereof.

    In Python, there is one indentation style. Just one. Not bunches of them. So I get used to the way Python looks, the "tuning" goes into my backbrain or wherever the heck that stuff lives, and I can read anyone's code. This is a distinct benefit for me, and I suspect for others as well.

    I would have loved a C compiler that didn't use braces, but used indentation instead. Man, that would have been glorious. Sigh.

  • by Anonymous Brave Guy ( 457657 ) on Sunday April 03, 2005 @05:15PM (#12128451)
    I do not like C++ as a language though. C's use can be justified for low-end systems, but C++ is in more of a quandary, since its architecture has been superceded by newer languages

    The problem is that actually, it hasn't, although it surely should have been a long, long time ago. Alas, the bulk of the software development industry is so driven by marketing hype and buzzwords that it has collectively failed to develop a new language that is a serious choice as a general purpose programming language spanning many problem domains.

    A lot of newer languages imitate C++'s approach in terms of design tools, most obviously Java, C# and now Visual basic.Net. However, the beauty is only skin-deep; these languages often lack the solid, underlying framework and reasoned design decisions that have gone into C++, with the result that most of the time they are lucky to be as good, never mind an improvement. The addition of generics to Java several years later is an obvious demonstration of what happens when you go for buzzwords and you meet someone who went for solid design principles.

    Many other languages have something valuable to offer developers, but then go and spoil it in some other way, ultimately winding up with something that might fit certain niches, but isn't suitable for major development projects across a wide range of areas. Some common examples come immediately to mind:

    Java
    Pro: emphasises safety, readability, and portability; con: sacrifices low-level control (and with it performance) and only supports a limited number of programming techniques, encouraging over-engineered, component-based designs
    Perl
    Pro: quick, flexible, useful for rapid development of useful tools; con: terrible scalability and unfriendly (to both programmers and tools) syntax restrict it almost exclusively to quick-and-dirty projects
    Haskell
    Pro: elegant and powerful syntax, serious support for powerful programming tools like higher-order functions; con: overly academic community, and puts purity above pragmatism, making it hard to use in real-world projects where things like UIs are involved

    The list goes on, but the important point is that while each of these has good applications, they all have obvious flaws as well. Java is the closest to a serious general purpose language, but even today most of the serious Java code is restricted to server-side back-ends driving databases or some thinly disguised variant on that theme.

    C++, for all its sins, remains a pragmatic, balanced choice for a general purpose language that can be effectively adapted to a diverse range of applications. Is it a perfect language? Of course not. It has gaping flaws in any number of areas. The problem is that no-one has yet produced an alternative that beats it on all of them without significant compensating weaknesses.

  • Re:Advantages? (Score:1, Interesting)

    by Anonymous Coward on Sunday April 03, 2005 @06:18PM (#12128821)
    > java.io.File myFile = new java.io.File("Some file Name");

    That gives you a file handle. Now return every line in the file starting with "DEBUG> " into an array. This is ONE line in python and doesn't even require a variable.

    [line for line in file("some file name") where line[:6] == "DEBUG> "]

    Good to know java got foreach syntax. Welcome to the 1970's, Java.
  • by goombah99 ( 560566 ) on Sunday April 03, 2005 @11:43PM (#12130686)
    I just tried your suggestion of using the try/except format. You are seriously mistaken if you think that is fast:

    I benched the two pieces of code: (note the slashdot ecode tag removes the proper indentation, but this should be obvious in context)

    #!/usr/bin/python
    a ={}
    c = 10000
    for i in xrange(c*10):
    b = i%c
    a[i] = 1+a.get(i,0)
    and then using your suggestion:

    #!/usr/bin/python
    a ={}
    c = 10000
    for i in xrange(c*10):
    b = i%c
    try:
    a[i] += 1
    except KeyError:
    a[i] = i

    timing these shows the try clause almoist QUADRUPLES the time: the first runs in 0.62 seconds and the latter runs in 2.4 seconds!!!

    Now here is the is the point I was making in my original post: if you try this without using the get its almost 6 times faster than using the .get format and 24 times faster than doing it with the try statement!!!!!!!

    To show this consider the following example: In this special problem we know ahead of time what the keys will be. In general we would probably not know this if we were say parsing a file. But since we know them its cheap to write a loop to initialize them first. then we dont have use the get() statement or the try. then we can see how much speed we are losing to the get() statement.

    #!/usr/bin/python
    a ={}
    c = 10000
    for i in xrange(c):
    a[i] = 0

    for i in xrange(c*10):
    b = i%c
    a[i] += 1
    this runs in 0.11 seconds. Which is about 24 times slower than using the try.

    your information about how to replace autointialization appears to be seriously mistaken.

This file will self-destruct in five minutes.

Working...