Re: Wrote a memoize function: I do not mind feedback

2015-04-29 Thread Cecil Westerhof
Op Wednesday 29 Apr 2015 10:58 CEST schreef Mark Lawrence: >> It is not only performance wise, I find the code without the try >> also better looking. But that is very personally I suppose. >> > > You might find this interesting > http://www.jeffknupp.com/blog/2013/02/06/write-cleaner-python-use-e

Re: Wrote a memoize function: I do not mind feedback

2015-04-29 Thread Mark Lawrence
On 29/04/2015 09:04, Cecil Westerhof wrote: Op Wednesday 29 Apr 2015 09:02 CEST schreef Ian Kelly: On Wed, Apr 29, 2015 at 12:06 AM, Cecil Westerhof wrote: Op Monday 27 Apr 2015 22:35 CEST schreef Albert-Jan Roskam: def some_func(arg, _memoize={}): try: return _memoize[arg] except KeyError:

Re: Wrote a memoize function: I do not mind feedback

2015-04-29 Thread Cecil Westerhof
Op Wednesday 29 Apr 2015 09:02 CEST schreef Ian Kelly: > On Wed, Apr 29, 2015 at 12:06 AM, Cecil Westerhof wrote: >> Op Monday 27 Apr 2015 22:35 CEST schreef Albert-Jan Roskam: >>> def some_func(arg, _memoize={}): >>> try: >>> return _memoize[arg] >>> except KeyError: >>> result = some_expensive_

Re: Wrote a memoize function: I do not mind feedback

2015-04-29 Thread Ian Kelly
On Wed, Apr 29, 2015 at 12:06 AM, Cecil Westerhof wrote: > Op Monday 27 Apr 2015 22:35 CEST schreef Albert-Jan Roskam: >> def some_func(arg, _memoize={}): >> try: >> return _memoize[arg] >> except KeyError: >> result = some_expensive_operation(arg) >> _memoize[arg] = result >> return result > > Th

Re: Wrote a memoize function: I do not mind feedback

2015-04-28 Thread Cecil Westerhof
Op Monday 27 Apr 2015 22:35 CEST schreef Albert-Jan Roskam: > - Original Message - >> From: Peter Otten <__pete...@web.de> >> To: python-list@python.org >> Cc: >> Sent: Monday, April 27, 2015 4:28 PM >> Subject: Re: Wrote a memoize function: I do

Re: Wrote a memoize function: I do not mind feedback

2015-04-27 Thread Albert-Jan Roskam
- Original Message - > From: Peter Otten <__pete...@web.de> > To: python-list@python.org > Cc: > Sent: Monday, April 27, 2015 4:28 PM > Subject: Re: Wrote a memoize function: I do not mind feedback > > Cecil Westerhof wrote: > >> I started again with

Re: Wrote a memoize function: I do not mind feedback

2015-04-27 Thread Peter Otten
Cecil Westerhof wrote: > I started again with Python. In Clojure you have memoize. I thought it > nice to have this in Python also. So I wrote it. With a Fibonacci > function to show the usefulness. > You can find it here: > https://github.com/CecilWesterhof/PythonLibrary > > I love to hear w

Wrote a memoize function: I do not mind feedback

2015-04-27 Thread Cecil Westerhof
I started again with Python. In Clojure you have memoize. I thought it nice to have this in Python also. So I wrote it. With a Fibonacci function to show the usefulness. You can find it here: https://github.com/CecilWesterhof/PythonLibrary I love to hear what you think of it. And ideas for ot