Re: Queue cleanup

2010-09-02 Thread John Nagle
On 8/30/2010 12:22 AM, Paul Rubin wrote: I guess that is how the so-called smart pointers in the Boost C++ template library work. I haven't used them so I don't have personal experience with how convenient or reliable they are, or what kinds of constraints they imposed on programming style.

Re: importing excel data into a python matrix?

2010-09-02 Thread John Yeung
On Sep 1, 7:45 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Sep 1, 2010 at 4:35 PM, patrick mcnameeking pmcnameek...@gmail.com wrote:  I'm working on a project where I have been given a 1000 by 1000 cell excel spreadsheet and I would like to be able to access the data using Python.  

Re: PyPy and RPython

2010-09-02 Thread Stefan Behnel
sarvi, 02.09.2010 07:06: Look at all the alternatives we have. Cython? Shedskin? I'll take PyPy anyday instead of them Fell free to do so, but don't forget that the choice of a language always depends on the specific requirements at hand. Cython has proven its applicability in a couple of

Re: PyPy and RPython

2010-09-02 Thread John Nagle
On 9/1/2010 10:49 AM, sarvi wrote: Is there a plan to adopt PyPy and RPython under the python foundation in attempt to standardize both. I have been watching PyPy and RPython evolve over the years. PyPy seems to have momentum and is rapidly gaining followers and performance. PyPy JIT and

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Arnaud Delobelle
Dmitry Chichkov dchich...@gmail.com writes: Given: a large list (10,000,000) of floating point numbers; Task: fastest python code that finds k (small, e.g. 10) smallest items, preferably with item indexes; Limitations: in python, using only standard libraries (numpy scipy is Ok); I've

python path separator

2010-09-02 Thread swapnil
I could not find any documentation for variables os.path.sep and os.path.altsep. Although the first is pretty straightforward can anyone explain the purpose of the second variable? Is it even useful? According to issue http://bugs.python.org/issue709428, os.path.altsep was 'None' till a long time

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Peter Otten
Dmitry Chichkov wrote: Given: a large list (10,000,000) of floating point numbers; Task: fastest python code that finds k (small, e.g. 10) smallest items, preferably with item indexes; Limitations: in python, using only standard libraries (numpy scipy is Ok); I've tried several methods.

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Peter Otten
Dmitry Chichkov wrote: Code: A lot of the following doesn't run or returns incorrect results. To give but one example: def nargsmallest_numpy_argmin(iter, k): distances = N.asarray(iter) mins = [] Could you please provide an up-to-date version? Peter PS: for an easy way to

Re: python path separator

2010-09-02 Thread Vlastimil Brom
2010/9/2 swapnil swapnil...@gmail.com: I could not find any documentation for variables os.path.sep and os.path.altsep. Although the first is pretty straightforward can anyone explain the purpose of the second variable? Is it even useful? According to issue http://bugs.python.org/issue709428,

Is python is the safest language ...

2010-09-02 Thread Anand Sadasivam
Hi All, Is python is the safest language is my question. I feel its good language, but however java has good occupancy. About four years back I did few python programs and worked with some of add-on product over ZOPE and Plone. The suggestion to me is mostly welcome. Regards, -- Anand.S

Re: Python-list Digest, Vol 84, Issue 8

2010-09-02 Thread Nally Kaunda-Bukenya
Dear Peter, that did wonders!! thanks so much for the code fix; I will check back with you later for the meaning of some functions you used. Many thanks to all those good people who gave me pointers: Rami, Mathew, Bob,   Best wishes for now:) From:

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Arnaud Delobelle
On Sep 2, 7:59 am, Peter Otten __pete...@web.de wrote: Dmitry Chichkov wrote: Given: a large list (10,000,000) of floating point numbers; Task: fastest python code that finds k (small, e.g. 10) smallest items, preferably with item indexes; Limitations: in python, using only standard

Re: Windows vs. file.read

2010-09-02 Thread Lawrence D'Oliveiro
In message mailman.330.1283362312.29448.python-l...@python.org, MRAB wrote: You should open the files in binary mode, not text mode, ie file(path, rb). Text mode is the default. Not a problem on *nix because the line ending is newline. We used to pride ourselves on not having to worry about

