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

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
In <[EMAIL PROTECTED]>, Tom Carrick wrote: > [รข] Also, I was wondering if there was a more > builtin, or just nicer way of converting a string to a list (or using > the sort function on a list) than making a function for it. Use the `list()` builtin on the string and *just* the `sort()` method::

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