Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-24 Thread Barry Scott
t; > Date: Friday, October 7, 2022 at 1:30 PM > To: MRAB mailto:pyt...@mrabarnett.plus.com>> > Cc: python-list@python.org <mailto:python-list@python.org> > mailto:python-list@python.org>> > Subject: Re: Ref-strings in logging messages (was: Performance issue with

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-08 Thread Weatherby,Gerard
hello" logging.basicConfig() logging.debug(Defer(some_expensive_function)) From: Python-list on behalf of Barry Date: Friday, October 7, 2022 at 1:30 PM To: MRAB Cc: python-list@python.org Subject: Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython) *** Attentio

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Julian Smith
On Fri, 7 Oct 2022 18:28:06 +0100 Barry wrote: > > On 7 Oct 2022, at 18:16, MRAB wrote: > > > > On 2022-10-07 16:45, Skip Montanaro wrote: > >>> On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames > >>> > >>> wrote: > >>> 1. The culprit was me. As lazy as I am, I have used f-strings all over the >

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
ebug = logger_from(DEBUG) log_debug and log_debug(‘expensive %s’ % (complex(),)) Barry > > From: Python-list on > behalf of Barry > Date: Friday, October 7, 2022 at 1:30 PM > To: MRAB > Cc: python-list@python.org > Subject: Re: Ref-strings in logging messages (was: Pe

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Weatherby,Gerard
To: MRAB Cc: python-list@python.org Subject: Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython) *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** > On 7 Oct 2022, at 18:16, MRAB wrote: >

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
> On 7 Oct 2022, at 18:16, MRAB wrote: > > On 2022-10-07 16:45, Skip Montanaro wrote: >>> On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames >>> wrote: >>> 1. The culprit was me. As lazy as I am, I have used f-strings all over the >>> place in calls to `logging.logger.debug()` and friends, evaluatin

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread MRAB
On 2022-10-07 16:45, Skip Montanaro wrote: On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames wrote: 1. The culprit was me. As lazy as I am, I have used f-strings all over the place in calls to `logging.logger.debug()` and friends, evaluating all arguments regardless of whether the logger was enabled

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
> On 7 Oct 2022, at 16:48, Skip Montanaro wrote: > > On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames > wrote: > >> 1. The culprit was me. As lazy as I am, I have used f-strings all over the >> place in calls to `logging.logger.debug()` and friends, evaluating all >> arguments regardless of wheth

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Skip Montanaro
Dang autocorrect. Subject first word was supposed to be "f-strings" not "ref-strings." Sorry about that. S On Fri, Oct 7, 2022, 10:45 AM Skip Montanaro wrote: > > > On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames > wrote: > >> 1. The culprit was me. As lazy as I am, I have used f-strings all over

Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Skip Montanaro
On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames wrote: > 1. The culprit was me. As lazy as I am, I have used f-strings all over the > place in calls to `logging.logger.debug()` and friends, evaluating all > arguments regardless of whether the logger was enabled or not. > I thought there was some dis

Re: Performance issue with CPython 3.10 + Cython

2022-10-07 Thread Andreas Ames
Answering to myself, just for the records: 1. The culprit was me. As lazy as I am, I have used f-strings all over the place in calls to `logging.logger.debug()` and friends, evaluating all arguments regardless of whether the logger was enabled or not. Replacing these f-strings by regular printf-l

Performance issue with CPython 3.10 + Cython

2022-10-04 Thread Andreas Ames
Hi all, I am wrapping an embedded application (, which does not use any dynamic memory management,) using Cython to call it from CPython. The wrapped application uses a cyclic executive, i.e. everything is done in the input-logic-output design, typical for some real-time related domains. Conseque

Re: A performance issue when using default value

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 20:58:50 -0800, keakon wrote: > I've found strange performance issue when using default value, the test > code is list below: > > from timeit import Timer > > def f(x): > y = x > y.append(1) > return y > > def g(x=[]): > y =

Re: A performance issue when using default value

2010-01-31 Thread alex23
keakon wrote: > The default value is mutable, and can be reused by all each call. > So each call it will append 1 to the default value, that's very > different than C++. Being different from C++ is one of the many reasons some of us choose Python ;) This tends to bite most newcomers, so it's men

Re: A performance issue when using default value

2010-01-31 Thread keakon
On 2月1日, 下午1时20分, alex23 wrote: > alex23 wrote: > > keakon wrote: > > > def h2(x=[]): > > > y = x > > > y.append(1) > > > return y + [] > > > Are you aware that 'y = x' _doesn't_ make a copy of [], that it > > actually points to the same list as x? > > Sorry, I meant to suggest trying the

Re: A performance issue when using default value

2010-01-31 Thread alex23
alex23 wrote: > keakon wrote: > > def h2(x=[]): > >   y = x > >   y.append(1) > >   return y + [] > > Are you aware that 'y = x' _doesn't_ make a copy of [], that it > actually points to the same list as x? Sorry, I meant to suggest trying the following instead: def h2(x=None): if x is None:

Re: A performance issue when using default value

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 8:58 PM, keakon wrote: > I've found strange performance issue when using default value, the > test code is list below: > > from timeit import Timer > > def f(x): >  y = x >  y.append(1) >  return y > > def g(x=[]): >  y = [] >  y

Re: A performance issue when using default value

2010-01-31 Thread alex23
keakon wrote: > def h2(x=[]): >   y = x >   y.append(1) >   return y + [] > h2() is about 42 times slower than h2([]), but h() is a litter faster > than h([]). Are you aware that 'y = x' _doesn't_ make a copy of [], that it actually points to the same list as x? My guess is that the slowdown yo

A performance issue when using default value

2010-01-31 Thread keakon
I've found strange performance issue when using default value, the test code is list below: from timeit import Timer def f(x): y = x y.append(1) return y def g(x=[]): y = [] y.append(1) return y def h(x=[]): y = x y.append(1) return y def f2(x): y = x y.app

Re: Strange performance issue

2009-10-06 Thread Dan Stromberg
Ulrich Eckhardt wrote: Dan Stromberg wrote: My new version formats an SD card and preallocates some file space in about 3 minutes with "Optimize Performance" selected, and in about 30 minutes with "Optimize for Quick Removal" selected. Needless to say, I don't like the 27 minute penalty much

Re: Strange performance issue

2009-10-06 Thread Dan Stromberg
Steven D'Aprano wrote: On Mon, 05 Oct 2009 22:31:05 -0700, Dan Stromberg wrote: I'm rewriting 3 programs as one program - from Python with Tkinter to Python with pygtk, both on Windows XP. My new version formats an SD card and preallocates some file space in about 3 minutes with "Optimize P

Re: Strange performance issue

2009-10-06 Thread Ulrich Eckhardt
Dan Stromberg wrote: > My new version formats an SD card and preallocates some file space in > about 3 minutes with "Optimize Performance" selected, and in about 30 > minutes with "Optimize for Quick Removal" selected. Needless to say, I > don't like the 27 minute penalty much. For performance, t

Re: Strange performance issue

2009-10-06 Thread Steven D'Aprano
On Mon, 05 Oct 2009 22:31:05 -0700, Dan Stromberg wrote: > I'm rewriting 3 programs as one program - from Python with Tkinter to > Python with pygtk, both on Windows XP. > > My new version formats an SD card and preallocates some file space in > about 3 minutes with "Optimize Performance" selecte

Strange performance issue

2009-10-05 Thread Dan Stromberg
I'm rewriting 3 programs as one program - from Python with Tkinter to Python with pygtk, both on Windows XP. My new version formats an SD card and preallocates some file space in about 3 minutes with "Optimize Performance" selected, and in about 30 minutes with "Optimize for Quick Removal" s

Re: Levenshtein word comparison -performance issue

2009-02-19 Thread S.Selvam Siva
On Sat, Feb 14, 2009 at 3:01 PM, Peter Otten <__pete...@web.de> wrote: > Gabriel Genellina wrote: > > > En Fri, 13 Feb 2009 08:16:00 -0200, S.Selvam Siva < > s.selvams...@gmail.com> > > escribió: > > > >> I need some help. > >> I tried to find top n(eg. 5) similar words for a given word, from a >

Re: Levenshtein word comparison -performance issue

2009-02-14 Thread Peter Otten
Gabriel Genellina wrote: > En Fri, 13 Feb 2009 08:16:00 -0200, S.Selvam Siva > escribió: > >> I need some help. >> I tried to find top n(eg. 5) similar words for a given word, from a >> dictionary of 50,000 words. >> I used python-levenshtein module,and sample code is as follow. >> >> def foo(se

Re: Levenshtein word comparison -performance issue

2009-02-13 Thread Basilisk96
On Feb 13, 5:42 am, "Gabriel Genellina" wrote: > You may replace the last steps (sort + slice top 5) by heapq.nlargest - at   > least you won't waste time sorting 49995 irrelevant words... > Anyway you should measure the time taken by the first part (Levenshtein),   > it may be the most demanding.

Re: Levenshtein word comparison -performance issue

2009-02-13 Thread Terry Reedy
Gabriel Genellina wrote: En Fri, 13 Feb 2009 08:16:00 -0200, S.Selvam Siva escribió: I need some help. I tried to find top n(eg. 5) similar words for a given word, from a dictionary of 50,000 words. I used python-levenshtein module,and sample code is as follow. def foo(searchword): disdi

Re: Levenshtein word comparison -performance issue

2009-02-13 Thread Gabriel Genellina
En Fri, 13 Feb 2009 08:16:00 -0200, S.Selvam Siva escribió: I need some help. I tried to find top n(eg. 5) similar words for a given word, from a dictionary of 50,000 words. I used python-levenshtein module,and sample code is as follow. def foo(searchword): disdict={} for word in sel

Levenshtein word comparison -performance issue

2009-02-13 Thread S.Selvam Siva
Hi all, I need some help. I tried to find top n(eg. 5) similar words for a given word, from a dictionary of 50,000 words. I used python-levenshtein module,and sample code is as follow. def foo(searchword): disdict={} for word in self.dictionary-words: distance=Levenshte

Re: cgitb performance issue

2008-05-15 Thread Ethan Furman
Gabriel Genellina wrote: En Wed, 14 May 2008 13:51:40 -0300, Ethan Furman <[EMAIL PROTECTED]> escribió: Gabriel Genellina wrote: En Mon, 05 May 2008 15:56:26 -0300, Ethan Furman <[EMAIL PROTECTED]> escribió: I tried adding a form to our website for uploading large files. Personally, I

Re: cgitb performance issue

2008-05-15 Thread Gabriel Genellina
En Wed, 14 May 2008 13:51:40 -0300, Ethan Furman <[EMAIL PROTECTED]> escribió: Gabriel Genellina wrote: En Mon, 05 May 2008 15:56:26 -0300, Ethan Furman <[EMAIL PROTECTED]> escribió: I tried adding a form to our website for uploading large files. Personally, I dislike the forms that tell yo

Re: cgitb performance issue

2008-05-14 Thread Ethan Furman
Gabriel Genellina wrote: En Mon, 05 May 2008 15:56:26 -0300, Ethan Furman <[EMAIL PROTECTED]> escribió: I tried adding a form to our website for uploading large files. Personally, I dislike the forms that tell you you did something wrong and make you re-enter *all* your data again, so this

Re: cgitb performance issue

2008-05-11 Thread Gabriel Genellina
En Mon, 05 May 2008 15:56:26 -0300, Ethan Furman <[EMAIL PROTECTED]> escribió: > I tried adding a form to our website for uploading large files. > Personally, I dislike the forms that tell you you did something wrong > and make you re-enter *all* your data again, so this one cycles and > remembers

cgitb performance issue

2008-05-05 Thread Ethan Furman
Greetings! I tried adding a form to our website for uploading large files. Personally, I dislike the forms that tell you you did something wrong and make you re-enter *all* your data again, so this one cycles and remembers your answers, and only prompts for the file once the rest of the ente

Re: Random Drawing Simulation -- performance issue

2006-09-13 Thread David J. Braden
David J. Braden wrote: > Travis E. Oliphant wrote: >> Brendon Towle wrote: >>> I need to simulate scenarios like the following: "You have a deck of >>> 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, >>> replace it, and repeat N times." >>> >> >> Thinking about the problem as

Re: Random Drawing Simulation -- performance issue

2006-09-13 Thread David J. Braden
Travis E. Oliphant wrote: > Brendon Towle wrote: >> I need to simulate scenarios like the following: "You have a deck of >> 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, >> replace it, and repeat N times." >> > > Thinking about the problem as drawing sample froms a discret

Re: Random Drawing Simulation -- performance issue

2006-09-13 Thread Brendon Towle
On 13 Sep 2006, at 1:01 AM, [EMAIL PROTECTED] wrote: > Date: 12 Sep 2006 20:17:47 -0700 > From: Paul Rubin <http://[EMAIL PROTECTED]> > Subject: Re: Random Drawing Simulation -- performance issue > To: python-list@python.org > > "Travis E. Oliphant" <[EM

Re: Random Drawing Simulation -- performance issue

2006-09-13 Thread Brendon Towle
On 12 Sep 2006, at 6:33 PM, [EMAIL PROTECTED] wrote: > Date: 12 Sep 2006 15:23:51 -0700 > From: "Simon Forman" <[EMAIL PROTECTED]> > Subject: Re: Random Drawing Simulation -- performance issue > > Brendon Towle wrote: >> I need to simulate scenarios like th

Re: Random Drawing Simulation -- performance issue

2006-09-12 Thread Robert Kern
Paul Rubin wrote: > "Travis E. Oliphant" <[EMAIL PROTECTED]> writes: >>> I need to simulate scenarios like the following: "You have a deck of >>> 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, >>> replace it, and repeat N times." >>> >> Thinking about the problem as drawing samp

Re: Random Drawing Simulation -- performance issue

2006-09-12 Thread Paul Rubin
"Travis E. Oliphant" <[EMAIL PROTECTED]> writes: > > I need to simulate scenarios like the following: "You have a deck of > > 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, > > replace it, and repeat N times." > > > Thinking about the problem as drawing sample froms a discrete >

Re: Random Drawing Simulation -- performance issue

2006-09-12 Thread Travis E. Oliphant
Brendon Towle wrote: > I need to simulate scenarios like the following: "You have a deck of > 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, > replace it, and repeat N times." > Thinking about the problem as drawing sample froms a discrete distribution defined by the popu

Re: Random Drawing Simulation -- performance issue

2006-09-12 Thread Simon Forman
Brendon Towle wrote: > I need to simulate scenarios like the following: "You have a deck of > 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, > replace it, and repeat N times." > > So, I wrote the following code, which works, but it seems quite slow > to me. Can anyone point out

Re: Random Drawing Simulation -- performance issue

2006-09-12 Thread David J. Braden
Brendon Towle wrote: > I need to simulate scenarios like the following: "You have a deck of 3 > orange cards, 5 yellow cards, and 2 blue cards. You draw a card, replace > it, and repeat N times." > > So, I wrote the following code, which works, but it seems quite slow to > me. Can anyone point

Random Drawing Simulation -- performance issue

2006-09-12 Thread Brendon Towle
I need to simulate scenarios like the following: "You have a deck of 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, replace it, and repeat N times." So, I wrote the following code, which works, but it seems quite slow to me. Can anyone point out some obvious thing that I'

Re: Performance issue

2005-04-02 Thread Steven Bethard
Marc 'BlackJack' Rintsch wrote: def make_anagram_map(words): anagram_map = dict() for word in imap(lambda w: w.strip().lower(), words): sorted_word = ''.join(sorted(list(word))) anagram_map.setdefault(sorted_word, list()).append(word) return dict(ifilter(lambda x: l

Re: Performance issue

2005-04-02 Thread Bengt Richter
On Sat, 02 Apr 2005 10:29:19 -0800, Shalabh Chaturvedi <[EMAIL PROTECTED]> wrote: >Tom Carrick wrote: >> Hi, >> >> In my attempted learning of python, I've decided to recode an old >> anagram solving program I made in C++. The C++ version runs in less >> than a second, while the python takes 30

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Tom Carrick wrote: > In my attempted learning of python, I've decided to recode an old > anagram solving program I made in C++. The C++ version runs in less > than a second, while the python takes 30 seconds. I'm not willing to > think it's just python being slow, so I was

Re: Performance issue

2005-04-02 Thread Shalabh Chaturvedi
Tom Carrick wrote: Hi, In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. I'm not willing to think it's just python being slow, so I was hoping someone could find a f

Re: Performance issue

2005-04-02 Thread Shalabh Chaturvedi
Tom Carrick wrote: Hi, In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. I'm not willing to think it's just python being slow, so I was hoping someone could find a f

Re: Performance issue

2005-04-02 Thread Thomas Rast
Tom Carrick <[EMAIL PROTECTED]> writes: > In my attempted learning of python, I've decided to recode an old > anagram solving program I made in C++. The C++ version runs in less > than a second, while the python takes 30 seconds. Indeed, your program can be improved to run about ten times as fast

Re: Performance issue

2005-04-02 Thread vincent wehren
"Tom Carrick" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] | Hi, | | In my attempted learning of python, I've decided to recode an old | anagram solving program I made in C++. The C++ version runs in less | than a second, while the python takes 30 seconds. I'm not willing to |

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Irmen de Jong wrote: >> words = file.splitlines() > > You can obtain this list without reading the file in its entirety, > by using the readlines method of file objects: > > words=open("words.txt").readlines() This leaves the newline characters at the end of each line wh

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
rdlist = string2list(words[0]) > wordlist.sort(lambda x, y: cmp(x, y)) > sorted_wordlist = wordlist > if sorted_anagram == sorted_wordlist: > found.append(words[0]) > del words[0] And here's the performance issue. Deleting the first element of a lis

Re: Performance issue

2005-04-02 Thread Irmen de Jong
Tom Carrick wrote: > Hi, > > In my attempted learning of python, I've decided to recode an old > anagram solving program I made in C++. The C++ version runs in less > than a second, while the python takes 30 seconds. I'm not willing to > think it's just python being slow, so I was hoping someone c

Performance issue

2005-04-02 Thread Tom Carrick
Hi, In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. I'm not willing to think it's just python being slow, so I was hoping someone could find a faster way of doing