Re: Is python is the safest language ...

2010-09-02 Thread Chris Rebert
On Thu, Sep 2, 2010 at 12:29 AM, Anand Sadasivam anand.sadasi...@gmail.com wrote: Hi All, Is python is the safest language is my question. I feel its good language, but however java has good occupancy. About four years back I did few python programs and worked with some of add-on product over

Re: Is there a Python equivalent to Perl's File::Listing::parse_dir

2010-09-02 Thread Stefan Schwarzer
Hi John, On 2010-08-11 20:24, John Nagle wrote: Perl has a function which will take a remote directory page, in the form that most web sites return for a file directory, and parse it into a useful form: http://www.xav.com/perl/site/lib/File/Listing.html This is especially useful

Re: fairly urgent request: paid python (or other) work required

2010-09-02 Thread Daniel Fetchinson
On 9/1/10, lkcl luke.leigh...@gmail.com wrote: i apologise for having to contact so many people but this is fairly urgent, and i'm running out of time and options. i'm a free software programmer, and i need some paid work - preferably python - fairly urgently, so that i can pay for food and

Re: Queue cleanup

2010-09-02 Thread Paul Rubin
Dennis Lee Bieber wlfr...@ix.netcom.com writes: GC's for large systems ... copy the live objects to a new contiguous heap That sounds suspiciously like the original Macintosh OS, with its handles... IE, double-indirection. Nah, a double indirection on every access would be a terrible

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Peter Otten
Arnaud Delobelle wrote: I get: 1.46s for _heapq.nsmallest 0.85s for nsmallest_slott_bisect2 (version I posted) I am a bit surprised that mine is so slow compared with yours. I'll do more tests later! Strange. I see a significant difference only for python3 (on 64bit Linux) $ python3

Re: PyPy and RPython

2010-09-02 Thread sarvi
When I think about it these restrictions below seem a very reasonable tradeoff for performance. And I can use this for just the modules/sections that are performance critical. Essentially, the PyPy interpreter can have a restricted mode that enforces these restriction. This will help write such

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Dmitry Chichkov
Uh. I'm sorry about the confusion. Last three items are just O(N) baselines. Python min(), Numpy argmin(), Numpy asarray(). I'll update the code. Thanks! A lot of the following doesn't run or returns incorrect results. To give but one example: def nargsmallest_numpy_argmin(iter, k):    

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Dmitry Chichkov
By the way, improving n-ARG-smallest (that returns indexes as well as values) is actually more desirable than just regular n-smallest: == Result == 1.38639092445 nargsmallest 3.1569879055 nargsmallest_numpy_argsort 1.29344892502 nargsmallest_numpy_argmin Note that numpy array constructor eats

comp.lang.python

2010-09-02 Thread roshini begum
www.127760.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Speed-up for loops

2010-09-02 Thread Michael Kreim
Hi, I was comparing the speed of a simple loop program between Matlab and Python. My Codes: $ cat addition.py imax = 10 a = 0 for i in xrange(imax): a = a + 10 print a $ cat addition.m imax = 1e9; a = 0; for i=0:imax-1 a = a + 10; end disp(a); exit; The results look like

Re: python path separator

2010-09-02 Thread swapnil
On Sep 2, 12:25 pm, Vlastimil Brom vlastimil.b...@gmail.com wrote: 2010/9/2 swapnil swapnil...@gmail.com: I could not find any documentation for variables os.path.sep and os.path.altsep. Although the first is pretty straightforward can anyone explain the purpose of the second variable? Is

I GOT $5000 FROM PAYPAL BY SIMPLE HACK.

2010-09-02 Thread paypal cash
I GOT $5000 FROM PAYPAL BY SIMPLE HACK At http://happyandeasy.co.cc Due to high security risks, i have hidden the PayPal Form link in an image. in that website On RIGHT SIDE Below search box , click on image and enter your PAYPAL id And Your name. --

Re: Speed-up for loops

2010-09-02 Thread Peter Otten
Michael Kreim wrote: I was comparing the speed of a simple loop program between Matlab and Python. My Codes: $ cat addition.py imax = 10 a = 0 for i in xrange(imax): a = a + 10 print a Are there any ways to speed up the for/xrange loop? Move it into a function; this

