Parallelizing python code - design/implementation questions

2008-12-13 Thread stdazi
Hello! I'm about to parallelize some algorithm that turned out to be too slow. Before I start doing it, I'd like to hear some suggestions/hints from you. The algorithm essentially works like this: There is a iterator function "foo" yielding a special kind permutation of [1,n]. The main progr

Re: Program inefficiency?

2007-09-29 Thread stdazi
On Sep 29, 6:07 pm, [EMAIL PROTECTED] wrote: > You did not mention the OS, but because you are using > "pathname\editfile.txt", it sounds like you are using an MS OS. From > past experience with various MS OSes, I found that as the number of > files in a directory increases the slower your proces

Nice "bug" to loose a contest

2007-04-08 Thread stdazi
Hello, Yesterday, I was at a programming competition. We programmed on Linux liveCD's and Python was one of the allowed languages (among C and Java). I cared just about the algorithmic approach so I used Python. One of the main rules is, that the code reads its standard input and dumps the result

why I don't like range/xrange

2007-02-16 Thread stdazi
Hello! Many times I was suggested to use xrange and range instead of the while constructs, and indeed, they are quite more elegant - but, after calculating the overhead (and losen flexibility) when working with range/xrange, and while loops, you get to the conclusion that it isn't really worth usi

Re: One module per class, bad idea?

2006-12-23 Thread stdazi
Matias Jansson wrote: > I come from a background of Java and C# where it is common practise to have > one class per file in the file/project structure. As I have understood it, > it is more common practice to have many classes in a Python module/file. > What is the motivation behind it, would it b

Re: skip last line in loops

2006-12-17 Thread stdazi
lines = open('blah').readlines() for i in range(0, len(lines)-1) : print lines[i] [EMAIL PROTECTED] wrote: > hi, > how can i skip printing the last line using loops (for /while) > > eg > > for line in open("file): > print line. > > I want to skip printing last line of the file.thanks --

Re: Why not just show the out-of-range index?

2006-12-05 Thread stdazi
Usually, when I make some coding mistake (index out of range - in this case) I just care to fix the mistake and I usually don't mind to inspect by how much the index was overflowed. It really seems like a feature that should be embedded in some Python debugger than a feature in the interpreter itse

Spliting a string on non alpha characters

2006-09-23 Thread stdazi
Hello! I'm relatively new to python but I already noticed that many lines of python code can be simplified to a oneliner by some clever coder. As the topics says, I'm trying to split lines like this : 'foo bar- blah/hm.lala' -> [foo, bar, blah, hm, lala] 'foobbbar.. xyz' -> [foo, bbbar, xyz]

Re: python loops

2006-09-01 Thread stdazi
`range' is especially useful for iterating over long sequences ;-) for i in range(0,100) : OverflowError: range() result has too many items Sybren Stuvel wrote: > [EMAIL PROTECTED] enlightened us with: > > I thought the xrange was preferred? for x in xrange(length): > > True. I

Re: How ahead are you guys in the (Python) real world?

2006-08-31 Thread stdazi
Ray wrote: > Since I haven't used Python at work, I am using Python 2.5 right now. > However I wonder, how fast are you guys moving from version to version > at work? As an illustration my ex-company just moved to Java 5, which > was released around... what, 2-3 years ago? (While I am running Java