cached-property icon indicating copy to clipboard operation
cached-property copied to clipboard

Credit where it's due

Open sloria opened this issue 10 years ago • 10 comments

The README currently says that the Django implementation is used, but I believe the implementation was originally the work of Marcel Hellkamp (@defnull) in bottle.py.

While it will always be tricky to pin down the "true source" of a piece of code, the git histories of bottle and django may be of some help. The cached_property decorator appeared in bottle a month before it appeared in django.

in bottle, Aug 2011: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76

in django, Sept 2011: https://github.com/django/django/commit/5009e45dfe366ebf520eecb49d72d5a11cee1623

Also, your docstring and variables names are exactly identical to Marcel's.

And one last friendly reminder: the licenses of both bottle and django (MIT and BSD, respectively) require a copyright notice to be posted.

sloria avatar May 18 '14 02:05 sloria

Thanks @sloria for identifying the true source. I had been looking at multiple implementations and went with what Bottle did, then forgot to update the README. I've now linked to @defnull's https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76 commit in the source.

As for the copyright notice, do you have an example of how it's done in instances like this?

pydanny avatar May 18 '14 17:05 pydanny

I believe that I wrote the Django version that this is based on. I can say definitely that the Django version is based on conversations (and maybe code?) I had with @mitsuhiko.

alex avatar May 18 '14 18:05 alex

@alex, @mitsuhiko This makes me wonder if the idea of a cached_property decorator emerged from several places at once.

The code at https://wiki.python.org/moin/PythonDecoratorLibrary#Cached_Properties makes me wish people added more specific date stamps to their code snippets. :P

pydanny avatar May 18 '14 18:05 pydanny

I can say for sure that the version in Django is code that I wrote on teh flight back from DjangoCon, with @carljm, at Midway airport. Probably in 2011. I think @mitsuhiko was at that DjangoCon in portland, so we probably discussed it there.

On Sun, May 18, 2014 at 11:18 AM, Daniel Greenfeld <[email protected]

wrote:

@alex https://github.com/alex, @mitsuhiko https://github.com/mitsuhikoThis makes me wonder if the idea of a cached_property decorator emerged from several places at once.

The code at https://wiki.python.org/moin/PythonDecoratorLibrary#Cached_Propertiesmakes me wish people added more specific date stamps to their code snippets. :P

— Reply to this email directly or view it on GitHubhttps://github.com/pydanny/cached-property/issues/1#issuecomment-43447070 .

"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

alex avatar May 18 '14 18:05 alex

It's a very small piece of code and somewhat obvious if you think about it, so I don't care much if my name is mentioned or not. That someone noticed, however, is really cool :) Thanks Steven, that made my day :)

It's only speculation but I am quite sure that @mitsuhiko watched the development of Bottle very closely for his own Flask framework. I find it plausible that he saw it, talked about it, and Alex implemented it in Django. Thats the way of open source. I'm fine with that :)

defnull avatar May 18 '14 18:05 defnull

https://github.com/mitsuhiko/werkzeug/blame/3c9905f9a490b245dff7fa1d9d60e4b371c02608/werkzeug/utils.py#L658 blames to 2007 the commit is from 2009

i wonder of @mitsuhiko came up with it while experimenting with the descriptor protocol, or if it arose differently

i vaguely recall earlier iterations - for quite a while it was a data descriptor before it got turned into a non-data descriptor

RonnyPfannschmidt avatar Feb 15 '16 12:02 RonnyPfannschmidt

Looks like birkenfeld introduced the function in 2007 https://github.com/mitsuhiko/werkzeug/commit/2fe4c8f24b42ba2d6f75ebe75dbc2ef80561fb8f

He's the one :)

defnull avatar Mar 04 '16 16:03 defnull

This also means that someone broke the nice properties of the decorator later by turning it into a data descriptor, then fixing it again in werkzeug 0.6, which perhaps explains why alex remembers talking about it with mitsuhiko at a later point.

Edit: Mitsuhiko broke the decorator here: https://github.com/mitsuhiko/werkzeug/commit/d2a4fbe472261bbd7ab45629f25cde6f1609ba91#diff-a4b29ff47a27aba363b13f31bd2f127fR1147

defnull avatar Mar 04 '16 16:03 defnull

The code at https://wiki.python.org/moin/PythonDecoratorLibrary#Cached_Properties makes me wish people added more specific date stamps to their code snippets. :P

I was the one who wrote and added that code. You can find the exact timestamp when it was added in the page history:

https://wiki.python.org/moin/PythonDecoratorLibrary?action=info

It's revision 103 from 2011-06-08 11:52:04

I probably wrote and used that code in closed-source projects before that. So, I think deserve some credit for the cached_property_ttl too :). At least the implementation is very similar.

SpotlightKid avatar Nov 06 '16 13:11 SpotlightKid

In case someone cares, lazy_property was not the first version. The trick with the data only descriptor comes from an earlier codebase but not sure which one. Might have been in the original pocoo project or alternatively in wsgitools or whatever that was called. Original author was probably either Georg or me.

mitsuhiko avatar Nov 06 '16 16:11 mitsuhiko