Re: dirty problem 3 lines

2010-09-02 Thread bussiere bussiere
It seems to work perfectly thanks a lot Bussiere Google Fan boy On Thu, Sep 2, 2010 at 7:32 AM, alex23 wuwe...@gmail.com wrote: bussiere bussiere bussi...@gmail.com wrote: it's just as it seems : i want to know how does ti works to get back an object from a string in python :

Re: Speed-up for loops

2010-09-02 Thread Michael Kreim
Peter Otten wrote: Move it into a function; this turns a and i into local variables. def f(): imax = 10 a = 0 for i in xrange(imax): a = a + 10 print a f() Wow. It is still slower than Matlab, but your suggestion speeds up the code by ca 50%. But I do not

Re: Speed-up for loops

2010-09-02 Thread Peter Otten
Michael Kreim wrote: Peter Otten wrote: Move it into a function; this turns a and i into local variables. def f(): imax = 10 a = 0 for i in xrange(imax): a = a + 10 print a f() Wow. It is still slower than Matlab, but your suggestion speeds up the

argparse list

2010-09-02 Thread Neal Becker
I'm interested in using argparse to parse a string formatted as: my_prog --option1=1,10,37 That is, a list of comma delimited values. I guess nargs almost does it, but expects options to be space-delimited. What would be the easiest approach? --

Re: argparse list

2010-09-02 Thread Peter Otten
Neal Becker wrote: I'm interested in using argparse to parse a string formatted as: my_prog --option1=1,10,37 That is, a list of comma delimited values. I guess nargs almost does it, but expects options to be space-delimited. What would be the easiest approach? import argparse def

Re: argparse list

2010-09-02 Thread Neal Becker
Peter Otten wrote: import argparse def csv(value): ... return map(int, value.split(,)) ... p = argparse.ArgumentParser() p.add_argument(--option1, type=csv) and None p.parse_args([--option1=1,10,37]) Thanks! But, why the 'and None'? --

Safely decoding user input

2010-09-02 Thread Tom Miller
Hello everyone, Before I pose my question, I should mention that I'm still pretty unfamiliar with proper terminology for string encoding, so I might get some of it wrong. Please bear with me. I'm writing a program that accepts arguments from the command line. Some of my users are using Windows

Re: argparse list

2010-09-02 Thread Peter Otten
Neal Becker wrote: Peter Otten wrote: import argparse def csv(value): ... return map(int, value.split(,)) ... p = argparse.ArgumentParser() p.add_argument(--option1, type=csv) and None p.parse_args([--option1=1,10,37]) Thanks! But, why the 'and None'? To hide the result of

Re: parsing string into dict

2010-09-02 Thread Aleksey
On Sep 2, 12:46 am, Tim Arnold a_j...@bellsouth.net wrote: Hi, I have a set of strings that are *basically* comma separated, but with the exception that if a comma occur insides curly braces it is not a delimiter.  Here's an example: [code=one, caption={My Analysis for \textbf{t}, Version

Re: parsing string into dict

2010-09-02 Thread Aleksey
On Sep 2, 12:46 am, Tim Arnold a_j...@bellsouth.net wrote: Hi, I have a set of strings that are *basically* comma separated, but with the exception that if a comma occur insides curly braces it is not a delimiter.  Here's an example: [code=one, caption={My Analysis for \textbf{t}, Version

Re: Speed-up for loops

