[Python-ideas] Code snippet signature (Was: Publishing ideas on ActiveState recipe site)

anatoly techtonik techtonik at gmail.com
Wed Nov 7 08:14:01 CET 2012


Speaking about snippets in the thread about ActiveState recipe site
reminded me of this idea.

Snippet signature is a checksum over normalized source code with
stripped comments. The signature looks like `# snippet:site:hash`
added before function as a comment. Normalized means that code is
unindented and PEPified. Comments are also stripped as they may be
custom.

Signatures are useful to:
1. identify piece of code repeatably used in Python apps for potential
inclusion in Python library
2. measure popularity of snippets using automated code analysis
3. automatically check for updates using lookup on the given hash
4. automatically check if local code has improvements over the
original snippet by recalculating and comparing hash
5. lookup if snippets were integrated into standard (or some other library)
6. compile a Python library with mostly reused snippets on the server side

--
anatoly t.


On Wed, Nov 7, 2012 at 9:46 AM, anatoly techtonik <techtonik at gmail.com> wrote:
> On Tue, Nov 6, 2012 at 1:22 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>> On 05/11/12 23:52, Ned Batchelder wrote:
>>>
>>> Get everything the way you want it, and then propose it.
>>
>>
>> +1
>>
>> Also consider publishing it as a recipe on ActiveState, where many
>> people will view it, use it, and offer feedback. This has many
>> benefits:
>>
>> * You will gauge community interest;
>>
>> * Many eyeballs make bugs shallow;
>>
>> * You are providing a useful recipe that others can use, even
>>   if it doesn't get included in the std lib.
>>
>> Some of the most useful parts of the std lib, like namedtuple,
>> started life on ActiveState.
>>
>> http://code.activestate.com/recipes/langs/python/
>
> Why I don't use ActiveState:
>
> 1. StackOverflow is much easier to access - just one click to login
> with Google Account versus several clicks, data entry and copy/paste
> operations to remind the password on ActiveState - I want to login
> there with Python account
> 2. StackOverflow is problem search oriented - not recipe catalog
> oriented, which makes it better for solving problems, which I do more
> often than reading the recipe book (although I must admin when I was
> starting Python - the Cookbook from O'Reilly in CHM format was mega
> awesome)
> 3. I post the code as gists as it includes the notion of history,
> unlike ActiveState, which interface looks a little outdated - it was
> not obvious for me that recipes have history until today
> 4. Recipes are licensed, which is a too much of a burden for a snippet
> 5. ActiveState site makes it clear that it is ActiveState site - the
> 20% of my screen is taken by ActiveState header, so it looks like
> company site - not a site for community
>
> Otherwise the idea of community recipe site is very nice.



More information about the Python-ideas mailing list