Hello Naheed,
You seem to have messed up your quoting. Text starting with a > is a
quote, but in your reply, you have written text starting with > as if it
were written by me. I have fixed the quoting in this reply, but please
try to watch that.
See below for more comments.
naheed arafat w
On Sat, Jun 25, 2011 at 9:42 PM, Steven D'Aprano wrote:
> naheed arafat wrote:
>
>> 1)
>>
>>> zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' '))
>
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
>>
>>> map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am
>
fine.'
On Sat, Jun 25, 2011 at 9:38 PM, Alan Gauld wrote:
>
> "naheed arafat" wrote
>
> 1)
>>
>>> zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' '))
>
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
>>
>>> map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am
>
fine.'.
naheed arafat wrote:
> Is there any way easier to do the following?
> input:
> 'How are you'
> 'I am fine'
> output:
> 'you I are am How fine'
>
> solution:
' '.join(reduce(lambda x,y:x+y, zip('How are you'.split(' ')[::-1],
> 'I am fine'.split(' '
reversed(items) instead of items[::-1]
2011/6/25 naheed arafat :
> 1)
zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' '))
> [('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am
fine.'.split(' '))
> [('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
>
> Which on
naheed arafat wrote:
1)
zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' '))
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am
fine.'.split(' '))
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
Which one has better efficiency
"naheed arafat" wrote
1)
zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' '))
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am
fine.'.split(' '))
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]
Which one has better efficie
Shane O'Connor wrote:
Hi,
First-time poster here. I've a question about loop efficiency - I was
wondering whether this code:
i = 0
while i < 1000:
do something
i+=1
is more efficient than:
for i in range(1000):
do something
or:
for i in xrange(1000):
do something
You can
On Thu, Mar 17, 2011 at 8:45 AM, Stefan Behnel wrote:
> Note that a web application involves many things outside of your own code
> that seriously impact the performance and/or resource requirements. Database
> access can be slow, excessively dynamic page generation and template engines
> can bec
Shane O'Connor, 17.03.2011 01:32:
In particular, I'm using Python 2.4.3 on a web server which needs to run as
fast as possible using as little memory as possible (no surprises there!).
Note that a web application involves many things outside of your own code
that seriously impact the performan
"Shane O'Connor" wrote
First-time poster here. I've a question about loop efficiency - I
was
wondering whether this code:
i = 0
while i < 1000:
do something
i+=1
is more efficient than:
for i in range(1000):
do something
It is impossible to tell and 99% of the time irrelevant si
On 03/16/2011 08:32 PM, Shane O'Connor wrote:
> Hi,
>
> First-time poster here. I've a question about loop efficiency - I was
> wondering whether this code:
>
> i = 0
> while i < 1000:
> do something
> i+=1
>
> is more efficient than:
>
> for i in range(1000):
> do something
>
> or
On Wed, Mar 16, 2011 at 7:32 PM, Shane O'Connor wrote:
> Hi,
>
> First-time poster here. I've a question about loop efficiency - I was
> wondering whether this code:
>
> i = 0
> while i < 1000:
> do something
> i+=1
>
> is more efficient than:
>
> for i in range(1000):
> do something
>
"James Reynolds" wrote
On that end, I'm almost done readying "beginning Python: From Novice to
Professional" Can anyone recommend anything else for me to read after
that?
I'm not familiar with that book but I'd say consider what area of
programming you are interested in and get a specialist
On Sat, Mar 20, 2010 at 1:17 PM, Steven D'Aprano wrote:
> On Sat, 20 Mar 2010 05:47:45 am James Reynolds wrote:
>
> > This is a monte-carlo simulation.
> >
> > The simulation measures the expiration of something and those
> > somethings fall into bins that are not evenly dispersed. These bins
> >
On Sat, 20 Mar 2010 05:47:45 am James Reynolds wrote:
> This is a monte-carlo simulation.
>
> The simulation measures the expiration of something and those
> somethings fall into bins that are not evenly dispersed. These bins
> are stored in the nx list mentioned previously.
>
> So let's say you h
On Sat, 20 Mar 2010 03:41:11 am James Reynolds wrote:
> I've still been working towards learning the language, albeit slowly
> and I've been working on a project that is somewhat intense on the
> numerical calculation end of things.
>
> Running 10,000 trials takes about 1.5 seconds and running 100
(Please don't top-post. It ruins the context for anyone else trying to
follow it. Post your remarks at the end, or immediately after whatever
you're commenting on.)
James Reynolds wrote:
Here's another idea I had. I thought this would be slower than then the
previous algorithm because it has
James Reynolds, 19.03.2010 21:17:
Here's another idea I had. I thought this would be slower than then the
previous algorithm because it has another for loop and another while loop. I
read that the overhead of such loops is high, so I have been trying to avoid
using them where possible.
Prematur
"James Reynolds" wrote
Here's another idea I had. I thought this would be slower than then the
previous algorithm because it has another for loop and another while
loop. I
read that the overhead of such loops is high, so I have been trying to
avoid
using them where possible.
Thats often t
On Fri, Mar 19, 2010 at 3:17 PM, James Reynolds wrote:
> Here's another idea I had. I thought this would be slower than then the
> previous algorithm because it has another for loop and another while loop. I
> read that the overhead of such loops is high, so I have been trying to avoid
> using th
Here's another idea I had. I thought this would be slower than then the
previous algorithm because it has another for loop and another while loop. I
read that the overhead of such loops is high, so I have been trying to avoid
using them where possible.
def mcrange_gen(self, sample):
nx
"James Reynolds" wrote
I've made a few other optimizations today that I won't be able to test
until
I get home, but I was wondering if any of you could give some general
pointers on how to make python run a little more quickly.
Always, always, get the algorithm efficient before trying to mak
On 3/19/2010 9:41 AM James Reynolds said...
OK, so starting here:
def mcrange_gen(self, sample):
lensample = len(sample)
nx2 = self.nx1
nx2_append = nx2.append
nx2_sort = nx2.sort
nx2_reverse = nx2.reverse
nx2_index = nx2.index
nx2_remove = nx2.remove
for s in ra
Well, I'm always out to impress!
This is a monte-carlo simulation.
The simulation measures the expiration of something and those somethings
fall into bins that are not evenly dispersed. These bins are stored in the
nx list mentioned previously.
So let's say you have the bins, a, b,c,d,e,f and yo
James Reynolds, 19.03.2010 17:41:
I've still been working towards learning the language, albeit slowly and
I've been working on a project that is somewhat intense on the numerical
calculation end of things.
Running 10,000 trials takes about 1.5 seconds and running 100,000 trials
takes 11 seconds
Stephen McInerney wrote:
> Kent,
>
>
>>> I was asking if it's a recognized good programming practice to
>>> declare and initialize *all* members in the class defn.
>>>
>> What do you mean by "initialize *all* members in the class defn"?
>>
> - obviously I meant to say do it in the __
Stephen McInerney wrote:
> Kent,
>
>>> I was asking if it's a recognized good programming practice to
>>> declare and initialize *all* members in the class defn.
>>
>> What do you mean by "initialize *all* members in the class defn"?
> - obviously I meant to say do it in the __init__() method,
> I
Kent,
I was asking if it's a recognized good programming practice to
declare and initialize *all* members in the class defn.
What do you mean by "initialize *all* members in the class defn"?
- obviously I meant to say do it in the __init__() method,
I wrote the snippet as I was rushing out th
"Stephen McInerney" <[EMAIL PROTECTED]> wrote
> I was asking if it's a recognized good programming practice to
> declare and initialize *all* members in the class defn.
> I think I'm hearing a general yes on that - any other opinions?
It depends on what you mean by the class definition.
In gen
Stephen McInerney wrote:
> I was asking if it's a recognized good programming practice to
> declare and initialize *all* members in the class defn.
What do you mean by "initialize *all* members in the class defn"? Your
original example was not syntactically correct Python. You wrote:
class C
s
amming practice to
declare and initialize *all* members in the class defn.
I think I'm hearing a general yes on that - any other opinions?
Stephen
>From: Eric Brunson <[EMAIL PROTECTED]>
>To: Alan Gauld <[EMAIL PROTECTED]>
>CC: tutor@python.org
>Subject: Re: [Tutor] E
We're definitely on the same wavelength, Alan. :-)
Alan Gauld wrote:
> "Stephen McInerney" <[EMAIL PROTECTED]> wrote
>
>
>> Eric, you misunderstood my point.
>> I said you make a **token** assignment in the class defn simply
>> to do two things:
>> - 1) identify all the members in one place
>
"Stephen McInerney" <[EMAIL PROTECTED]> wrote
> Eric, you misunderstood my point.
> I said you make a **token** assignment in the class defn simply
> to do two things:
> - 1) identify all the members in one place
> - 2) annotate each member's type, as much as you can
I'm sure Eric can explain for
Eric, you misunderstood my point.
I said you make a **token** assignment in the class defn simply
to do two things:
- 1) identify all the members in one place
- 2) annotate each member's type, as much as you can
e.g.:
class C
s = []
d = {}
ot = (None, None)
I didn't say you make the actual assign
"Stephen McInerney" <[EMAIL PROTECTED]> wrote
>>lines to parse in a Python project, typically only a third or a
>>quarter of
>>the number of lines - sometimes less than that.
>
> Can you cite us a literature source for saying that Python is 3-4x
> more
> expressive per line-of-code than C++?
I
Stephen McInerney wrote:
> Hi Alan,
>
>
>>> My friend clarifies: "It's not the efficiency of doxygen that's the
>>> question. The problem is that you can add fields to objects as you go in
>>> Python so you need to do a deep analysis of the code to determine the
>>>
>> class
>>
>>>
> Is this not just evidence of a very bad Python coding style?
> Should we not always declare *all* class fields in the class definition
> by assigning to them, even if the assignment is token or dummy
> i.e. 'None', "", [], {} etc.
this is one of the many things that pylint can warn you about.
I
Stephen McInerney wrote:
> Hi Alan,
>
>>> My friend clarifies: "It's not the efficiency of doxygen that's the
>>> question. The problem is that you can add fields to objects as you go in
>>> Python so you need to do a deep analysis of the code to determine the
>> class
>>> structure which you don
Hi Alan,
> > My friend clarifies: "It's not the efficiency of doxygen that's the
> > question. The problem is that you can add fields to objects as you go in
> > Python so you need to do a deep analysis of the code to determine the
>class
> > structure which you don't have to do with C++ (or Java
"Stephen McInerney" <[EMAIL PROTECTED]> wrote
> Yes but it's still a canonical question about analysis of
> weakly-typed
> dynamic languages, since my Java friend makes separate comments
> about scalability when analyzing large builds - he claims 1-5m lines
> of
> code is a threshold.
There is
> My friend clarifies: "It's not the efficiency of doxygen that's the
> question. The problem is that you can add fields to objects as you go in
> Python so you need to do a deep analysis of the code to determine the class
> structure which you don't have to do with C++ (or Java)."
That's true
n Cameron <[EMAIL PROTECTED]>
>CC: tutor@python.org
>Subject: Re: [Tutor] Efficiency of Doxygen on Python vs C++?
>Date: Thu, 16 Aug 2007 22:06:13 -0400
>
>Kevin Cameron wrote:
> > Stephen McInerney wrote:
> >> My friend said the runtime efficiency of Doxygen on
Kevin Cameron wrote:
> Stephen McInerney wrote:
>> My friend said the runtime efficiency of Doxygen on his build was much
>> worse on the Python code than the C++ code, i.e. it took ages to parse
>> the Python code.
> It's not the efficiency of doxygen that's the question. The problem is
> that yo
Stephen McInerney wrote:
> My friend said the runtime efficiency of Doxygen on his build was much
> worse on the Python code than the C++ code, i.e. it took ages to parse
> the Python code.
It's not the efficiency of doxygen that's the question. The problem is
that you can add fields to objects as
My friend clarifies: "It's not the efficiency of doxygen that's the
question. The problem is that you can add fields to objects as you go in
Python so you need to do a deep analysis of the code to determine the class
structure which you don't have to do with C++ (or Java)."
He mentioned numbers
"Stephen McInerney" <[EMAIL PROTECTED]> wrote
> My friend said the runtime efficiency of Doxygen on his build was
> much
> worse on the Python code than the C++ code, i.e. it took ages to
> parse
> the Python code.
>
> Anyone agree/disagree, or have any efficiency tips on how to
> structure
>
47 matches
Mail list logo