Python 2.3 Final Released 371
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."
impact... (Score:2, Interesting)
Re:impact... (Score:3, Informative)
In short: don't worry about it. The python developers already have.
Countdown to Gentoo zealotry. (Score:4, Funny)
Python 3 (Score:5, Funny)
Whitespace trolling... (Score:5, Funny)
for the trolls to start
complaing about
whitespace usage in
Python.
That, and what does this mean for improvments to my favourite distro's package management? (Gentoo!)
Re:Whitespace trolling... (Score:2)
Re:Whitespace trolling... (Score:2)
Re:Whitespace trolling... (Score:2)
USE="brains" emerge joke
Re:Whitespace trolling... (Score:3, Funny)
Don't you mean?
def waiting (trolls)Re:Whitespace trolling... (Score:3, Funny)
Python:
Programming the way
Guido
indented it.
Re:Whitespace trolling... (Score:5, Interesting)
What's wrong with it is that it's the syntax for dictionaries. Similar to hashes in Perl, it is a built-in type for Python. Anything wrapped in {} would probably be viewed as an attempt to make a dictionary by the parser.
I've discussed this with all my software engineering colleagues, and most of them have white space as their only hang up about the language. I thought this was pretty petty at first, given the other strengths of the language, but one person brought up an extremely good point. A co-worker at his company is blind. He said that having to deal with white space while coding was near impossible (maybe he uses a "pretty printer" or code beautifier after the fact? I don't know) Has anybody on
I do think it would be nice if there was a way to open and close a block (someone later down in the comments suggested preprocessor comments of and ) such that one could use either method. Perhaps there would even be a built in function of the interpreter to spit out the code one way or the other.
I must say I've gotten used to the whitespace over the past year. Using a decent editor makes life much easier in this respect. I would encourage anyone who hasn't tried out Python for this reason alone to give it a shot for a few weeks and see what you think.
Re:Whitespace trolling... (Score:4, 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.
question to practical programmers (Score:5, Interesting)
Re:question to practical programmers (Score:2, Informative)
[google.com]
Python developer showing preference to hash tables over balanced tres.
I would also like to see balanced trees in the library, if for nothing more than sometimes ordered iteration is more useful than fast lookup, but oh well. I believe having hash tables but not balanced trees is much less bad than the other way around (like standard C++), in which there are balanced trees but no hash tables.
Re:question to practical programmers (Score:2, Insightful)
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.
Comment removed (Score:5, Insightful)
Re:question to practical programmers (Score:4, Insightful)
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.
Re:question to practical programmers (Score:4, Interesting)
I don't know what Python (or other scripting languages) are doing to address this; many on the Python newsgroup seemed not to care and said that the operating system should deal with any process which is using too much CPU time, but I don't know if this attitude is shared by the real Python developers.
Perhaps for security-conscious applications you could choose to use red-black trees or some other implementation of associative arrays, at least in cases where strings sent by the user are used as part of a hash key. Perhaps Perl's tainting mechanism could help with this.
Re:question to practical programmers (Score:3, Informative)
Re:question to practical programmers (Score:2)
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.
If the code is not time-critical then why optimize for average case performance?
Re:question to practical programmers (Score:3, Insightful)
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 sort
Re:question to practical programmers (Score:3, Informative)
Judy looks fairly promising for some applications I'm looking at. The benchmarks I ran are sort of bogus though since I'm not causing fragmentation by doing other things between inserts and deletes. I suppose the moral of the story is, preallocate if you know your structure is going to get big.
Re:question to practical programmers (Score:2, Insightful)
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 peo
Well, this is good, but I'm hoping for more. (Score:2)
Some way to use Perl libraries would really kick ass too but I guess that's impossible without Parrot coming into reality.
Platform Competition? (Score:5, Insightful)
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 [boost.org], 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 [pygame.org] is looking more and more attractive for quite a number of things.
Download soon and often.
Re:Platform Competition? (Score:2, Insightful)
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 i
Re:Platform Competition? (Score:3, Informative)
Re:Platform Competition? (Score:5, Interesting)
Last time I saw unbiased performance comparisions, the difference between Python and Java wasn't really worth talking about.
Re:Platform Competition? (Score:3, Insightful)
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 sa
Re:Platform Competition? (Score:5, Funny)
Wait, now Java people are saying other languages are too slow??
-Bill
Re:Platform Competition? (Score:4, Insightful)
Re:Platform Competition? (Score:4, Insightful)
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.
Python is actually strongly typed. (Score:5, Informative)
Take a look at this article [artima.com] for clarification on typing models.
Its 20-30% faster !! (Score:5, Insightful)
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
Re:Its 20-30% faster !! (Score:5, Informative)
Out by an order of magnitude, and not getting closer any time soon. Last I checked, it's out by a factor of 100 or so for small operations (loops, etc) But this isn't a problem in practice -- one can code the speed-critical stuff (whether that be objects, or functions) in C or C++, then wrap them in python, and enjoy all the benefits of python.
Also, it often happens that 1% of the speed of C and C++ is actually good enough. Sounds slow, but only compared to C and C++ which may be well over 100x faster than what's required.
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
It is much slower, and unavoidably so. It's a very dynamic language, and this has consequences as far as performance is concerned.
Re:Its 20-30% faster !! (Score:5, Interesting)
Out by an order of magnitude, and not getting closer any time soon. Last I checked, it's out by a factor of 100 or so for small operations (loops, etc)
Well, regular Python code can see some dramatic speedups, with just a little bit of extra work. Check out Psyco [sourceforge.net] if you firmly believe that interpreted languages will never ever be as fast as C.
With sufficient cleverness, it may be possible to boost Python beyond the speed of the most highly optimized pre-compiled program.
Psyco and approaches like it do have drawbacks, but there is some very interesting work going on now with high-level languages.
Re:Its 20-30% faster !! (Score:2, Flamebait)
Or you could use Common Lisp, and realize that you're a few years behind....
Pyrex also is worth considering (Score:2)
Still a work in progress, but interesting.
Re:Its 20-30% faster !! (Score:4, Interesting)
Compiling alone wouldn't bridge the gap. Python already reduces interpreter overhead by using a pre-compiled byte-code. A large part of the problem is in dynamic typing: for example, when you say
a+b
in python, it's not equivalent to doing the same in C++. In python, you need to do a runtime type check and then decide what operation to perform, and only then can you add a and b. In C++, the dispatch can be performed compile-time.
What you really need to get a big speedup is some sort of mechanism that can eliminate a lot of this type checking (the other guy posted a link to an interesting approach to this problem)
But I've often been impressed with the ease of coding in such a language
It's a bit of a two-edged sort for the same reason -- the lack of type checking makes it easy to write code quickly, but it also makes it easy to code incorrectly.
Re:Its 20-30% faster !! (Score:4, Informative)
However, with the addition of Parrot, Python, as well as Perl, will be running on a virtual machine that uses registers rather than a stack. Register based machines are much faster than stack based machines.
Damian Conway, in a presentation at the Seattle Perl User's Group, demonstrated that you can actually get code that is written in perl that runs only a small factor (like 4 or 5 times) slower than C, rather than many orders of magnitudes (like 100 or 10,000 times) slower. This speedup will benefit Python as well, when it is ported to Parrot.
In short, Python and Perl, and every other language that is ported to Parrot, will kick some serious butt, and put a lot of C programmers out of work.
psyco (Score:2)
Boolean support (Score:2)
Re:Boolean support (Score:2)
Re:Boolean support (Score:2)
2.2.1 added True and False constants, which were set to integer 1 and 0.
But 2.3 adds a true Boolean type [python.org].
Re:Boolean support (Score:4, Insightful)
"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."
new features? (Score:2)
Re:new features? (Score:2)
I didn't realize gzip could concatenate files. How does that work? Just cat the resulting files together?
Bastion disabled (Score:2)
Re:Bastion disabled (Score:3, Informative)
datetime module (Score:2)
Reviewing a book 101 (Score:2, Interesting)
How did it help you? Did you really need help? If so was this book uniquely helpful or do you think others would have helped too?
Are there other reasons why it was great? Was the author witty and entertaining? Or was he dry and to the point? Was his writing unusually clear and illuminating? Did he "speak to you"?
I'm not saying every comment here has to be a full book review, just that yours was devoid
Re:Reviewing a book 101 (Score:5, Informative)
In the tradition of O'Reilly's "In a Nutshell" series, this book offers Python programmers one place to look when they need help remembering or deciphering the syntax of this open source language and its many modules. This comprehensive reference guide makes it easy to look up all the most frequently needed information--not just about the Python language itself, but also the most frequently used parts of the standard library and the most important third-party extensions.
Python in a Nutshell focuses on Python 2.2 (and all its point releases), currently the most stable and widespread Python release. This book includes:
A fast-paced tutorial on the syntax of the Python language itself
An explanation of object-oriented programming in Python, covering both the classic and new-style object models
Coverage of other core topics, including exceptions, modules, strings, and regular expressions
A quick reference for Python's built-in types and functions, as well as the key modules in the Python standard library, including sys, os, time, thread, math, and socket, among many others
Reference material on important third-party extensions, such as Numeric and Tkinter
Information about extending Python and embedding it into other applications
Python in a Nutshell provides a solid, no-nonsense quick reference to information that programmers rely on the most. This latest addition to the best-selling "In a Nutshell" series will immediately earn its place in any Python programmer's library.
Synopsis
In the tradition of O'Reilly's "In a Nutshell" series, this book offers Python programmers help remembering or deciphering the syntax of this open source language and its many modules. This comprehensive reference guide should make it easy to look up all the most frequently needed information - not just about the Python language itself, but also the most frequently used parts of the standard library and the most important third-party extensions. The book includes: a fast-paced tutorial on the syntax of the Python language itself; an explanation of object-oriented programming in Python, covering both the classic and new-style object models; coverage of other core topics, including exceptions, modules, strings, and regular expressions; a quick reference for Python's built-in types and functions, as well as the key modules in the Python standard library, including sys, os, time, thread, math, and socket, among many others; reference material on important third-party extensions, such as Numeric and Tkinter; and information about extending Python and embedding it into other applications.
Happy?
Shameless plug (Score:5, Informative)
However, my book, _Text Processing in Python_, has at least one think over Alex's that is germane to this thread: I make a good effort to cover Python 2.3. I am quite confident that mine is the only book you can actually buy today that does so (I'm sure there will be more titles, and various updates, over time, of course). Don't let my title fool you, btw, I do a bit more than the title entirely admits to. But the title isn't a lie either, it really is focussed on the broad area called "text processing".
Anyway, there's nothing subtle in my plug. I really will get a couple dollars every time someone buys one (unlike the somewhat odd insinuation downthread about Sir Haxalot doing so). But then, I also invite everyone to read the entire text for free at:
http://gnosis.cx/TPiP/
So you can have something for nothing too, if you want.
David Mertz
Re:Shameless plug (Score:2)
I bought your book _Text Processing in Python_, I must say it is excellent so far (although I'm not too far into it). I've read Appendix A, which does provide a very good intro to the Python language (I've been using it at work for about six months solid now), and I'm wading through chapter one. There is a lot of material to digest in a short period in the first few sections. I have some background with Functional Programming from Lisp, but it's nice to see it covered in Python (as I have much mo
Re:To be fair... (Score:2)
Re:Reviewing a book 101 (Score:2)
Nice Amazon scam buddy (Score:3, Interesting)
Moderators should know to look out for this... it's way worse than karma whoring. Did you even read this book? I wouldn't be wondering this if your post wasn't so clearly a cash grab.
If so, it might help if you wrote something useful about why you're recommending it! (And I don't mean cut-n-paste from an Amazon review either...)
Better than Learning Python. (Score:5, Informative)
I've been learning Python Language for a while, but since I don't work with other programmers, it's taken me quite a while. I learned python the usual way (a mix between the on-line tutorial and Learning Python) and my fluency is improving.
I picked up this book recently while I was at a convention in Baltimore. I liked its organization: the book features a whole chapter on each datatype (strings, numbers, tuples, lists, and dictionaries). There are also chapters on Control Flow Statements, Functions, Modules, Files, Classes, and Exceptions.
Because of its organization, it's as useful as a reference as it is a tutorial. Each chapter contains progressively advanced examples that end up demonstrating the finer points of each topic.
For example, one hint was to use the vars() function creates a dictionary of the local namespace. This makes it useful when string formatting: The book does not cover advanced topics like Tkinter, Jython, or extending Python with C. Nor does it cover the Library modules (the Python online documentation is actually quite good).
"Python" is newer, cheaper (22 USD vs. 30 USD), and longer (410pp vs. 368pp) than "Learning Python"
I would recommend this book to anyone who would like to learn Python. If you're an intermediate Pythoneer, I agree with the parent: you will want to get "Python In A Nutshell".
Re:Second fucking post (Score:2, Informative)
Really, Dr. FoolingYou (Score:4, Informative)
Re:Why Python is good at our university (Score:4, Informative)
Re:Why Python is good at our university (Score:2)
Re: (Score:2)
Re:Why Python is good at our university (Score:4, Interesting)
Re: (Score:2)
Re:Why Python is good at our university (Score:3, Funny)
Haunted? Leave it to dearly departed Edsger Dijkstra to say how it really is:
``It is practically imposible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.''
Re:Why Python is good at our university (Score:2, Interesting)
The first is NetLogo because its really awesome and you can do great things with it very easily. Ever try to simulate the spread of diseases in a C program??? The second is Dr Scheme which is a newer form of LISP. Teaches kids how to use functions and recursion. And the tortures of syntax. I just love () now. Rather i love (((()))) now. That portion of the course is concluded by us making our own number system with simple arithmetic functions.
Beginners MUST learn C (Score:3, Insightful)
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 b
Re: (Score:2)
Re: Why Python is good at our university (Score:3, Insightful)
Re: (Score:2)
Re:Why Python is good at our university (Score:2, Insightful)
this of course coming from somebody who uses "u" and "ur"...
Re:Why Python is good at our university (Score:2)
C and C++ are much more stable in both language reports and compilers, but Perl must be in the same so-called "experimental" group as Python and Java.
On the other hand, all of them must be in the experimental group, comparing to LISP (Scheme included), the language that survived since 1957 (amazingly - even still ac
Re:I see whitespace is still syntactically relevan (Score:5, Insightful)
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.
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).
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]?
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.
Re:I see whitespace is still syntactically relevan (Score:5, Insightful)
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.
Re:I see whitespace is still syntactically relevan (Score:5, Informative)
Discussions on tabs and spaces can lead to flamewars in Python circles. Many people hate tabs, and a significant majority of code does not use tabs.
As far as screen width, that's no different in Python than any other language. Deep nesting is a sign of a program in need of refactoring.
Makefiles require tabs too (Score:2)
Re:I see whitespace is still syntactically relevan (Score:2, Interesting)
Putting a large block of code into a while or for loop.
Well, if you had a large block of code to insert, why not make it a function and call it. Also, when you're working with Python, you quickly learn (or assign) the "entab" and "detab" commands, so inserting the tabs aren't a problem.
TABS and order of whitespace
Most people have their editors convert tabs to spaces
For decently-complex programs there might be so many nesting le
Re:I see whitespace is still syntactically relevan (Score:4, Insightful)
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.
Re:I see whitespace is still syntactically relevan (Score:3)
Actually, the chances are it would generate a Syntax Error.
C//
Re:I see whitespace is still syntactically relevan (Score:2)
Not particularly, as in Python you know not to do that. Myself, I have VIM macros for intenting and outcommenting and incommenting code in a wide variety of programming languages. What you are describing is what I call a "theoretical problem that does not turn out to be a problem in practice."
C//
Re:I see whitespace ... autogeneration a problem (Score:2)
it's a feature (Score:3, Insightful)
--Mike
Re:I see whitespace is still syntactically relevan (Score:3, Informative)
while 1:
---->while 1:
--------->dosomething;
xxxxx>i+=1;
Now where did the i+=1 go? I don't know. The way I deal with it is by doing this:
while 1:
-
Re:I see whitespace is still syntactically relevan (Score:2, Interesting)
while something someval: #{
do.something()
while x 10: #{
print x
#}
#}
Re:I see whitespace is still syntactically relevan (Score:2)
-Sean
Re:I see whitespace is still syntactically relevan (Score:5, Funny)
Isn't that better?
No cookie for you.
Re:From relevancy to troll and back. Whitespace (Score:2, Informative)
Nobody Expects the Whitespace Inquisition (Score:3, Informative)
Our two chief weapons are trolling and casting nasturtiums
Our three chief weapons are trolling and casting nasturtiums and not paying attention to what we're saying....
So your favorite language is whitespace neutral - completely so, right?
No preprocessor lines (C, C++) that terminate on an end of line (which I consider whitespace).
No comments that terminate on the end of line? (Java, C#, C++, Perl, and so on )
How about end of line embedded in strings? Is that legal (
Re:Nobody Expects the Whitespace Inquisition (Score:3, Informative)
And while you are at it, if you like semicolons, you can always add #; to the end of statements.
Actually, Python allows the user of semi-colons at the end of statements in most cases. Think of it more as if Python doesn't enforce them.
Re:ATTENTION! (Score:5, Informative)
Actually, it could. The PHP crowd blew every horn they could find when yahoo switched over to PHP, but AOL has been using python behind the scenes for a long time with little fanfare (or problems). So if it's AOL doing the upgrading, it might help your AOL downloads be faster.
Re:ATTENTION! (Score:2)
http://maps.yahoo.com/py/maps.py?Pyt=Tmap&ed=2eq1M up_0TpxXa5UN63mjyUSVQJsX5Sk2q8YXq2EXTawW.mGFYV8AHt JOL7B4CsQWw--&csz=Washington+DC&country=us
(purposefully not anchored)
Re:ATTENTION! (Score:2)
Re:definately? (Score:5, Funny)
we definately do not waist are time with speling and grammer, you looser.
in the immortal words of homer*:
"if i spelled cat 'C', 'A', 'T', you'd know what i mean"
* simpson, homer j. not that other guy.
Re:how about lists (Score:2, Insightful)
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.
It has reference counting with a collector for cycles. What's wrong with that? BTW, it's an implementation choice.
Re:how about lists (Score:2)
Python already has full garbage collection in both the C and Java implementations. The reference counting accelerates collection at the expense of runtime in C python. Since the reference counting
Re:how about lists (Score:3, Informative)
Re:The real way to get some head and tail (Score:4, Informative)
Lisp style cons lists are essentially a big nested set of tuples
[1, 2, 3, 4, 5]
translates to
(1, (2, (3, (4, (5, _)))))
so head (the lisp CAR) is the first element of this two item tuple, tail (lisp's CDR) is the 2nd element, or the rest of the list.
Re:The dynamic duo. (Score:2)
Re:Notebook? (Score:3, Informative)