Slashdot Mirror


Python 2.3 Final Released

An anonymous reader writes "Nineteen months in the making, Python 2.3 has just been released. With a plethora of changes since version 2.2, this release is definately worth the upgrade. Be sure to read the Release Notes and the Highlights file for more information."

25 of 371 comments (clear)

  1. Re:I see whitespace is still syntactically relevan by Anonymous Coward · · Score: 1, Insightful

    There's a feature I'd like to see removed.

    Why ? What would the benefit be, beside breaking all existing python code ?

  2. Re:If anyone wants a good python book... by Sir+Haxalot · · Score: 1, Insightful

    Heh... another useful book just sprang to mind, try Learning Python. There isn't really much between the two books... although a see Amazon offer a discount, wheras with the other one you don't get a discount... anyways your choice :)

    --
    I have over 70 freaks, do you?
  3. Platform Competition? by Chromodromic · · Score: 5, Insightful

    Check out Artima if you want to see Bruce Eckel's take on the Python language which, incidentally, with the addition of things like a logging API, and with long-existing additions like Jython, is beginning to look more and more like a viable competitor to Java.

    Why?

    Python carries a LOT of the same advantages, but with a dramatically accelerated prototyping and general development speed, and a few tricks of its own. Plus, via Boost, it interoperates with C++, too. I'm an avid Perl hack, but I have to admit that Python, which even has a whole API for basic game programming is looking more and more attractive for quite a number of things.

    Download soon and often.

    --
    Chr0m0Dr0m!C
    1. Re:Platform Competition? by 73939133 · · Score: 1, Insightful

      [Python] is beginning to look more and more like a viable competitor to Java.

      Python is a great scripting language and development in it is much easier than in Java, but it is not a competitor to Java. Java achieves close to C/C++ performance on low-level code (for loops, arrays, etc.); Python doesn't even get close. That really matters in many applications because it means you don't have to "drop down" to C. And Java has static type checking. Static type checking is a nuisance for prototyping, but it is crucially important for building large system.

      Java and Python are just very different tools for very different applications. Both are probably misapplied a lot.

      I should also mention that I don't actually recommend you use Java: it is a proprietary language and has a number of serious design problems. If you want a Java-like language, ECMA C# (not .NET) as implemented by Mono is a better choice in every respect. But there are many other statically typed language choices out there if you don't like C# or Java.

    2. Re:Platform Competition? by Malcontent · · Score: 3, Insightful

      It seems to me that everything Bruce praises about python also applies to most other dynamic typed scripting languages. Certainly ruby and even php or dare I say it perl.

      He seems more in love with the idea of typeless, brief, dynamic and expressive languages in general. it's just that he learned python first and has gotten good at it. If he picked up Ruby first he would be saying the same things about it.

      --

      War is necrophilia.

    3. Re:Platform Competition? by 73939133 · · Score: 2, Insightful

      Maybe you are right but I have written several apps in python and java, and the ones in py left java in the dust. Much less memory for the runtime too.

      There is no contradiction: the Java libraries and the Java runtime have numerous design flaws that cause people to build bloated and sluggish applications in Java. In fact, the same can be said for many C++ frameworks.

      But if you just look at the languages and their implementations, it's easy to compile Java into tight, efficient machine code, while the same is just not possible for Python. Python is a great language with many applications, but it simply is no substitute for statically typed languages like Java, C#, or C++.

    4. Re:Platform Competition? by archeopterix · · Score: 3, Insightful
      I'm really starting to think that the whole static type checking as a requirement for large systems thing is just dogma.
      In fact, Java is a proof of that. Static type checking with most collections being Object holders? If you want typechecking, use a language with some decent type constructors (C++ templates will do, but ML-derivatives have much cleaner type systems). If you implement generics with Object, you defer typechecking till runtime, when your Objects get downcast to whatever you hope they really are.
  4. Its 20-30% faster !! by vivek7006 · · Score: 4, Insightful

    According to a couple of simple benchmark, Python 2.3 is about 20-30% faster than Python 2.2.3. Some of this speed-up was obtained by removing the SET_LINENO opcodes, which means that the difference is less impressive when comparing "python -O"; the rest was various careful tune-ups.

    This is a big improvement. The biggest advantage of using a programming langage like python is the fast development time (5X-10X faster than C++). If the speed of execution of python scripts can be made comparable to compiled C/C++ code, then it would be awesome. Python programs can never be as fast as compiled code, but if the difference in the speed is not significant, it will be a big win for Python

    1. Re:Its 20-30% faster !! by Anonymous Coward · · Score: 1, Insightful

      Most desktop applications spend almost all their time either waiting for user input or reading from disk. Having written applications in python, I can attest that it is plenty fast.

      For big programs, python's greates weakness tends to be its biggest strength - its dynamic nature. The fact that there is no strong type checking done by the compiler (i.e. one can enter i=1 and later change the type of i to a string via i="hello") can introduce a lot of confusion.

      I'd really like to hear about a python tool that could at least generate warnings at compile time about these type changes.

  5. Re:I see whitespace is still syntactically relevan by wass · · Score: 4, Insightful
    There's a feature I'd like to see removed.

    I hear this repeated fairly often, but I can not think of any really good reason why whitespace is bad. IMHO, any decent programmer worth his/her salt will whitespace their code anyway for sanity.

    Just to be my own devil's advocate, here are some reasons I can think of off the top of my head. But I don't think any is sufficiently great for not using python strictly because of it's required whitespace syntax.

    Actually, I want to become proficient in python, I've even got a few books, and just haven't gotten around to programming any application in it yet :-( But these are things I've wondered about (regarding the whitespace). Hopefully a seasoned veteran can point out why these aren't substantial problems.

    • Putting a large block of code into a while or for loop.

      In C, if I am quickly hacking some stuff together and realize I want to put 100+ lines into a for loop, I can put brackets around the code and possibly indent it later if I wind up keeping the code for long-term.

      In python I'd have to manually go to all those lines and put the indent in. (I assume EMACS and other editors can do this automatically, if one knows the key combinations).

    • TABS and order of whitespace

      This confuses me. Does python keep track of instances of \t in an input file? Are they distinguishable from spaces? If at some nested level of indentation I'm at [tab][space][space], is a line of indentation of [space][space][tab] at the same nesting level?

      If I'm at [space][space][space][space] can the next level of nesting be [tab]?

    • For decently-complex programs there might be so many nesting levels that the indented code is spaced so far inwards that one needs ridiculously-wide displays for sanity.

      Personally, I don't think I've ever put more than 10 levels of nested blocks in a program somewhere, but I suppose it could possibly happen and might be a problem, especially of someone is restricted to 80-column screen for some reason.

    Other than those rare or obscure issues, I can't think of any reason that mandatory whitespacing should hold someone back from python.
    --

    make world, not war

  6. Re:question to practical programmers by elflord · · Score: 2, Insightful
    The advantage of the latter over hashtables is a solid bound on the worst case running times.

    Another key advantage, is that RB trees are automatically sorted.

    I'd suppose they use hashtables because they're interested in good average case performance, especially for large tables. I doubt they'd care about worst-case performance -- I suspect that most time-critical code is not written in python.

  7. Re:I see whitespace is still syntactically relevan by jericho4.0 · · Score: 4, Insightful
    For your first two points, a decent IDE helps a lot, or just being familiar with your editor of choice. It's much easier to figure out the key combo in emacs/vi than it is to indent 50+ lines.

    For your second point, 10 levels of nesting is, IMHO, at least 7 too many. That's what subroutines are for. If you find yourself adding another level after three, it's probably time to look at your design.

    --
    "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
  8. Re:I see whitespace is still syntactically relevan by Cranx · · Score: 4, Insightful

    The reason I never bothered with Python is because of the whitespace issue, and I'll tell you why:

    I don't trust that blocks are properly grouped.

    When I program in C++, Java or even Ruby, and I create a new block, the first thing I do is close the block. Any code I put in the block I indent, but if the block grows, or my indenting gets goofy, I don't have to fear that my block is now improperly closing.

    If I paste in a few quick lines of code for debug purposes, and it just happened to be indented differently than where I was pasting it, that would screw up the block closure unless I went and tabbed everything correctly. Sometimes, I *like* that the temporary code is indented wrong because it helps remind me to comment it out or remove it when I'm done debugging.

    The whitespace thing is just too weird. It generates a lot of feelings that I might screw up my blocks. That sort of anxiety shouldn't be there; I shouldn't be so worried about blocks closing.

  9. Re:Boolean support by jdfox · · Score: 3, Insightful

    For simple flags, yes, "1" is quicker to type than "True". But Booleans can make other kinds of code clearer:

    "For example, if you're reading a function and encounter the statement return 1, you might wonder whether the 1 represents a Boolean truth value, an index, or a coefficient that multiplies some other quantity. If the statement is return True, however, the meaning of the return value is quite clear."

  10. Re:question to practical programmers by jcr · · Score: 4, Insightful

    I suspect that most time-critical code is not written in python.

    Depends on which time is critical: CPU time, or programmer time?

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  11. Re:how about lists by Anonymous Coward · · Score: 2, Insightful
    • It would be nice if python had lists with a head and tail
      Python lists are a contiguous array. It's O(1) to get to the head or tail or anything in between. You might be thinking of lists from another language, like Lisp. Or you might be looking for a doubly-linked list implementation, which is easy to implement but rarely needed in real code.
    • a collector instead of reference counting
      It has reference counting with a collector for cycles. What's wrong with that? BTW, it's an implementation choice. Jython uses Java's native gc. Python uses ref counting because that works better with C extensions
    • maybe a decent attribute analysis so that the expression "a"[1] is barfed on before being run.
      Well, I've been known to insert "1/0" as a debugging aid. It's an easy way to raise an exception. Python deliberately aims for late binding and a clean, understandable implementation. What you want breaks both, especially since '''if 0: "a"[1]''' must not be barfed on.
  12. Re: Why Python is good at our university by gidds · · Score: 2, Insightful

    Personally (and knowing both languages well), I'd consider that a problem with C, not with Java...

    --

    Ceterum censeo subscriptionem esse delendam.

  13. Re:question to practical programmers by elflord · · Score: 4, Insightful
    I wasn't trying to dis python, but the point is that most python programmers (even the ones who are interested in performance) are probably thinking "I want this to be as fast as possible on average", not "someone (possibly the programmer) will die if this code does not run in 0.05ms. In one case, you're interested in average case performance, in the other you're interested in worst-case.

    For most web applications, you only care about average case, but for embedded systems, medical equipment, air traffic control systems, etc, worst case may also be very important.

  14. Re:question to practical programmers by miu · · Score: 2, Insightful
    Another key advantage, is that RB trees are automatically sorted.

    Most stl map implementations are based on a RB tree, and often cause memory fragmentation. That's not the end of world for most programs, but data being located on many different pages can trash average access times for threaded programs (although constant use of the memory allocator probably harms the program itself more).

    A hash gives good memory locality and good average lookup performance, if data is constant (or near constant) a sorted vector gives you excellent lookup performance and very good memory locality.

    But I don't think flat out optimization is that important to python, otherwise they'd use low level hacks like perl reading directly out of the stdio FILE buffers to optimize IO.

    --

    [Set Cain on fire and steal his lute.]
  15. it's a feature by mkcmkc · · Score: 2, Insightful
    I'd consider the (slightly) increased difficulty in autogeneration to be a feature rather than a problem. 99% of the time, autogenerating code is a really lame idea. The other 1% of the time, you ought to be generating the indentation, too, for readability/debugability. So Python doesn't really lose here.

    --Mike

    --
    "Not an actor, but he plays one on TV."
  16. Re:Why Python is good at our university by Anonymous Coward · · Score: 2, Insightful

    Unless ur an embedded applications developer/kernel hacker/lean and mean ....u can live ur whole programming life in ignorant bliss behind the facade that is the class library.

    this of course coming from somebody who uses "u" and "ur"...

  17. Re:question to practical programmers by scj · · Score: 2, Insightful

    I believe the reason is that sets in Python are implemented in the Python language itself. Since Python already has hash tables implemented in C, it was easy to write a good set class by using a hashtable. To get the same level of performance with another data structure would mean writing and maintaining a bunch of C code.

    The Python developers could always rewrite the set class in C using Fibonacci heaps at some later time. By writing it in Python, they get a reasonably good implementation now where people can use and experiment with it and suggest improvements to them before commiting to a harder to maintain C version.

  18. Re:Why Python is good at our university by kruntiform · · Score: 2, Insightful

    Dijkstra was half joking, trolling even, in that remark about Basic. In the same piece are other hyperbolic comments such as "The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence." Have you really read any Dijkstra? He always seems level headed to me. Your rant seems to be about a different kind of person entirely. Are you seriously suggesting he should have been defending the status quo of Basic (and Fortran and Cobol)? That Basic is effective? If someone tells you goto is harmful, by all means try it out yourself, but also go and read the careful reasoning behind that little quote.

  19. Re:Whitespace trolling... by ProfKyne · · Score: 3, Insightful

    In general I find Ruby's way easier to read than Python's, especially in the case of weenies who haven't yet learnt to indent properly and have tabs/spaces randomly mixed in with their indents (a practice that seems so common as to outnumber the more traditional spaces OR tabs methods many times over).

    Interesting... seeing as how Python doesn't let weenies indent improperly, and you can run Python scripts with a flag (-O) that gives warnings if tabs and spaces are intermixed in the whitespace... you would think that Python's way would be easier.

    --
    "First you gotta do the truffle shuffle."
  20. Beginners MUST learn C by duck_prime · · Score: 2, Insightful
    It could be worse, people could be learning Basic instead of Pascal and Java. At least they are slightly similar to C. I start programming with Basic and it's haunted me ever since.
    I have to weigh in here... it is my sincere belief that it is a huge mistake to start students in on high-level languages. If you start by learning that the JVM or the interpreter will "take care of it for you", it gives poor incentive to write carefully, with the real machine limits in mind.

    I suggest that all students be forced to learn C and assembler first, to get an idea of what's really, really going on under the hood. Students need to build moral fiber by implementing Yet Another Linked List, by tracking down memory leaks, and going through the agony of allocating a multi-dimensional array.

    After this experience, they will:
    a) Appreciate the glories of Java, Perl & co.
    b) Realize that even with memory-managed platforms memory is still a limited resource, and that leaks can still happen.
    c) Be able to harrumph at the next generation for forgetting what programming to the bare metal is all about.

    Hey I've gotta run, my dad is waving some IBM punch-cards and a soldering iron at me.