<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Python Blog - All about python &#187; decorators</title>
	<atom:link href="http://www.python-blog.com/tag/decorators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.python-blog.com</link>
	<description>and technologies around</description>
	<lastBuildDate>Tue, 27 Jul 2010 19:58:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pydev 1.5.1 &#8211; still getting better.</title>
		<link>http://www.python-blog.com/2009/11/20/pydev-1-5-1-still-getting-better/</link>
		<comments>http://www.python-blog.com/2009/11/20/pydev-1-5-1-still-getting-better/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 23:02:41 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[1.5.1]]></category>
		<category><![CDATA[decorators]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[eclipse plugin]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[PyDev]]></category>
		<category><![CDATA[pydev 1.5]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=214</guid>
		<description><![CDATA[Few days ago there was again a major update on pydev eclipse plugin.
The version 1.5.1. Comes with new refactoring engine PEPTIC, it&#8217;s way better than any one before.
Complete list below: visit http://pydev.org for download.

Release 1.5.1

Improvements in the AST rewriter
Improvements on the refactoring engine:

No longer using BRM
Merged with the latest PEPTIC
Inline local available
Extract method bug-fixes
Extract local [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago there was again a major update on pydev eclipse plugin.<br />
The version 1.5.1. Comes with new refactoring engine PEPTIC, it&#8217;s way better than any one before.<br />
Complete list below: visit <a href="http://pydev.org" target="_blank">http://pydev.org</a> for download.</p>
<div id="release-1-5-1">
<h1>Release 1.5.1</h1>
<ul>
<li>Improvements in the AST rewriter</li>
<li>Improvements on the refactoring engine:
<ul>
<li>No longer using BRM</li>
<li>Merged with the latest PEPTIC</li>
<li>Inline local available</li>
<li>Extract method bug-fixes</li>
<li>Extract local on multi-line</li>
<li>Generating properties using coding style defined in preferences</li>
<li>Add after current method option added to extract method</li>
<li>A bunch of other corner-case situations were fixed</li>
</ul>
</li>
<li>Bug-fixes:
<ul>
<li>Minor editor improvements</li>
<li>Adding default forced builtins on all platforms (e.g.: time, math, etc) which wouldn&#8217;t be on sys.builtin_module_names on some python installations</li>
<li>Adding &#8216;numpy&#8217; and &#8216;Image&#8217; to the forced builtins always</li>
<li>Ctrl+1: Generate docstring minor fixes</li>
<li>Ctrl+1: Assign to local now follows coding style preferences properly</li>
<li>Exponential with uppercase E working on code-formatting</li>
<li>When a set/get method is found in code-completion for a java class an NPE is no longer thrown</li>
<li>Backspace properly treated in block mode</li>
<li>Setting IRONPYTHONPATH when dealing with Iron Python (projects could not be referenced)</li>
<li>No longer giving spurious &#8217;statement has no effect&#8217; inside of lambda and decorators</li>
<li>Fixed new exec in python 3k</li>
<li>Fixed NPE when breakpoint is related to a resource in a removed project</li>
<li>Fixed import problem on regexp that could lead to a recursion.</li>
<li>No longer giving NPE when debugging with the register view open</li>
<li>List access be treated as __getitem__() in the list &#8212; patch from Tassilo Barth</li>
<li>Fix for invalid auto-self added when typing</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/11/20/pydev-1-5-1-still-getting-better/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Functions execution time decorator &#8211; parametrized</title>
		<link>http://www.python-blog.com/2009/06/27/functions-execution-time-decorator-parametrized/</link>
		<comments>http://www.python-blog.com/2009/06/27/functions-execution-time-decorator-parametrized/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 00:21:48 +0000</pubDate>
		<dc:creator>Marcin Kuźmiński</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[decorators]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[execution time measure]]></category>
		<category><![CDATA[python blog]]></category>
		<category><![CDATA[Threads]]></category>

		<guid isPermaLink="false">http://www.python-blog.com/?p=71</guid>
		<description><![CDATA[UPDATE: i added two small fixes. When a functions is returning let&#8217;s pass the return value further, and exception when there&#8217;s no parameters.
I began studying more about decorators. I made a simple one for now it can be used to calculate execution time in miliseconds,seconds,minutes or hours of function decorated. It uses closures with wrapper [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: i added two small fixes. When a functions is returning let&#8217;s pass the return value further, and exception when there&#8217;s no parameters.</p>
<p>I began studying more about decorators. I made a simple one for now it can be used to calculate execution time in miliseconds,seconds,minutes or hours of function decorated. It uses closures with wrapper function for handling parameters. Next time i&#8217;ll post decorator for running a function in a background using threads.</p>
<p>Here&#8217;s the code:</p>
<pre class="brush:python">''' @author: marcink '''

import time
from types import FunctionType

class GetExecutionTime:
    '''
    This generic class is meant to be used as decorator for messuring
    simple method execution time it works on class methods as well
    as regular non class functions ;
    Availible parameters:
        'ms' - miliseconds
        's' - seconds
        'm' - minutes
        'h' - hours
    usage: @GetExecutionTime(param)

    samples:
    @GetExecutionTime('s')
    def samplemethod(self,params):
        function body
    will print executions time at end in seconds

    @GetExecutionTime('m')
    def samplemethod(params):
        function body
    will print executions time at end in minutes

     '''

    def __init__(self, *args):
        #in case of calling without parametrs
        #first argument will be the function decorated raise exception than

        if len(args) is 0 or type(args[0]) is FunctionType:
            raise Exception("Calling decorator without parameters is not possible")
        else:
            self.fn = None
            self.d_as = args[0]

        def miliseconds():return 1
        def seconds(): return 10000000000
        def minutes():return seconds() * 60
        def hours(): return minutes() * 60
        def default_():return seconds()

        #this is a cool way to replace switch case with default parameter
        commands = {'ms':miliseconds,
                    's':seconds,
                    'm':minutes,
                    'h':hours}
        self.display_as = commands.get(self.d_as, default_)()

    def __call__(self,fn):

        display_as = self.display_as
        d_as = self.d_as

        def wrapper_function(*args, **kwargs):
            start = time.time()

            ret = fn(*args,**kwargs)

            end = time.time()
            microsec = (end - start) * 10000000000

            print "function %s execution time: %s %s" % (fn.__name__, (microsec) / display_as, d_as)
            if ret:
                return ret
        return wrapper_function

#EXAMPLES:

from time import sleep

@GetExecutionTime('s')
def short_func(max, min):
    for x in range(3):
        sleep(1)
    print max,min
    return (max, min)

short_func(100, 10)

''' prints: function short_func execution time: 3.00342392921 s '''</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.python-blog.com/2009/06/27/functions-execution-time-decorator-parametrized/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