2010-09-02 Thread Tim Wintle
On Thu, 2010-09-02 at 12:02 +0200, Michael Kreim wrote: Hi, I was comparing the speed of a simple loop program between Matlab and Python. Unfortunately my Python Code was much slower and I do not understand why. The main reason is that, under the hood, cpython does something like this (in

profiling qt programs

2010-09-02 Thread Duim
I'm trying to get a qt program a little faster by looking at the most expensive functions. To find out which functions are most important I wanted to profile the application using cProfile module. Unfortunately this runs through the complete code in 1 go without waiting until all threads (or in

Re: Speed-up for loops

2010-09-02 Thread Stefan Behnel
Tim Wintle, 02.09.2010 14:55: If you really need to optimise it then you can convert that module to cython by adding a cdef, and then compile it: cdef int i for i in xrange(imax): a = a + 10 print a or you can write it in C it'll run a lot faster. Just to get the context right here: a

first non-null element in a list, otherwise None

2010-09-02 Thread wheres pythonmonks
This should be trivial: I am looking to extract the first non-None element in a list, and None otherwise. Here's one implementation: x = reduce(lambda x,y: x or y, [None,None,1,None,2,None], None) print x 1 I thought maybe a generator expression would be better, to prevent iterating over

Re: first non-null element in a list, otherwise None

2010-09-02 Thread Peter Otten
wheres pythonmonks wrote: I am looking to extract the first non-None element in a list, and None otherwise. Here's one implementation: x = reduce(lambda x,y: x or y, [None,None,1,None,2,None], None) print x 1 I thought maybe a generator expression would be better, to prevent iterating

Re: Speed-up for loops

2010-09-02 Thread Hrvoje Niksic
Michael Kreim mich...@perfect-kreim.de writes: Are there any ways to speed up the for/xrange loop? Or do I have to live with the fact that Matlab beats Python in this example? To a point, yes. However, there are things you can do to make your Python code go faster. One has been pointed out

Re: first non-null element in a list, otherwise None

2010-09-02 Thread wheres pythonmonks
Peter wrote: But this can be expensive memory wise.  Is there a way to concatenate generator expressions? itertools.chain() Aha! import itertools x = itertools.chain( (x for x in [None,None] if x is not None), [ None ] ).next() print x None x = itertools.chain( (x for x in [None,7] if

Re: Speed-up for loops

2010-09-02 Thread Roland Koebler
Hi, Are there any ways to speed up the for/xrange loop? You can use psyco. The following example should be about 4-times as fast as your example: import psyco psyco.full() def f(): imax = 10 a = 0 for i in xrange(imax): a += 10 print a f() regards,

Re: argparse list

2010-09-02 Thread Michele Simionato
On Sep 2, 1:45 pm, Neal Becker ndbeck...@gmail.com wrote: I'm interested in using argparse to parse a string formatted as: my_prog --option1=1,10,37 That is, a list of comma delimited values.  I guess nargs almost does it, but expects options to be space-delimited. What would be the

Re: first non-null element in a list, otherwise None

2010-09-02 Thread Arnaud Delobelle
On Sep 2, 2:48 pm, wheres pythonmonks wherespythonmo...@gmail.com wrote: This should be trivial: I am looking to extract the first non-None element in a list, and None otherwise.  Here's one implementation: x = reduce(lambda x,y: x or y, [None,None,1,None,2,None], None) print x 1 I

Help needed with Windows Service in Python

2010-09-02 Thread Ian Hobson
Hi All, I am attempting to create a Windows Service in Python. I have the framework (from Mark Hammond and Andy Robinason's book) running - see below. It starts fine - but it will not stop. :( net stop Python Service and using the services GUI both leave the services showing it as stopping

Re: first non-null element in a list, otherwise None

2010-09-02 Thread Gerard Flanagan
wheres pythonmonks wrote: This should be trivial: I am looking to extract the first non-None element in a list, and None otherwise. Here's one implementation: x = reduce(lambda x,y: x or y, [None,None,1,None,2,None], None) print x 1 I thought maybe a generator expression would be better,

Re: killing all subprocess childrens

2010-09-02 Thread Nobody
On Thu, 02 Sep 2010 13:12:07 +1000, Astan Chee wrote: I have a piece of code that looks like this: import subprocess retcode = subprocess.call([java,test,string]) print Exited with retcode + str(retcode) What I'm trying to do (and wondering if its possible) is to make sure that any

Re: python path separator

2010-09-02 Thread Nobody
On Wed, 01 Sep 2010 23:57:21 -0700, swapnil wrote: I could not find any documentation for variables os.path.sep and os.path.altsep. Although the first is pretty straightforward can anyone explain the purpose of the second variable? Is it even useful? The purpose is so that you can do e.g.:

Customizing cgitb

2010-09-02 Thread D'Arcy J.M. Cain
I have a small problem with the cgitb module. I know that I can basically write my own version but it seems kind of silly to rewrite something that does 99% what I want. Here is an excerpt from the output of an exception. 1520 (current_job['job_id'], job['_SELECT_'])) 1521

Re: Speed-up for loops

2010-09-02 Thread Nobody
On Thu, 02 Sep 2010 12:02:40 +0200, Michael Kreim wrote: I was comparing the speed of a simple loop program between Matlab and Python. imax = 10 a = 0 for i in xrange(imax): a = a + 10 print a Are there any ways to speed up the for/xrange loop? Sure; the above can be

Re: Windows vs. file.read

2010-09-02 Thread MRAB
On 02/09/2010 08:49, Lawrence D'Oliveiro wrote: In messagemailman.330.1283362312.29448.python-l...@python.org, MRAB wrote: You should open the files in binary mode, not text mode, ie file(path, rb). Text mode is the default. Not a problem on *nix because the line ending is newline. We used

Re: Help needed with Windows Service in Python

2010-09-02 Thread David
Il Thu, 02 Sep 2010 16:22:04 +0100, Ian Hobson ha scritto: self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) You may try to give a WaitHint parameter to ReportServiceStatus call, otherwise the Service Manager will expect the service is stopped istantly.

Re: Customizing cgitb

2010-09-02 Thread Peter Otten
D'Arcy J.M. Cain wrote: I have a small problem with the cgitb module. I know that I can basically write my own version but it seems kind of silly to rewrite something that does 99% what I want. Here is an excerpt from the output of an exception. 1520

Re: Speed-up for loops

2010-09-02 Thread Tim Wintle
On Thu, 2010-09-02 at 16:13 +0200, Roland Koebler wrote: Hi, Are there any ways to speed up the for/xrange loop? You can use psyco. Assuming you've got a 32-bit machine. -- http://mail.python.org/mailman/listinfo/python-list

Re: Customizing cgitb

2010-09-02 Thread D'Arcy J.M. Cain
On Thu, 02 Sep 2010 19:02:35 +0200 Peter Otten __pete...@web.de wrote: You could try to monkey-patch pydoc: I suppose so. Not a comfortable solution of course. It's bad enough when you get too familiar with the internals of a module but even worse when you need to get familiar with the

Financial time series data

2010-09-02 Thread Virgil Stokes
Has anyone written code or worked with Python software for downloading financial time series data (e.g. from Yahoo financial)? If yes, would you please contact me. --Thanks, V. Stokes -- http://mail.python.org/mailman/listinfo/python-list

RE: Speed-up for loops

2010-09-02 Thread Philip Bloom
Uh. Try: Imax=10 a=0 i=0 While(iimax): a= a+10 i=i+1 print a I suspect you will find it is way faster than using range or xrange for large numbers and map far more closely in the final result to what you are doing on matlab's side. At least last I checked, xrange and

Re: Help needed with Windows Service in Python

2010-09-02 Thread ipatrol6...@yahoo.com
Well for one, if you're writing with pywin32, you certainly don't need the shbang line. #! /usr/bin/env is purely a POSIX thing. -- http://mail.python.org/mailman/listinfo/python-list

Re: Financial time series data

2010-09-02 Thread Hidura
But what kind of data you want to download?, because the financial time it's basicly html code and you can work very well with a parser 2010/9/2, Virgil Stokes v...@it.uu.se: Has anyone written code or worked with Python software for downloading financial time series data (e.g. from Yahoo

Re: Windows vs. file.read

2010-09-02 Thread ipatrol6...@yahoo.com
Correct in that regard. In Python 3.x, strings are by default considered UTF-8. Wheras ASCII isn't a problem because it's fixed-width, UTF-8 will give you a different character depending on the last byte value. Therefore handling any kind of data that is not UTF-8 will need you to open it with

MySQL Problem

2010-09-02 Thread Victor Subervi
Hi; I have this code: print 'select * from spreadsheets s join products p on p.Item=s.Item join productsCategories pc on p.ID=pc.ProductsID join categories c on pc.CategoryID=c.ID where s.Client=%s order by c.Category, c.Parent' % (client,) cursor.execute('select * from spreadsheets s

Re: Help needed with Windows Service in Python

2010-09-02 Thread Ian
On 02/09/2010 18:03, David wrote: Il Thu, 02 Sep 2010 16:22:04 +0100, Ian Hobson ha scritto: self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) You may try to give a WaitHint parameter to ReportServiceStatus call, otherwise the Service Manager will expect the service is stopped

Re: Reversing a List

2010-09-02 Thread Victor Subervi
On Wed, Sep 1, 2010 at 9:26 AM, Shashwat Anand anand.shash...@gmail.comwrote: On Wed, Sep 1, 2010 at 6:45 PM, Matt Saxton m...@scotweb.co.uk wrote: On Wed, 1 Sep 2010 09:00:03 -0400 Victor Subervi victorsube...@gmail.com wrote: Hi; I have this code: cursor.execute('describe

Re: MySQL Problem

2010-09-02 Thread Ian
On 02/09/2010 19:34, Victor Subervi wrote: for some reason running the command through python *omits* this one data!! The only difference is that a flag in spreadsheets (Temp) is set to 1. Why on earth doesn't it work in python?? Some ideas to follow up. (These are only guesses). 1) One of

Re: Help needed with Windows Service in Python

2010-09-02 Thread Edward Kozlowski
On Sep 2, 10:22 am, Ian Hobson i...@ianhobson.co.uk wrote: Hi All, I am attempting to create a Windows Service in Python. I have the framework (from Mark Hammond and Andy Robinason's book) running - see below. It starts fine - but it will not stop. :( net stop Python Service and using

RE: Speed-up for loops

2010-09-02 Thread Peter Otten
Philip Bloom wrote: Uh. Try: Imax=10 a=0 i=0 While(iimax): a= a+10 i=i+1 print a I suspect you will find it is way faster than using range or xrange for large numbers and map far more closely in the final result to what you are doing on matlab's side. At

Re: Windows vs. file.read

2010-09-02 Thread Thomas Jollans
On Thursday 02 September 2010, it occurred to ipatrol6...@yahoo.com to exclaim: Correct in that regard. In Python 3.x, strings are by default considered UTF-8. Wheras ASCII isn't a problem because it's fixed-width, UTF-8 will give you a different character depending on the last byte value.

Re: Help needed with Windows Service in Python

2010-09-02 Thread Ian
On 02/09/2010 20:06, Edward Kozlowski wrote: On Sep 2, 10:22 am, Ian Hobsoni...@ianhobson.co.uk wrote: Hi All, I am attempting to create a Windows Service in Python. I have the framework (from Mark Hammond and Andy Robinason's book) running - see below. It starts fine - but it will not

Re: Help needed with Windows Service in Python

2010-09-02 Thread Edward Kozlowski
On Sep 2, 2:38 pm, Ian hobso...@gmaiil.com wrote:   On 02/09/2010 20:06, Edward Kozlowski wrote: On Sep 2, 10:22 am, Ian Hobsoni...@ianhobson.co.uk  wrote: Hi All, I am attempting to create a Windows Service in Python. I have the framework (from Mark Hammond and Andy Robinason's

Re: killing all subprocess childrens

2010-09-02 Thread Aahz
In article mailman.353.1283398245.29448.python-l...@python.org, Astan Chee astan.c...@al.com.au wrote: Chris Rebert wrote: import os import psutil # http://code.google.com/p/psutil/ # your piece of code goes here myself = os.getpid() for proc in psutil.process_iter(): Is there a way

Re: Speed-up for loops

2010-09-02 Thread Carl Banks
On Sep 2, 5:55 am, Tim Wintle tim.win...@teamrubber.com wrote: On Thu, 2010-09-02 at 12:02 +0200, Michael Kreim wrote: Hi, I was comparing the speed of a simple loop program between Matlab and Python. Unfortunately my Python Code was much slower and I do not understand why. The main

bisection method: Simulating a retirement fund

2010-09-02 Thread Baba
level: beginner exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset4.pdf Problem 4 Can my code be optimised? I think my approach is correct but i am hesitant about the initial

Re: Performance: sets vs dicts.

2010-09-02 Thread Terry Reedy
On 9/1/2010 10:57 PM, ru...@yahoo.com wrote: So while you may think most people rarely read the docs for basic language features and objects (I presume you don't mean to restrict your statement to only sets), I and most people I know *do* read them. And when read them I expect them, as any

Obscure MySQLdb question - duplicating a database handle

2010-09-02 Thread John Nagle
I have a system which does error logging to its database: db = MySQLdb.connect(...) # get database connection ... errorlog(db, Message) The problem is that I want errorlog to commit its message to the table used for error logging, but don't want to commit whatever the

Re: PyPy and RPython

2010-09-02 Thread John Nagle
On 9/2/2010 1:29 AM, sarvi wrote: When I think about it these restrictions below seem a very reasonable tradeoff for performance. Yes. And I can use this for just the modules/sections that are performance critical. Not quite. Neither Shed Skin nor RPython let you call from

Re: Performance: sets vs dicts.

2010-09-02 Thread Terry Reedy
On 9/1/2010 8:11 PM, John Bokma wrote: Terry Reedytjre...@udel.edu writes: On 9/1/2010 5:40 PM, John Bokma wrote: [..] Yes, I switched, because 'constant time' is a comprehensible claim that can be refuted and because that is how some will interpret O(1) (see below for proof;-). You

Sum of product-please help

2010-09-02 Thread Nally Kaunda-Bukenya
Dear all, kindly help me with this code; This script  is supposed to calculate Rvi for each row by first summing the product of #fields (Ai*Rv) and dividing by another field (Tot) such that  Rvi=sum(Ai*Rv)/Tot. First it's acting like I need another parenthesis and it doesn't seem to work at

Re: bisection method: Simulating a retirement fund

2010-09-02 Thread MRAB
On 02/09/2010 21:37, Baba wrote: level: beginner exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset4.pdf Problem 4 Can my code be optimised? I think my approach is correct but

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Terry Reedy
On 9/1/2010 9:08 PM, Dmitry Chichkov wrote: Given: a large list (10,000,000) of floating point numbers; Task: fastest python code that finds k (small, e.g. 10) smallest items, preferably with item indexes; Limitations: in python, using only standard libraries (numpy scipy is Ok); I've tried

Re: Sum of product-please help

2010-09-02 Thread MRAB
On 02/09/2010 23:01, Nally Kaunda-Bukenya wrote: Dear all, kindly help me with this code; This script is supposed to calculate Rvi for each row by first summing the product of #fields (Ai*Rv) and dividing by another field (Tot) such that Rvi=sum(Ai*Rv)/Tot. First it's acting like I need another

Re: Speed-up for loops

2010-09-02 Thread Terry Reedy
On 9/2/2010 8:55 AM, Tim Wintle wrote: On Thu, 2010-09-02 at 12:02 +0200, Michael Kreim wrote: Hi, I was comparing the speed of a simple loop program between Matlab and Python. Unfortunately my Python Code was much slower and I do not understand why. The main reason is that, under the

Re: killing all subprocess childrens

2010-09-02 Thread Chris Rebert
On Thu, Sep 2, 2010 at 12:58 PM, Aahz a...@pythoncraft.com wrote: In article mailman.353.1283398245.29448.python-l...@python.org, Astan Chee  astan.c...@al.com.au wrote: Chris Rebert wrote: import os import psutil # http://code.google.com/p/psutil/ # your piece of code goes here myself =

Re: Fibonacci: returning a selection of the series

2010-09-02 Thread Baba
On Aug 29, 7:18 pm, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: In general, if you have a program that produces something just to remove/ignore it five lines later, you have a problem. In your case: 1) are you sure you need to append to list(*) at every iteration? When do you *really*

Re: Obscure MySQLdb question - duplicating a database handle

2010-09-02 Thread John Bokma
John Nagle na...@animats.com writes: I have a system which does error logging to its database: db = MySQLdb.connect(...) # get database connection ... errorlog(db, Message) The problem is that I want errorlog to commit its message to the table used for error logging,

Re: DeprecationWarning

2010-09-02 Thread cerr
On Sep 1, 5:04 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Sep 1, 2010 at 8:58 AM, cerr ron.egg...@gmail.com wrote: Hi There, I would like to create an scp handle and download a file from a client. I have following code: snip but what i'm getting is this and no file is

Re: Selecting k smallest or largest elements from a large list in python; (benchmarking)

2010-09-02 Thread Dmitry Chichkov
Yes, you are right of course. But it is not really a contest. And if you could improve algorithm or implementation on your Python version running under your OS on your hardware it may as well improve performance for other people under other OS's. On Sep 2, 3:14 pm, Terry Reedy tjre...@udel.edu

Re: DeprecationWarning

2010-09-02 Thread Chris Rebert
On Thu, Sep 2, 2010 at 4:19 PM, cerr ron.egg...@gmail.com wrote: On Sep 1, 5:04 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Sep 1, 2010 at 8:58 AM, cerr ron.egg...@gmail.com wrote: Hi There, I would like to create an scp handle and download a file from a client. I have following

Re: Financial time series data

2010-09-02 Thread Virgil Stokes
On 09/02/2010 08:15 PM, Hidura wrote: But what kind of data you want to download?, because the financial time it's basicly html code and you can work very well with a parser 2010/9/2, Virgil Stokesv...@it.uu.se: Has anyone written code or worked with Python software for downloading

Re: Help needed with Windows Service in Python

2010-09-02 Thread Mark Hammond
On 3/09/2010 1:22 AM, Ian Hobson wrote: Hi All, I am attempting to create a Windows Service in Python. I have the framework (from Mark Hammond and Andy Robinason's book) running - see below. It starts fine - but it will not stop. :( net stop Python Service and using the services GUI both

Re: Financial time series data

2010-09-02 Thread MRAB
On 03/09/2010 00:56, Virgil Stokes wrote: On 09/02/2010 08:15 PM, Hidura wrote: But what kind of data you want to download?, because the financial time it's basicly html code and you can work very well with a parser 2010/9/2, Virgil Stokesv...@it.uu.se: Has anyone written code or worked with

Re: Re: Financial time series data

2010-09-02 Thread hidura
I've tried to see the page and the code GSPC it's wrong i has used ^DJI, and when you download the page code use a xml parser localize the table element and read it. I can't access from the browser to the next page it doesn't appear as a link. El , Virgil Stokes v...@it.uu.se escribió: On

Re: DeprecationWarning

2010-09-02 Thread cerr
On Sep 2, 4:25 pm, Chris Rebert c...@rebertia.com wrote: On Thu, Sep 2, 2010 at 4:19 PM, cerr ron.egg...@gmail.com wrote: On Sep 1, 5:04 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Sep 1, 2010 at 8:58 AM, cerr ron.egg...@gmail.com wrote: Hi There, I would like to create an scp

Re: Windows vs. file.read

2010-09-02 Thread Lawrence D'Oliveiro
In message mailman.379.1283444129.29448.python-l...@python.org, MRAB wrote: On 02/09/2010 08:49, Lawrence D'Oliveiro wrote: In messagemailman.330.1283362312.29448.python-l...@python.org, MRAB wrote: You should open the files in binary mode, not text mode, ie file(path, rb). Text mode is

Does MySQLdb rollback on control-C? Maybe not.

2010-09-02 Thread John Nagle
I would expect MySQLdb to rollback on a control-C, but it doesn't seem to have done so. I have a program which does a thousand or so INSERT operations in one transaction on an InnoDB table. I kill it with a control-C on Windows, and it aborts. But it looks like some of the INSERT

Re: PyPy and RPython

2010-09-02 Thread sarvi
On Sep 2, 2:19 pm, John Nagle na...@animats.com wrote: On 9/2/2010 1:29 AM, sarvi wrote: When I think about it these restrictions below seem a very reasonable tradeoff for performance.     Yes. And I can use this for just the modules/sections that are performance critical.     Not

[issue9739] Output of help(...) is wider than 80 characters

2010-09-02 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Aren't there tools that extract only the first line of help? -- assignee: - d...@python components: +Documentation -Extension Modules nosy: +amaury.forgeotdarc, d...@python ___ Python

[issue9739] Output of help(...) is wider than 80 characters

2010-09-02 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9739 ___ ___

[issue7141] 2to3 should add from __future__ import print_statement

2010-09-02 Thread Giampaolo Rodola'
Giampaolo Rodola' g.rod...@gmail.com added the comment: it's not really the point of 2to3 to port apps to 2.6. +1 -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7141

  1   2   >