From 7fa512b4bbf45e9ec97a7f3c88b990273ae4a7ae Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Sun, 28 Nov 2010 10:37:06 +0100 Subject: Updated the documentation of decorator 3.2.1 --- decorator/documentation.html | 460 +++++---- decorator/documentation.pdf | 2150 +++++++++++++++++++++-------------------- decorator/documentation3.html | 86 +- decorator/documentation3.pdf | 1978 +++++++++++++++++++------------------ 4 files changed, 2355 insertions(+), 2319 deletions(-) diff --git a/decorator/documentation.html b/decorator/documentation.html index 79163a7..55936b3 100644 --- a/decorator/documentation.html +++ b/decorator/documentation.html @@ -83,10 +83,10 @@ E-mail:michele.simionato@gmail.com Version: -3.2.0 (2010-05-25) +3.2.1 (2010-11-28) Requires:Python 2.4+ -Download page:http://pypi.python.org/pypi/decorator/3.2.0 +Download page:http://pypi.python.org/pypi/decorator/3.2.1 Installation:easy_install decorator @@ -179,24 +179,22 @@ but they do not preserve the signature. A simple implementation could be the following (notice that in general it is impossible to memoize correctly something that depends on non-hashable arguments):

-
-
def memoize_uw(func):
-    func.cache = {}
-    def memoize(*args, **kw):
-        if kw: # frozenset is used to ensure hashability
-            key = args, frozenset(kw.iteritems())
-        else:
-            key = args
-        cache = func.cache
-        if key in cache:
-            return cache[key]
-        else:
-            cache[key] = result = func(*args, **kw)
-            return result
-    return functools.update_wrapper(memoize, func)
-
- -
+
+def memoize_uw(func):
+    func.cache = {}
+    def memoize(*args, **kw):
+        if kw: # frozenset is used to ensure hashability
+            key = args, frozenset(kw.iteritems())
+        else:
+            key = args
+        cache = func.cache
+        if key in cache:
+            return cache[key]
+        else:
+            cache[key] = result = func(*args, **kw)
+            return result
+    return functools.update_wrapper(memoize, func)
+

Here we used the functools.update_wrapper utility, which has been added in Python 2.5 expressly to simplify the definition of decorators (in older versions of Python you need to copy the function attributes @@ -211,7 +209,7 @@ general memoize_uw returns a function with a

>>> @memoize_uw
 ... def f1(x):
-...     time.sleep(1) # simulate some long computation
+...     time.sleep(1) # simulate some long computation
 ...     return x
 
@@ -232,10 +230,10 @@ pydoc will tell you that the function accepts a generic signature *args, **kw, but when you try to call the function with more than an argument, you will get an error:

-
>>> f1(0, 1)
+
>>> f1(0, 1)
 Traceback (most recent call last):
    ...
-TypeError: f1() takes exactly 1 argument (2 given)
+TypeError: f1() takes exactly 1 argument (2 given)
 
@@ -257,29 +255,25 @@ returns the decorated function. The caller function must have signature (f, *args, **kw) and it must call the original function f with arguments args and kw, implementing the wanted capability, i.e. memoization in this case:

-
-
def _memoize(func, *args, **kw):
-    if kw: # frozenset is used to ensure hashability
-        key = args, frozenset(kw.iteritems())
-    else:
-        key = args
-    cache = func.cache # attributed added by memoize
-    if key in cache:
-        return cache[key]
-    else:
-        cache[key] = result = func(*args, **kw)
-        return result
-
- -
+
+def _memoize(func, *args, **kw):
+    if kw: # frozenset is used to ensure hashability
+        key = args, frozenset(kw.iteritems())
+    else:
+        key = args
+    cache = func.cache # attributed added by memoize
+    if key in cache:
+        return cache[key]
+    else:
+        cache[key] = result = func(*args, **kw)
+        return result
+

At this point you can define your decorator as follows:

-
-
def memoize(f):
-    f.cache = {}
-    return decorator(_memoize, f)
-
- -
+
+def memoize(f):
+    f.cache = {}
+    return decorator(_memoize, f)
+

The difference with respect to the memoize_uw approach, which is based on nested functions, is that the decorator module forces you to lift the inner function at the outer level (flat is better than nested). @@ -289,7 +283,7 @@ decorate to the caller function.

>>> @memoize
 ... def heavy_computation():
-...     time.sleep(2)
+...     time.sleep(2)
 ...     return "done"
 
 >>> print heavy_computation() # the first time it will take 2 seconds
@@ -313,19 +307,15 @@ decorate to the caller function.

As an additional example, here is how you can define a trivial trace decorator, which prints a message everytime the traced function is called:

-
-
def _trace(f, *args, **kw):
-    print "calling %s with args %s, %s" % (f.__name__, args, kw)
-    return f(*args, **kw)
-
- -
-
-
def trace(f):
-    return decorator(_trace, f)
-
- -
+
+def _trace(f, *args, **kw):
+    print "calling %s with args %s, %s" % (f.__name__, args, kw)
+    return f(*args, **kw)
+
+
+def trace(f):
+    return decorator(_trace, f)
+

Here is an example of usage:

>>> @trace
@@ -336,8 +326,8 @@ function is called:

It is immediate to verify that f1 works

-
>>> f1(0)
-calling f1 with args (0,), {}
+
>>> f1(0)
+calling f1 with args (0,), {}
 
@@ -351,27 +341,27 @@ function is called:

The same decorator works with functions of any signature:

>>> @trace
-... def f(x, y=1, z=2, *args, **kw):
+... def f(x, y=1, z=2, *args, **kw):
 ...     pass
 
->>> f(0, 3)
-calling f with args (0, 3, 2), {}
+>>> f(0, 3)
+calling f with args (0, 3, 2), {}
 
 >>> print getargspec(f)
-ArgSpec(args=['x', 'y', 'z'], varargs='args', keywords='kw', defaults=(1, 2))
+ArgSpec(args=['x', 'y', 'z'], varargs='args', keywords='kw', defaults=(1, 2))
 

That includes even functions with exotic signatures like the following:

>>> @trace
-... def exotic_signature((x, y)=(1,2)): return x+y
+... def exotic_signature((x, y)=(1,2)): return x+y
 
 >>> print getargspec(exotic_signature)
-ArgSpec(args=[['x', 'y']], varargs=None, keywords=None, defaults=((1, 2),))
+ArgSpec(args=[['x', 'y']], varargs=None, keywords=None, defaults=((1, 2),))
 >>> exotic_signature()
-calling exotic_signature with args ((1, 2),), {}
-3
+calling exotic_signature with args ((1, 2),), {}
+3
 
@@ -405,7 +395,7 @@ For instance, you can write directly

object which can be used as a decorator:

>>> trace
-<function trace at 0x...>
+<function trace at 0x...>
 
@@ -429,40 +419,38 @@ object which can be used as a decorator:

sometimes it is best to have back a "busy" message than to block everything. This behavior can be implemented with a suitable family of decorators, where the parameter is the busy message:

-
-
def blocking(not_avail):
-    def blocking(f, *args, **kw):
-        if not hasattr(f, "thread"): # no thread running
-            def set_result(): f.result = f(*args, **kw)
-            f.thread = threading.Thread(None, set_result)
-            f.thread.start()
-            return not_avail
-        elif f.thread.isAlive():
-            return not_avail
-        else: # the thread is ended, return the stored result
-            del f.thread
-            return f.result
-    return decorator(blocking)
-
- -
+
+def blocking(not_avail):
+    def blocking(f, *args, **kw):
+        if not hasattr(f, "thread"): # no thread running
+            def set_result(): f.result = f(*args, **kw)
+            f.thread = threading.Thread(None, set_result)
+            f.thread.start()
+            return not_avail
+        elif f.thread.isAlive():
+            return not_avail
+        else: # the thread is ended, return the stored result
+            del f.thread
+            return f.result
+    return decorator(blocking)
+

Functions decorated with blocking will return a busy message if the resource is unavailable, and the intended result if the resource is available. For instance:

>>> @blocking("Please wait ...")
 ... def read_data():
-...     time.sleep(3) # simulate a blocking resource
+...     time.sleep(3) # simulate a blocking resource
 ...     return "some data"
 
 >>> print read_data() # data is not available yet
 Please wait ...
 
->>> time.sleep(1)
+>>> time.sleep(1)
 >>> print read_data() # data is not available yet
 Please wait ...
 
->>> time.sleep(1)
+>>> time.sleep(1)
 >>> print read_data() # data is not available yet
 Please wait ...
 
@@ -490,66 +478,58 @@ is executed in a separate thread. Moreover, it is possible to set
 three callbacks on_success, on_failure and on_closing,
 to specify how to manage the function call.
 The implementation is the following:

-
-
def on_success(result): # default implementation
-    "Called on the result of the function"
-    return result
-
- -
-
-
def on_failure(exc_info): # default implementation
-    "Called if the function fails"
-    pass
-
- -
-
-
def on_closing(): # default implementation
-    "Called at the end, both in case of success and failure"
-    pass
-
- -
-
-
class Async(object):
-    """
-    A decorator converting blocking functions into asynchronous
-    functions, by using threads or processes. Examples:
-
-    async_with_threads =  Async(threading.Thread)
-    async_with_processes =  Async(multiprocessing.Process)
-    """
-
-    def __init__(self, threadfactory):
-        self.threadfactory = threadfactory
-
-    def __call__(self, func, on_success=on_success,
-                 on_failure=on_failure, on_closing=on_closing):
-        # every decorated function has its own independent thread counter
-        func.counter = itertools.count(1)
-        func.on_success = on_success
-        func.on_failure = on_failure
-        func.on_closing = on_closing
-        return decorator(self.call, func)
-
-    def call(self, func, *args, **kw):
-        def func_wrapper():
-            try:
-                result = func(*args, **kw)
-            except:
-                func.on_failure(sys.exc_info())
-            else:
-                return func.on_success(result)
-            finally:
-                func.on_closing()
-        name = '%s-%s' % (func.__name__, func.counter.next())
-        thread = self.threadfactory(None, func_wrapper, name)
-        thread.start()
-        return thread
-
- -
+
+def on_success(result): # default implementation
+    "Called on the result of the function"
+    return result
+
+
+def on_failure(exc_info): # default implementation
+    "Called if the function fails"
+    pass
+
+
+def on_closing(): # default implementation
+    "Called at the end, both in case of success and failure"
+    pass
+
+
+class Async(object):
+    """
+    A decorator converting blocking functions into asynchronous
+    functions, by using threads or processes. Examples:
+
+    async_with_threads =  Async(threading.Thread)
+    async_with_processes =  Async(multiprocessing.Process)
+    """
+
+    def __init__(self, threadfactory):
+        self.threadfactory = threadfactory
+
+    def __call__(self, func, on_success=on_success,
+                 on_failure=on_failure, on_closing=on_closing):
+        # every decorated function has its own independent thread counter
+        func.counter = itertools.count(1)
+        func.on_success = on_success
+        func.on_failure = on_failure
+        func.on_closing = on_closing
+        return decorator(self.call, func)
+
+    def call(self, func, *args, **kw):
+        def func_wrapper():
+            try:
+                result = func(*args, **kw)
+            except:
+                func.on_failure(sys.exc_info())
+            else:
+                return func.on_success(result)
+            finally:
+                func.on_closing()
+        name = '%s-%s' % (func.__name__, func.counter.next())
+        thread = self.threadfactory(None, func_wrapper, name)
+        thread.start()
+        return thread
+

The decorated function returns the current execution thread, which can be stored and checked later, for instance to verify that the thread .isAlive().

@@ -566,7 +546,7 @@ be locked. Here is a minimalistic example:

... def write(data): ... # append data to the datalist by locking ... with threading.Lock(): -... time.sleep(1) # emulate some long running operation +... time.sleep(1) # emulate some long running operation ... datalist.append(data) ... # other operations not requiring a lock here
@@ -576,14 +556,14 @@ be locked. Here is a minimalistic example:

be no synchronization problems since write is locked.

>>> write("data1")
-<Thread(write-1, started...)>
+<Thread(write-1, started...)>
 
->>> time.sleep(.1) # wait a bit, so we are sure data2 is written after data1
+>>> time.sleep(.1) # wait a bit, so we are sure data2 is written after data1
 
 >>> write("data2")
-<Thread(write-2, started...)>
+<Thread(write-2, started...)>
 
->>> time.sleep(2) # wait for the writers to complete
+>>> time.sleep(2) # wait for the writers to complete
 
 >>> print datalist
 ['data1', 'data2']
@@ -610,8 +590,8 @@ were the function is generated by exec. Here i
 ...     print args, kw
 
 >>> f1 = FunctionMaker.create('f1(a, b)', 'f(a, b)', dict(f=f))
->>> f1(1,2)
-(1, 2) {}
+>>> f1(1,2)
+(1, 2) {}
 
@@ -674,14 +654,12 @@ available. In the past I have considered this acceptable, since inspect.getsource does not really work even with regular decorators. In that case inspect.getsource gives you the wrapper source code which is probably not what you want:

-
-
def identity_dec(func):
-    def wrapper(*args, **kw):
-        return func(*args, **kw)
-    return wrapper
-
- -
+
+def identity_dec(func):
+    def wrapper(*args, **kw):
+        return func(*args, **kw)
+    return wrapper
+
@identity_dec
 def example(): pass
@@ -694,7 +672,7 @@ source code which is probably not what you want:

(see bug report 1764286 for an explanation of what is happening). -Unfortunately the bug is still there, even in Python 2.6 and 3.0. +Unfortunately the bug is still there, even in Python 2.7 and 3.1. There is however a workaround. The decorator module adds an attribute .undecorated to the decorated function, containing a reference to the original function. The easy way to get @@ -703,10 +681,10 @@ undecorated function:

>>> print inspect.getsource(factorial.undecorated)
 @tail_recursive
-def factorial(n, acc=1):
+def factorial(n, acc=1):
     "The good old factorial"
-    if n == 0: return acc
-    return factorial(n-1, n*acc)
+    if n == 0: return acc
+    return factorial(n-1, n*acc)
 <BLANKLINE>
 
@@ -720,18 +698,16 @@ decorator is not signature-preserving. Therefore you may want an easy way to upgrade third party decorators to signature-preserving decorators without having to rewrite them in terms of decorator. You can use a FunctionMaker to implement that functionality as follows:

-
-
def decorator_apply(dec, func):
-    """
-    Decorate a function by preserving the signature even if dec
-    is not a signature-preserving decorator.
-    """
-    return FunctionMaker.create(
-        func, 'return decorated(%(signature)s)',
-        dict(decorated=dec(func)), undecorated=func)
-
- -
+
+def decorator_apply(dec, func):
+    """
+    Decorate a function by preserving the signature even if dec
+    is not a signature-preserving decorator.
+    """
+    return FunctionMaker.create(
+        func, 'return decorated(%(signature)s)',
+        dict(decorated=dec(func)), undecorated=func)
+

decorator_apply sets the attribute .undecorated of the generated function to the original function, so that you can get the right source code.

@@ -745,60 +721,54 @@ pretty slick decorator that converts a tail-recursive function in an iterative function. I have shamelessly stolen the basic idea from Kay Schluehr's recipe in the Python Cookbook, http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691.

-
-
class TailRecursive(object):
-    """
-    tail_recursive decorator based on Kay Schluehr's recipe
-    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691
-    with improvements by me and George Sakkis.
-    """
-
-    def __init__(self, func):
-        self.func = func
-        self.firstcall = True
-        self.CONTINUE = object() # sentinel
-
-    def __call__(self, *args, **kwd):
-        CONTINUE = self.CONTINUE
-        if self.firstcall:
-            func = self.func
-            self.firstcall = False
-            try:
-                while True:
-                    result = func(*args, **kwd)
-                    if result is CONTINUE: # update arguments
-                        args, kwd = self.argskwd
-                    else: # last call
-                        return result
-            finally:
-                self.firstcall = True
-        else: # return the arguments of the tail call
-            self.argskwd = args, kwd
-            return CONTINUE
-
- -
+
+class TailRecursive(object):
+    """
+    tail_recursive decorator based on Kay Schluehr's recipe
+    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691
+    with improvements by me and George Sakkis.
+    """
+
+    def __init__(self, func):
+        self.func = func
+        self.firstcall = True
+        self.CONTINUE = object() # sentinel
+
+    def __call__(self, *args, **kwd):
+        CONTINUE = self.CONTINUE
+        if self.firstcall:
+            func = self.func
+            self.firstcall = False
+            try:
+                while True:
+                    result = func(*args, **kwd)
+                    if result is CONTINUE: # update arguments
+                        args, kwd = self.argskwd
+                    else: # last call
+                        return result
+            finally:
+                self.firstcall = True
+        else: # return the arguments of the tail call
+            self.argskwd = args, kwd
+            return CONTINUE
+

Here the decorator is implemented as a class returning callable objects.

-
-
def tail_recursive(func):
-    return decorator_apply(TailRecursive, func)
-
- -
+
+def tail_recursive(func):
+    return decorator_apply(TailRecursive, func)
+

Here is how you apply the upgraded decorator to the good old factorial:

+
+@tail_recursive
+def factorial(n, acc=1):
+    "The good old factorial"
+    if n == 0: return acc
+    return factorial(n-1, n*acc)
+
-
@tail_recursive
-def factorial(n, acc=1):
-    "The good old factorial"
-    if n == 0: return acc
-    return factorial(n-1, n*acc)
-
- -
-
-
>>> print factorial(4)
-24
+
>>> print factorial(4)
+24
 
@@ -807,13 +777,11 @@ your mind ;) Notice that there is no recursion limit now, and you can easily compute factorial(1001) or larger without filling the stack frame. Notice also that the decorator will not work on functions which are not tail recursive, such as the following

-
-
def fact(n): # this is not tail-recursive
-    if n == 0: return 1
-    return n * fact(n-1)
-
- -
+
+def fact(n): # this is not tail-recursive
+    if n == 0: return 1
+    return n * fact(n-1)
+

(reminder: a function is tail recursive if it either returns a value without making a recursive call, or returns directly the result of a recursive call).

@@ -859,7 +827,7 @@ longer and more difficult to understand. Consider this example:

>>> @trace
 ... def f():
-...     1/0
+...     1/0
 
@@ -869,11 +837,11 @@ function is decorated the traceback will be longer:

>>> f()
 Traceback (most recent call last):
   ...
-     File "<string>", line 2, in f
-     File "<doctest __main__[18]>", line 4, in trace
+     File "<string>", line 2, in f
+     File "<doctest __main__[18]>", line 4, in trace
        return f(*args, **kw)
-     File "<doctest __main__[47]>", line 3, in f
-       1/0
+     File "<doctest __main__[47]>", line 3, in f
+       1/0
 ZeroDivisionError: integer division or modulo by zero
 
@@ -926,7 +894,7 @@ called too late:

The solution is to extract the inner function from the unbound method:

>>> trace(C.meth.im_func)
-<function meth at 0x...>
+<function meth at 0x...>
 
@@ -945,7 +913,9 @@ you will get a NameError:

-

Finally, the implementation is such that the decorated function contains +

Finally, the implementation is such that the decorated function +attribute .func_globals is a copy of the original function +attribute. Moreover the decorated function contains a copy of the original function dictionary (vars(decorated_f) is not vars(f)):

diff --git a/decorator/documentation.pdf b/decorator/documentation.pdf index 457d503..f1d4aed 100644 --- a/decorator/documentation.pdf +++ b/decorator/documentation.pdf @@ -1,4 +1,4 @@ -%PDF-1.3 +%PDF-1.4 %“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com % 'BasicFonts': class PDFDictionary 1 0 obj @@ -6,10 +6,9 @@ << /F1 2 0 R /F2 3 0 R /F3 4 0 R - /F4 5 0 R - /F5 8 0 R - /F6 38 0 R - /F7 40 0 R >> + /F4 7 0 R + /F5 37 0 R + /F6 41 0 R >> endobj % 'F1': class PDFType1Font 2 0 obj @@ -38,17 +37,8 @@ endobj /Subtype /Type1 /Type /Font >> endobj -% 'F4': class PDFType1Font -5 0 obj -% Font Times-Roman -<< /BaseFont /Times-Roman - /Encoding /WinAnsiEncoding - /Name /F4 - /Subtype /Type1 - /Type /Font >> -endobj % 'Annot.NUMBER1': class PDFDictionary -6 0 obj +5 0 obj << /A << /S /URI /Type /Action /URI (mailto:michele.simionato@gmail.com) >> @@ -56,362 +46,362 @@ endobj 0 0 ] /Rect [ 153.7323 - 707.5936 - 526.5827 - 719.5936 ] + 704.7736 + 289.4623 + 716.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER2': class PDFDictionary -7 0 obj +6 0 obj << /A << /S /URI /Type /Action - /URI (http://pypi.python.org/pypi/decorator/3.2.0) >> + /URI (http://pypi.python.org/pypi/decorator/3.2.1) >> /Border [ 0 0 0 ] /Rect [ 153.7323 - 662.5936 + 659.7736 526.5827 - 674.5936 ] + 671.7736 ] /Subtype /Link /Type /Annot >> endobj -% 'F5': class PDFType1Font -8 0 obj +% 'F4': class PDFType1Font +7 0 obj % Font Courier << /BaseFont /Courier /Encoding /WinAnsiEncoding - /Name /F5 + /Name /F4 /Subtype /Type1 /Type /Font >> endobj % 'Annot.NUMBER3': class LinkAnnotation -9 0 obj +8 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 37 0 R + /Dest [ 36 0 R /XYZ 62.69291 311.0236 0 ] /Rect [ 62.69291 - 563.5936 + 560.7736 121.0229 - 575.5936 ] + 572.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER4': class LinkAnnotation -10 0 obj +9 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 37 0 R + /Dest [ 36 0 R /XYZ 62.69291 311.0236 0 ] /Rect [ 527.0227 - 563.5936 + 560.7736 532.5827 - 575.5936 ] + 572.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER5': class LinkAnnotation -11 0 obj +10 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 40 0 R /XYZ 62.69291 - 675.0236 + 699.0236 0 ] /Rect [ 62.69291 - 545.5936 + 542.7736 114.3629 - 557.5936 ] + 554.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER6': class LinkAnnotation -12 0 obj +11 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 40 0 R /XYZ 62.69291 - 675.0236 + 699.0236 0 ] /Rect [ 527.0227 - 545.5936 + 542.7736 532.5827 - 557.5936 ] + 554.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER7': class LinkAnnotation -13 0 obj +12 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 40 0 R /XYZ 62.69291 - 432.0236 + 462.0236 0 ] /Rect [ 62.69291 - 527.5936 + 524.7736 183.2629 - 539.5936 ] + 536.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER8': class LinkAnnotation -14 0 obj +13 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 40 0 R /XYZ 62.69291 - 432.0236 + 462.0236 0 ] /Rect [ 527.0227 - 527.5936 + 524.7736 532.5827 - 539.5936 ] + 536.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER9': class LinkAnnotation -15 0 obj +14 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 43 0 R + /Dest [ 42 0 R /XYZ 62.69291 - 427.4236 + 451.4236 0 ] /Rect [ 62.69291 - 509.5936 + 506.7736 122.1429 - 521.5936 ] + 518.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER10': class LinkAnnotation -16 0 obj +15 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 43 0 R + /Dest [ 42 0 R /XYZ 62.69291 - 427.4236 + 451.4236 0 ] /Rect [ 527.0227 - 509.5936 + 506.7736 532.5827 - 521.5936 ] + 518.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER11': class LinkAnnotation -17 0 obj +16 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 44 0 R + /Dest [ 43 0 R /XYZ 62.69291 - 435.4236 + 459.4236 0 ] /Rect [ 62.69291 - 491.5936 + 488.7736 154.8129 - 503.5936 ] + 500.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER12': class LinkAnnotation -18 0 obj +17 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 44 0 R + /Dest [ 43 0 R /XYZ 62.69291 - 435.4236 + 459.4236 0 ] /Rect [ 527.0227 - 491.5936 + 488.7736 532.5827 - 503.5936 ] + 500.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER13': class LinkAnnotation -19 0 obj +18 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 45 0 R + /Dest [ 44 0 R /XYZ 62.69291 - 398.778 + 463.978 0 ] /Rect [ 62.69291 - 473.5936 + 470.7736 188.2729 - 485.5936 ] + 482.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER14': class LinkAnnotation -20 0 obj +19 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 45 0 R + /Dest [ 44 0 R /XYZ 62.69291 - 398.778 + 463.978 0 ] /Rect [ 527.0227 - 473.5936 + 470.7736 532.5827 - 485.5936 ] + 482.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER15': class LinkAnnotation -21 0 obj +20 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 46 0 R + /Dest [ 45 0 R /XYZ 62.69291 - 647.8236 + 729.0236 0 ] /Rect [ 62.69291 - 455.5936 + 452.7736 110.6929 - 467.5936 ] + 464.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER16': class LinkAnnotation -22 0 obj +21 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 46 0 R + /Dest [ 45 0 R /XYZ 62.69291 - 647.8236 + 729.0236 0 ] /Rect [ 527.0227 - 455.5936 + 452.7736 532.5827 - 467.5936 ] + 464.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER17': class LinkAnnotation -23 0 obj +22 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 47 0 R + /Dest [ 45 0 R /XYZ 62.69291 - 765.0236 + 195.6236 0 ] /Rect [ 62.69291 - 437.5936 + 434.7736 92.69291 - 449.5936 ] + 446.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER18': class LinkAnnotation -24 0 obj +23 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 47 0 R + /Dest [ 45 0 R /XYZ 62.69291 - 765.0236 + 195.6236 0 ] /Rect [ 527.0227 - 437.5936 + 434.7736 532.5827 - 449.5936 ] + 446.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER19': class LinkAnnotation -25 0 obj +24 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 48 0 R + /Dest [ 47 0 R /XYZ 62.69291 - 243.4236 + 366.6236 0 ] /Rect [ 62.69291 - 419.5936 + 416.7736 192.2729 - 431.5936 ] + 428.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER20': class LinkAnnotation -26 0 obj +25 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 48 0 R + /Dest [ 47 0 R /XYZ 62.69291 - 243.4236 + 366.6236 0 ] /Rect [ 527.0227 - 419.5936 + 416.7736 532.5827 - 431.5936 ] + 428.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER21': class LinkAnnotation -27 0 obj +26 0 obj << /Border [ 0 0 0 ] @@ -419,17 +409,17 @@ endobj /Dest [ 49 0 R /XYZ 62.69291 - 240.6236 + 387.8236 0 ] /Rect [ 62.69291 - 401.5936 + 398.7736 177.1629 - 413.5936 ] + 410.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER22': class LinkAnnotation -28 0 obj +27 0 obj << /Border [ 0 0 0 ] @@ -437,164 +427,165 @@ endobj /Dest [ 49 0 R /XYZ 62.69291 - 240.6236 + 387.8236 0 ] /Rect [ 527.0227 - 401.5936 + 398.7736 532.5827 - 413.5936 ] + 410.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER23': class LinkAnnotation -29 0 obj +28 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 52 0 R + /Dest [ 51 0 R /XYZ 62.69291 - 461.4236 + 623.8236 0 ] /Rect [ 62.69291 - 383.5936 + 380.7736 228.2829 - 395.5936 ] + 392.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER24': class LinkAnnotation -30 0 obj +29 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 52 0 R + /Dest [ 51 0 R /XYZ 62.69291 - 461.4236 + 623.8236 0 ] /Rect [ 521.4627 - 383.5936 + 380.7736 532.5827 - 395.5936 ] + 392.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER25': class LinkAnnotation -31 0 obj +30 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 54 0 R + /Dest [ 52 0 R /XYZ 62.69291 - 765.0236 + 239.0236 0 ] /Rect [ 62.69291 - 365.5936 + 362.7736 174.3929 - 377.5936 ] + 374.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER26': class LinkAnnotation -32 0 obj +31 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 54 0 R + /Dest [ 52 0 R /XYZ 62.69291 - 765.0236 + 239.0236 0 ] /Rect [ 521.4627 - 365.5936 + 362.7736 532.5827 - 377.5936 ] + 374.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER27': class LinkAnnotation -33 0 obj +32 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 62 0 R + /Dest [ 61 0 R /XYZ 62.69291 - 607.8236 + 765.0236 0 ] /Rect [ 62.69291 - 347.5936 + 344.7736 155.4829 - 359.5936 ] + 356.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER28': class LinkAnnotation -34 0 obj +33 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 62 0 R + /Dest [ 61 0 R /XYZ 62.69291 - 607.8236 + 765.0236 0 ] /Rect [ 521.4627 - 347.5936 + 344.7736 532.5827 - 359.5936 ] + 356.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER29': class LinkAnnotation -35 0 obj +34 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 62 0 R + /Dest [ 61 0 R /XYZ 62.69291 - 232.8236 + 390.0236 0 ] /Rect [ 62.69291 - 329.5936 + 326.7736 106.5829 - 341.5936 ] + 338.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER30': class LinkAnnotation -36 0 obj +35 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 62 0 R + /Dest [ 61 0 R /XYZ 62.69291 - 232.8236 + 390.0236 0 ] /Rect [ 521.4627 - 329.5936 + 326.7736 532.5827 - 341.5936 ] + 338.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Page1': class PDFPage -37 0 obj +36 0 obj % Page dictionary -<< /Annots [ 6 0 R - 7 0 R +<< /Annots [ 5 0 R + 6 0 R + 8 0 R 9 0 R 10 0 R 11 0 R @@ -621,14 +612,13 @@ endobj 32 0 R 33 0 R 34 0 R - 35 0 R - 36 0 R ] - /Contents 82 0 R + 35 0 R ] + /Contents 81 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -639,17 +629,17 @@ endobj /Trans << >> /Type /Page >> endobj -% 'F6': class PDFType1Font -38 0 obj +% 'F5': class PDFType1Font +37 0 obj % Font Helvetica-Oblique << /BaseFont /Helvetica-Oblique /Encoding /WinAnsiEncoding - /Name /F6 + /Name /F5 /Subtype /Type1 /Type /Font >> endobj % 'Annot.NUMBER31': class PDFDictionary -39 0 obj +38 0 obj << /A << /S /URI /Type /Action /URI (http://www.python.org/moin/PythonDecoratorLibrary) >> @@ -657,23 +647,14 @@ endobj 0 0 ] /Rect [ 219.6428 - 360.5936 + 387.7736 449.1728 - 372.5936 ] + 399.7736 ] /Subtype /Link /Type /Annot >> endobj -% 'F7': class PDFType1Font -40 0 obj -% Font Courier-Oblique -<< /BaseFont /Courier-Oblique - /Encoding /WinAnsiEncoding - /Name /F7 - /Subtype /Type1 - /Type /Font >> -endobj % 'Annot.NUMBER32': class PDFDictionary -41 0 obj +39 0 obj << /A << /S /URI /Type /Action /URI (http://www.python.org/doc/2.5.2/lib/module-functools.html) >> @@ -681,23 +662,23 @@ endobj 0 0 ] /Rect [ 151.0486 - 127.3936 + 154.5736 270.69 - 139.3936 ] + 166.5736 ] /Subtype /Link /Type /Annot >> endobj % 'Page2': class PDFPage -42 0 obj +40 0 obj % Page dictionary -<< /Annots [ 39 0 R - 41 0 R ] - /Contents 83 0 R +<< /Annots [ 38 0 R + 39 0 R ] + /Contents 82 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -708,15 +689,24 @@ endobj /Trans << >> /Type /Page >> endobj +% 'F6': class PDFType1Font +41 0 obj +% Font Courier-Oblique +<< /BaseFont /Courier-Oblique + /Encoding /WinAnsiEncoding + /Name /F6 + /Subtype /Type1 + /Type /Font >> +endobj % 'Page3': class PDFPage -43 0 obj +42 0 obj % Page dictionary -<< /Contents 84 0 R +<< /Contents 83 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -728,14 +718,14 @@ endobj /Type /Page >> endobj % 'Page4': class PDFPage -44 0 obj +43 0 obj % Page dictionary -<< /Contents 85 0 R +<< /Contents 84 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -747,14 +737,14 @@ endobj /Type /Page >> endobj % 'Page5': class PDFPage -45 0 obj +44 0 obj % Page dictionary -<< /Contents 86 0 R +<< /Contents 85 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -766,14 +756,14 @@ endobj /Type /Page >> endobj % 'Page6': class PDFPage -46 0 obj +45 0 obj % Page dictionary -<< /Contents 87 0 R +<< /Contents 86 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -785,14 +775,14 @@ endobj /Type /Page >> endobj % 'Page7': class PDFPage -47 0 obj +46 0 obj % Page dictionary -<< /Contents 88 0 R +<< /Contents 87 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -804,14 +794,14 @@ endobj /Type /Page >> endobj % 'Page8': class PDFPage -48 0 obj +47 0 obj % Page dictionary -<< /Contents 89 0 R +<< /Contents 88 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -822,15 +812,31 @@ endobj /Trans << >> /Type /Page >> endobj +% 'Annot.NUMBER33': class PDFDictionary +48 0 obj +<< /A << /S /URI + /Type /Action + /URI (http://bugs.python.org/issue1764286) >> + /Border [ 0 + 0 + 0 ] + /Rect [ 137.6966 + 95.17362 + 180.8679 + 107.1736 ] + /Subtype /Link + /Type /Annot >> +endobj % 'Page9': class PDFPage 49 0 obj % Page dictionary -<< /Contents 90 0 R +<< /Annots [ 48 0 R ] + /Contents 89 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -841,23 +847,8 @@ endobj /Trans << >> /Type /Page >> endobj -% 'Annot.NUMBER33': class PDFDictionary -50 0 obj -<< /A << /S /URI - /Type /Action - /URI (http://bugs.python.org/issue1764286) >> - /Border [ 0 - 0 - 0 ] - /Rect [ 137.6966 - 618.1936 - 180.8679 - 630.1936 ] - /Subtype /Link - /Type /Annot >> -endobj % 'Annot.NUMBER34': class PDFDictionary -51 0 obj +50 0 obj << /A << /S /URI /Type /Action /URI (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) >> @@ -865,23 +856,22 @@ endobj 0 0 ] /Rect [ 62.69291 - 144.7936 + 304.3736 363.4029 - 156.7936 ] + 316.3736 ] /Subtype /Link /Type /Annot >> endobj % 'Page10': class PDFPage -52 0 obj +51 0 obj % Page dictionary -<< /Annots [ 50 0 R - 51 0 R ] - /Contents 91 0 R +<< /Annots [ 50 0 R ] + /Contents 90 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -893,14 +883,14 @@ endobj /Type /Page >> endobj % 'Page11': class PDFPage -53 0 obj +52 0 obj % Page dictionary -<< /Contents 92 0 R +<< /Contents 91 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -911,15 +901,31 @@ endobj /Trans << >> /Type /Page >> endobj +% 'Annot.NUMBER35': class PDFDictionary +53 0 obj +<< /A << /S /URI + /Type /Action + /URI (http://www.python.org/dev/peps/pep-0362) >> + /Border [ 0 + 0 + 0 ] + /Rect [ 301.1597 + 140.9736 + 317.8397 + 152.9736 ] + /Subtype /Link + /Type /Annot >> +endobj % 'Page12': class PDFPage 54 0 obj % Page dictionary -<< /Contents 93 0 R +<< /Annots [ 53 0 R ] + /Contents 92 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -930,31 +936,15 @@ endobj /Trans << >> /Type /Page >> endobj -% 'Annot.NUMBER35': class PDFDictionary -55 0 obj -<< /A << /S /URI - /Type /Action - /URI (http://www.python.org/dev/peps/pep-0362) >> - /Border [ 0 - 0 - 0 ] - /Rect [ 301.1597 - 666.5936 - 317.8397 - 678.5936 ] - /Subtype /Link - /Type /Annot >> -endobj % 'Page13': class PDFPage -56 0 obj +55 0 obj % Page dictionary -<< /Annots [ 55 0 R ] - /Contents 94 0 R +<< /Contents 93 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -966,7 +956,7 @@ endobj /Type /Page >> endobj % 'Annot.NUMBER36': class PDFDictionary -57 0 obj +56 0 obj << /A << /S /URI /Type /Action /URI (http://packages.python.org/distribute/) >> @@ -974,14 +964,14 @@ endobj 0 0 ] /Rect [ 286.1685 - 548.3936 + 702.7736 329.8913 - 560.3936 ] + 714.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER37': class PDFDictionary -58 0 obj +57 0 obj << /A << /S /URI /Type /Action /URI (http://docutils.sourceforge.net/) >> @@ -989,14 +979,14 @@ endobj 0 0 ] /Rect [ 188.8729 - 524.3936 + 678.7736 225.5529 - 536.3936 ] + 690.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER38': class PDFDictionary -59 0 obj +58 0 obj << /A << /S /URI /Type /Action /URI (http://pygments.org/) >> @@ -1004,14 +994,14 @@ endobj 0 0 ] /Rect [ 245.0129 - 524.3936 + 678.7736 291.1429 - 536.3936 ] + 690.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER39': class PDFDictionary -60 0 obj +59 0 obj << /A << /S /URI /Type /Action /URI (http://www.python.org/dev/peps/pep-3107/) >> @@ -1019,14 +1009,14 @@ endobj 0 0 ] /Rect [ 62.69291 - 392.3936 + 546.7736 157.3009 - 404.3936 ] + 558.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER40': class PDFDictionary -61 0 obj +60 0 obj << /A << /S /URI /Type /Action /URI (http://www.phyast.pitt.edu/~micheles/python/documentation.html#class-decorators-and-decorator-factories) >> @@ -1034,26 +1024,26 @@ endobj 0 0 ] /Rect [ 364.2921 - 362.3936 + 516.7736 531.64 - 374.3936 ] + 528.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Page14': class PDFPage -62 0 obj +61 0 obj % Page dictionary -<< /Annots [ 57 0 R +<< /Annots [ 56 0 R + 57 0 R 58 0 R 59 0 R - 60 0 R - 61 0 R ] - /Contents 95 0 R + 60 0 R ] + /Contents 94 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -1065,14 +1055,14 @@ endobj /Type /Page >> endobj % 'Page15': class PDFPage -63 0 obj +62 0 obj % Page dictionary -<< /Contents 96 0 R +<< /Contents 95 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 81 0 R + /Parent 80 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -1083,246 +1073,247 @@ endobj /Trans << >> /Type /Page >> endobj -% 'R64': class PDFCatalog -64 0 obj +% 'R63': class PDFCatalog +63 0 obj % Document Root -<< /Outlines 66 0 R - /PageLabels 97 0 R +<< /Outlines 65 0 R + /PageLabels 96 0 R /PageMode /UseNone - /Pages 81 0 R + /Pages 80 0 R /Type /Catalog >> endobj -% 'R65': class PDFInfo -65 0 obj +% 'R64': class PDFInfo +64 0 obj << /Author (Michele Simionato) - /CreationDate (D:20100525055108-01'00') + /CreationDate (D:20101128103357-01'00') + /Creator (\(unspecified\)) /Keywords () - /Producer (ReportLab http://www.reportlab.com) + /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (\(unspecified\)) /Title (The decorator module) >> endobj -% 'R66': class PDFOutlines -66 0 obj +% 'R65': class PDFOutlines +65 0 obj << /Count 14 - /First 67 0 R - /Last 80 0 R + /First 66 0 R + /Last 79 0 R /Type /Outlines >> endobj % 'Outline.0': class OutlineEntryObject -67 0 obj -<< /Dest [ 37 0 R +66 0 obj +<< /Dest [ 36 0 R /XYZ 62.69291 311.0236 0 ] - /Next 68 0 R - /Parent 66 0 R + /Next 67 0 R + /Parent 65 0 R /Title (Introduction) >> endobj % 'Outline.1': class OutlineEntryObject +67 0 obj +<< /Dest [ 40 0 R + /XYZ + 62.69291 + 699.0236 + 0 ] + /Next 68 0 R + /Parent 65 0 R + /Prev 66 0 R + /Title (Definitions) >> +endobj +% 'Outline.2': class OutlineEntryObject 68 0 obj -<< /Dest [ 42 0 R +<< /Dest [ 40 0 R /XYZ 62.69291 - 675.0236 + 462.0236 0 ] /Next 69 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 67 0 R - /Title (Definitions) >> + /Title (Statement of the problem) >> endobj -% 'Outline.2': class OutlineEntryObject +% 'Outline.3': class OutlineEntryObject 69 0 obj << /Dest [ 42 0 R /XYZ 62.69291 - 432.0236 + 451.4236 0 ] /Next 70 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 68 0 R - /Title (Statement of the problem) >> + /Title (The solution) >> endobj -% 'Outline.3': class OutlineEntryObject +% 'Outline.4': class OutlineEntryObject 70 0 obj << /Dest [ 43 0 R /XYZ 62.69291 - 427.4236 + 459.4236 0 ] /Next 71 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 69 0 R - /Title (The solution) >> + /Title (A trace decorator) >> endobj -% 'Outline.4': class OutlineEntryObject +% 'Outline.5': class OutlineEntryObject 71 0 obj << /Dest [ 44 0 R /XYZ 62.69291 - 435.4236 + 463.978 0 ] /Next 72 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 70 0 R - /Title (A trace decorator) >> + /Title (decorator is a decorator) >> endobj -% 'Outline.5': class OutlineEntryObject +% 'Outline.6': class OutlineEntryObject 72 0 obj << /Dest [ 45 0 R /XYZ 62.69291 - 398.778 + 729.0236 0 ] /Next 73 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 71 0 R - /Title (decorator is a decorator) >> + /Title (blocking) >> endobj -% 'Outline.6': class OutlineEntryObject +% 'Outline.7': class OutlineEntryObject 73 0 obj -<< /Dest [ 46 0 R +<< /Dest [ 45 0 R /XYZ 62.69291 - 647.8236 + 195.6236 0 ] /Next 74 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 72 0 R - /Title (blocking) >> + /Title (async) >> endobj -% 'Outline.7': class OutlineEntryObject +% 'Outline.8': class OutlineEntryObject 74 0 obj << /Dest [ 47 0 R /XYZ 62.69291 - 765.0236 + 366.6236 0 ] /Next 75 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 73 0 R - /Title (async) >> + /Title (The FunctionMaker class) >> endobj -% 'Outline.8': class OutlineEntryObject +% 'Outline.9': class OutlineEntryObject 75 0 obj -<< /Dest [ 48 0 R +<< /Dest [ 49 0 R /XYZ 62.69291 - 243.4236 + 387.8236 0 ] /Next 76 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 74 0 R - /Title (The FunctionMaker class) >> + /Title (Getting the source code) >> endobj -% 'Outline.9': class OutlineEntryObject +% 'Outline.10': class OutlineEntryObject 76 0 obj -<< /Dest [ 49 0 R +<< /Dest [ 51 0 R /XYZ 62.69291 - 240.6236 + 623.8236 0 ] /Next 77 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 75 0 R - /Title (Getting the source code) >> + /Title (Dealing with third party decorators) >> endobj -% 'Outline.10': class OutlineEntryObject +% 'Outline.11': class OutlineEntryObject 77 0 obj << /Dest [ 52 0 R /XYZ 62.69291 - 461.4236 + 239.0236 0 ] /Next 78 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 76 0 R - /Title (Dealing with third party decorators) >> + /Title (Caveats and limitations) >> endobj -% 'Outline.11': class OutlineEntryObject +% 'Outline.12': class OutlineEntryObject 78 0 obj -<< /Dest [ 54 0 R +<< /Dest [ 61 0 R /XYZ 62.69291 765.0236 0 ] /Next 79 0 R - /Parent 66 0 R + /Parent 65 0 R /Prev 77 0 R - /Title (Caveats and limitations) >> -endobj -% 'Outline.12': class OutlineEntryObject -79 0 obj -<< /Dest [ 62 0 R - /XYZ - 62.69291 - 607.8236 - 0 ] - /Next 80 0 R - /Parent 66 0 R - /Prev 78 0 R /Title (Compatibility notes) >> endobj % 'Outline.13': class OutlineEntryObject -80 0 obj -<< /Dest [ 62 0 R +79 0 obj +<< /Dest [ 61 0 R /XYZ 62.69291 - 232.8236 + 390.0236 0 ] - /Parent 66 0 R - /Prev 79 0 R + /Parent 65 0 R + /Prev 78 0 R /Title (LICENCE) >> endobj -% 'R81': class PDFPages -81 0 obj +% 'R80': class PDFPages +80 0 obj % page tree << /Count 15 - /Kids [ 37 0 R + /Kids [ 36 0 R + 40 0 R 42 0 R 43 0 R 44 0 R 45 0 R 46 0 R 47 0 R - 48 0 R 49 0 R + 51 0 R 52 0 R - 53 0 R 54 0 R - 56 0 R - 62 0 R - 63 0 R ] + 55 0 R + 61 0 R + 62 0 R ] /Type /Pages >> endobj -% 'R82': class PDFStream -82 0 obj +% 'R81': class PDFStream +81 0 obj % page stream -<< /Length 9103 >> +<< /Length 9160 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q 1 0 0 1 62.69291 741.0236 cm q -BT 1 0 0 1 0 9.64 Tm 118.8249 0 Td 24 TL /F2 20 Tf 0 0 0 rg (The ) Tj /F3 20 Tf (decorator ) Tj /F2 20 Tf (module) Tj T* -118.8249 0 Td ET +BT 1 0 0 1 0 4 Tm 118.8249 0 Td 24 TL /F2 20 Tf 0 0 0 rg (The ) Tj /F3 20 Tf (decorator ) Tj /F2 20 Tf (module) Tj T* -118.8249 0 Td ET Q Q q 1 0 0 1 62.69291 716.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 36.93937 0 Td (Author:) Tj T* -36.93937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 36.93937 0 Td (Author:) Tj T* -36.93937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Michele Simionato) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Michele Simionato) Tj T* ET Q Q q @@ -1331,20 +1322,18 @@ Q q 1 0 0 1 62.69291 701.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 39.69937 0 Td (E-mail:) Tj T* -39.69937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 39.69937 0 Td (E-mail:) Tj T* -39.69937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q -0 0 .501961 rg -0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (michele.simionato@gmail.com) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 .501961 rg (michele.simionato@gmail.com) Tj T* ET Q Q q @@ -1353,19 +1342,19 @@ Q q 1 0 0 1 62.69291 686.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 33.02937 0 Td (Version:) Tj T* -33.02937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 33.02937 0 Td (Version:) Tj T* -33.02937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (3.2.0 \(2010-05-25\)) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (3.2.1 \(2010-11-28\)) Tj T* ET Q Q q @@ -1374,19 +1363,19 @@ Q q 1 0 0 1 62.69291 671.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 26.91937 0 Td (Requires:) Tj T* -26.91937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 26.91937 0 Td (Requires:) Tj T* -26.91937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Python 2.4+) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Python 2.4+) Tj T* ET Q Q q @@ -1395,12 +1384,12 @@ Q q 1 0 0 1 62.69291 644.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F2 10 Tf 12 TL 25.25937 0 Td (Download) Tj T* 21.11 0 Td (page:) Tj T* -46.36937 0 Td ET +BT 1 0 0 1 0 14 Tm /F2 10 Tf 12 TL 25.25937 0 Td (Download) Tj T* 21.11 0 Td (page:) Tj T* -46.36937 0 Td ET Q Q q @@ -1408,7 +1397,7 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (http://pypi.python.org/pypi/decorator/3.2.0) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (http://pypi.python.org/pypi/decorator/3.2.1) Tj T* ET Q Q q @@ -1417,19 +1406,19 @@ Q q 1 0 0 1 62.69291 629.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 16.91937 0 Td (Installation:) Tj T* -16.91937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 16.91937 0 Td (Installation:) Tj T* -16.91937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 5.71 Tm /F5 10 Tf 12 TL (easy_install decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm /F4 10 Tf 12 TL (easy_install decorator) Tj T* ET Q Q q @@ -1438,19 +1427,19 @@ Q q 1 0 0 1 62.69291 614.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 32.46937 0 Td (License:) Tj T* -32.46937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 32.46937 0 Td (License:) Tj T* -32.46937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (BSD license) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (BSD license) Tj T* ET Q Q q @@ -1459,17 +1448,17 @@ Q q 1 0 0 1 62.69291 581.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Contents) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Contents) Tj T* ET Q Q q 1 0 0 1 62.69291 323.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 0 237 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Introduction) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Introduction) Tj T* ET Q Q q @@ -1477,13 +1466,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (1) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (1) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 219 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Definitions) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Definitions) Tj T* ET Q Q q @@ -1491,13 +1480,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 201 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Statement of the problem) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Statement of the problem) Tj T* ET Q Q q @@ -1505,13 +1494,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 183 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The solution) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The solution) Tj T* ET Q Q q @@ -1519,13 +1508,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (3) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (3) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 165 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (A ) Tj /F3 10 Tf (trace ) Tj /F2 10 Tf (decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (A ) Tj /F3 10 Tf (trace ) Tj /F2 10 Tf (decorator) Tj T* ET Q Q q @@ -1533,13 +1522,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (4) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (4) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 147 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (decorator ) Tj /F2 10 Tf (is a decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (decorator ) Tj /F2 10 Tf (is a decorator) Tj T* ET Q Q q @@ -1547,13 +1536,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (5) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (5) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 129 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (blocking) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (blocking) Tj T* ET Q Q q @@ -1561,13 +1550,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (6) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (6) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 111 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (async) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (async) Tj T* ET Q Q q @@ -1575,13 +1564,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (7) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (6) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 93 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The ) Tj /F3 10 Tf (FunctionMaker ) Tj /F2 10 Tf (class) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The ) Tj /F3 10 Tf (FunctionMaker ) Tj /F2 10 Tf (class) Tj T* ET Q Q q @@ -1589,13 +1578,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (8) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (8) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 75 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Getting the source code) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Getting the source code) Tj T* ET Q Q q @@ -1603,13 +1592,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (9) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (9) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 57 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Dealing with third party decorators) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Dealing with third party decorators) Tj T* ET Q Q q @@ -1617,13 +1606,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (10) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (10) Tj T* -60.88 0 Td ET Q Q q 1 0 0 1 0 39 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Caveats and limitations) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Caveats and limitations) Tj T* ET Q Q q @@ -1631,13 +1620,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (12) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (11) Tj T* -60.88 0 Td ET Q Q q 1 0 0 1 0 21 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Compatibility notes) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Compatibility notes) Tj T* ET Q Q q @@ -1645,13 +1634,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (14) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (14) Tj T* -60.88 0 Td ET Q Q q 1 0 0 1 0 3 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (LICENCE) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (LICENCE) Tj T* ET Q Q q @@ -1659,7 +1648,7 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (14) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (14) Tj T* -60.88 0 Td ET Q Q q @@ -1668,14 +1657,14 @@ Q q 1 0 0 1 62.69291 290.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Introduction) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Introduction) Tj T* ET Q Q q 1 0 0 1 62.69291 224.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 52.82 Tm /F1 10 Tf 12 TL 3.995366 Tw (Python decorators are an interesting example of why syntactic sugar matters. In principle, their) Tj T* 0 Tw .151235 Tw (introduction in Python 2.4 changed nothing, since they do not provide any new functionality which was not) Tj T* 0 Tw 2.238555 Tw (already present in the language. In practice, their introduction has significantly changed the way we) Tj T* 0 Tw .098409 Tw (structure our programs in Python. I believe the change is for the best, and that decorators are a great idea) Tj T* 0 Tw (since:) Tj T* ET +BT 1 0 0 1 0 50 Tm /F1 10 Tf 12 TL 3.995366 Tw (Python decorators are an interesting example of why syntactic sugar matters. In principle, their) Tj T* 0 Tw .151235 Tw (introduction in Python 2.4 changed nothing, since they do not provide any new functionality which was not) Tj T* 0 Tw 2.238555 Tw (already present in the language. In practice, their introduction has significantly changed the way we) Tj T* 0 Tw .098409 Tw (structure our programs in Python. I believe the change is for the best, and that decorators are a great idea) Tj T* 0 Tw (since:) Tj T* ET Q Q q @@ -1685,21 +1674,21 @@ q 1 0 0 1 62.69291 218.0236 cm Q q -1 0 0 1 62.69291 200.0236 cm +1 0 0 1 62.69291 206.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators help reducing boilerplate code;) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators help reducing boilerplate code;) Tj T* ET Q Q q @@ -1709,24 +1698,21 @@ q 1 0 0 1 62.69291 200.0236 cm Q q -1 0 0 1 62.69291 200.0236 cm -Q -q -1 0 0 1 62.69291 182.0236 cm +1 0 0 1 62.69291 188.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators help separation of concerns;) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators help separation of concerns;) Tj T* ET Q Q q @@ -1736,24 +1722,21 @@ q 1 0 0 1 62.69291 182.0236 cm Q q -1 0 0 1 62.69291 182.0236 cm -Q -q -1 0 0 1 62.69291 164.0236 cm +1 0 0 1 62.69291 170.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators enhance readability and maintenability;) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators enhance readability and maintenability;) Tj T* ET Q Q q @@ -1763,169 +1746,162 @@ q 1 0 0 1 62.69291 164.0236 cm Q q -1 0 0 1 62.69291 164.0236 cm -Q -q -1 0 0 1 62.69291 146.0236 cm +1 0 0 1 62.69291 152.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators are explicit.) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators are explicit.) Tj T* ET Q Q q Q Q q -1 0 0 1 62.69291 146.0236 cm +1 0 0 1 62.69291 152.0236 cm Q q -1 0 0 1 62.69291 146.0236 cm +1 0 0 1 62.69291 110.0236 cm +q +0 0 0 rg +BT 1 0 0 1 0 26 Tm /F1 10 Tf 12 TL .848876 Tw (Still, as of now, writing custom decorators correctly requires some experience and it is not as easy as it) Tj T* 0 Tw 1.049269 Tw (could be. For instance, typical implementations of decorators involve nested functions, and we all know) Tj T* 0 Tw (that flat is better than nested.) Tj T* ET +Q Q q -1 0 0 1 62.69291 104.0236 cm +1 0 0 1 62.69291 80.02362 cm q -0 0 0 rg -BT 1 0 0 1 0 28.82 Tm /F1 10 Tf 12 TL .848876 Tw (Still, as of now, writing custom decorators correctly requires some experience and it is not as easy as it) Tj T* 0 Tw 1.049269 Tw (could be. For instance, typical implementations of decorators involve nested functions, and we all know) Tj T* 0 Tw (that flat is better than nested.) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.093735 Tw 12 TL /F1 10 Tf 0 0 0 rg (The aim of the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module it to simplify the usage of decorators for the average programmer, ) Tj T* 0 Tw 2.456136 Tw (and to popularize decorators by showing various non-trivial examples. Of course, as all techniques,) Tj T* 0 Tw ET Q Q endstream - endobj -% 'R83': class PDFStream -83 0 obj +% 'R82': class PDFStream +82 0 obj % page stream -<< /Length 7636 >> +<< /Length 6156 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 717.0236 cm +1 0 0 1 62.69291 741.0236 cm q -BT 1 0 0 1 0 40.82 Tm 1.093735 Tw 12 TL /F1 10 Tf 0 0 0 rg (The aim of the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module it to simplify the usage of decorators for the average programmer,) Tj T* 0 Tw 2.456136 Tw (and to popularize decorators by showing various non-trivial examples. Of course, as all techniques,) Tj T* 0 Tw 2.234987 Tw (decorators can be abused \(I have seen that\) and you should not try to solve every problem with a) Tj T* 0 Tw (decorator, just because you can.) Tj T* ET +BT 1 0 0 1 0 14 Tm 2.234987 Tw 12 TL /F1 10 Tf 0 0 0 rg (decorators can be abused \(I have seen that\) and you should not try to solve every problem with a) Tj T* 0 Tw (decorator, just because you can.) Tj T* ET Q Q q -1 0 0 1 62.69291 687.0236 cm +1 0 0 1 62.69291 711.0236 cm q -BT 1 0 0 1 0 16.82 Tm .13561 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may find the source code for all the examples discussed here in the ) Tj /F5 10 Tf (documentation.py ) Tj /F1 10 Tf (file, which) Tj T* 0 Tw (contains this documentation in the form of doctests.) Tj T* ET +BT 1 0 0 1 0 14 Tm .13561 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may find the source code for all the examples discussed here in the ) Tj /F4 10 Tf (documentation.py ) Tj /F1 10 Tf (file, which) Tj T* 0 Tw (contains this documentation in the form of doctests.) Tj T* ET Q Q q -1 0 0 1 62.69291 654.0236 cm +1 0 0 1 62.69291 678.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Definitions) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Definitions) Tj T* ET Q Q q -1 0 0 1 62.69291 612.0236 cm +1 0 0 1 62.69291 636.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 28.82 Tm /F1 10 Tf 12 TL 2.37561 Tw (Technically speaking, any Python object which can be called with one argument can be used as a) Tj T* 0 Tw .472339 Tw (decorator. However, this definition is somewhat too large to be really useful. It is more convenient to split) Tj T* 0 Tw (the generic class of decorators in two subclasses:) Tj T* ET +BT 1 0 0 1 0 26 Tm /F1 10 Tf 12 TL 2.37561 Tw (Technically speaking, any Python object which can be called with one argument can be used as a) Tj T* 0 Tw .472339 Tw (decorator. However, this definition is somewhat too large to be really useful. It is more convenient to split) Tj T* 0 Tw (the generic class of decorators in two subclasses:) Tj T* ET Q Q q -1 0 0 1 62.69291 606.0236 cm +1 0 0 1 62.69291 630.0236 cm Q q -1 0 0 1 62.69291 606.0236 cm +1 0 0 1 62.69291 630.0236 cm Q q -1 0 0 1 62.69291 576.0236 cm +1 0 0 1 62.69291 606.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 15 cm +1 0 0 1 6 9 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q -BT 1 0 0 1 0 16.82 Tm 2.68748 Tw 12 TL /F6 10 Tf 0 0 0 rg (signature-preserving ) Tj /F1 10 Tf (decorators, i.e. callable objects taking a function as input and returning a) Tj T* 0 Tw (function ) Tj /F6 10 Tf (with the same signature ) Tj /F1 10 Tf (as output;) Tj T* ET +BT 1 0 0 1 0 14 Tm 2.68748 Tw 12 TL /F5 10 Tf 0 0 0 rg (signature-preserving ) Tj /F1 10 Tf (decorators, i.e. callable objects taking a function as input and returning a) Tj T* 0 Tw (function ) Tj /F5 10 Tf (with the same signature ) Tj /F1 10 Tf (as output;) Tj T* ET Q Q q Q Q q -1 0 0 1 62.69291 576.0236 cm +1 0 0 1 62.69291 600.0236 cm Q q 1 0 0 1 62.69291 576.0236 cm -Q -q -1 0 0 1 62.69291 546.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 15 cm +1 0 0 1 6 9 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q -BT 1 0 0 1 0 16.82 Tm 1.43498 Tw 12 TL /F6 10 Tf 0 0 0 rg (signature-changing ) Tj /F1 10 Tf (decorators, i.e. decorators that change the signature of their input function, or) Tj T* 0 Tw (decorators returning non-callable objects.) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.43498 Tw 12 TL /F5 10 Tf 0 0 0 rg (signature-changing ) Tj /F1 10 Tf (decorators, i.e. decorators that change the signature of their input function, or) Tj T* 0 Tw (decorators returning non-callable objects.) Tj T* ET Q Q q Q Q q -1 0 0 1 62.69291 546.0236 cm -Q -q -1 0 0 1 62.69291 546.0236 cm +1 0 0 1 62.69291 576.0236 cm Q q -1 0 0 1 62.69291 504.0236 cm +1 0 0 1 62.69291 534.0236 cm q -BT 1 0 0 1 0 28.82 Tm 2.832706 Tw 12 TL /F1 10 Tf 0 0 0 rg (Signature-changing decorators have their use: for instance the builtin classes ) Tj /F5 10 Tf (staticmethod ) Tj /F1 10 Tf (and) Tj T* 0 Tw 1.506651 Tw /F5 10 Tf (classmethod ) Tj /F1 10 Tf (are in this group, since they take functions and return descriptor objects which are not) Tj T* 0 Tw (functions, nor callables.) Tj T* ET +BT 1 0 0 1 0 26 Tm 2.832706 Tw 12 TL /F1 10 Tf 0 0 0 rg (Signature-changing decorators have their use: for instance the builtin classes ) Tj /F4 10 Tf (staticmethod ) Tj /F1 10 Tf (and) Tj T* 0 Tw 1.506651 Tw /F4 10 Tf (classmethod ) Tj /F1 10 Tf (are in this group, since they take functions and return descriptor objects which are not) Tj T* 0 Tw (functions, nor callables.) Tj T* ET Q Q q -1 0 0 1 62.69291 474.0236 cm +1 0 0 1 62.69291 504.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL 1.735814 Tw (However, signature-preserving decorators are more common and easier to reason about; in particular) Tj T* 0 Tw (signature-preserving decorators can be composed together whereas other decorators in general cannot.) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL 1.735814 Tw (However, signature-preserving decorators are more common and easier to reason about; in particular) Tj T* 0 Tw (signature-preserving decorators can be composed together whereas other decorators in general cannot.) Tj T* ET Q Q q -1 0 0 1 62.69291 444.0236 cm +1 0 0 1 62.69291 474.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .494983 Tw (Writing signature-preserving decorators from scratch is not that obvious, especially if one wants to define) Tj T* 0 Tw (proper decorators that can accept functions with any signature. A simple example will clarify the issue.) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .494983 Tw (Writing signature-preserving decorators from scratch is not that obvious, especially if one wants to define) Tj T* 0 Tw (proper decorators that can accept functions with any signature. A simple example will clarify the issue.) Tj T* ET Q Q q -1 0 0 1 62.69291 411.0236 cm +1 0 0 1 62.69291 441.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Statement of the problem) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Statement of the problem) Tj T* ET Q Q q -1 0 0 1 62.69291 333.0236 cm +1 0 0 1 62.69291 363.0236 cm q -BT 1 0 0 1 0 64.82 Tm .351235 Tw 12 TL /F1 10 Tf 0 0 0 rg (A very common use case for decorators is the memoization of functions. A ) Tj /F5 10 Tf (memoize ) Tj /F1 10 Tf (decorator works by) Tj T* 0 Tw .871988 Tw (caching the result of the function call in a dictionary, so that the next time the function is called with the) Tj T* 0 Tw 2.350651 Tw (same input parameters the result is retrieved from the cache and not recomputed. There are many) Tj T* 0 Tw 2.92247 Tw (implementations of ) Tj /F5 10 Tf (memoize ) Tj /F1 10 Tf (in ) Tj 0 0 .501961 rg (http://www.python.org/moin/PythonDecoratorLibrary) Tj 0 0 0 rg (, but they do not) Tj T* 0 Tw 2.683984 Tw (preserve the signature. A simple implementation could be the following \(notice that in general it is) Tj T* 0 Tw (impossible to memoize correctly something that depends on non-hashable arguments\):) Tj T* ET +BT 1 0 0 1 0 62 Tm .351235 Tw 12 TL /F1 10 Tf 0 0 0 rg (A very common use case for decorators is the memoization of functions. A ) Tj /F4 10 Tf (memoize ) Tj /F1 10 Tf (decorator works by) Tj T* 0 Tw .871988 Tw (caching the result of the function call in a dictionary, so that the next time the function is called with the) Tj T* 0 Tw 2.350651 Tw (same input parameters the result is retrieved from the cache and not recomputed. There are many) Tj T* 0 Tw 2.92247 Tw (implementations of ) Tj /F4 10 Tf (memoize ) Tj /F1 10 Tf (in ) Tj 0 0 .501961 rg (http://www.python.org/moin/PythonDecoratorLibrary) Tj 0 0 0 rg (, but they do not) Tj T* 0 Tw 2.683984 Tw (preserve the signature. A simple implementation could be the following \(notice that in general it is) Tj T* 0 Tw (impossible to memoize correctly something that depends on non-hashable arguments\):) Tj T* ET Q Q q -1 0 0 1 62.69291 143.8236 cm +1 0 0 1 62.69291 173.8236 cm q q 1 0 0 1 0 0 cm @@ -1938,43 +1914,49 @@ q n -6 -6 468.6898 180 re B* Q q -BT 1 0 0 1 0 161.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize_uw) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ({}) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (kw) Tj (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# frozenset is used to ensure hashability) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (frozenset) Tj (\() Tj (kw) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (iteritems) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj T* ( ) Tj (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (key) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (functools) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (update_wrapper) Tj (\() Tj (memoize) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 158 Tm /F4 10 Tf 12 TL (def memoize_uw\(func\):) Tj T* ( func.cache = {}) Tj T* ( def memoize\(*args, **kw\):) Tj T* ( if kw: # frozenset is used to ensure hashability) Tj T* ( key = args, frozenset\(kw.iteritems\(\)\)) Tj T* ( else:) Tj T* ( key = args) Tj T* ( cache = func.cache) Tj T* ( if key in cache:) Tj T* ( return cache[key]) Tj T* ( else:) Tj T* ( cache[key] = result = func\(*args, **kw\)) Tj T* ( return result) Tj T* ( return functools.update_wrapper\(memoize, func\)) Tj T* ET Q Q Q Q Q q +1 0 0 1 62.69291 117.8236 cm +q +BT 1 0 0 1 0 38 Tm 1.801412 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here we used the ) Tj 0 0 .501961 rg (functools.update_wrapper ) Tj 0 0 0 rg (utility, which has been added in Python 2.5 expressly to) Tj T* 0 Tw .91686 Tw (simplify the definition of decorators \(in older versions of Python you need to copy the function attributes) Tj T* 0 Tw .580814 Tw /F4 10 Tf (__name__) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (__doc__) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (__module__ ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (__dict__ ) Tj /F1 10 Tf (from the original function to the decorated function) Tj T* 0 Tw (by hand\).) Tj T* ET +Q +Q +q 1 0 0 1 62.69291 87.82362 cm q -BT 1 0 0 1 0 40.82 Tm 1.801412 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here we used the ) Tj 0 0 .501961 rg (functools.update_wrapper ) Tj 0 0 0 rg (utility, which has been added in Python 2.5 expressly to) Tj T* 0 Tw .91686 Tw (simplify the definition of decorators \(in older versions of Python you need to copy the function attributes) Tj T* 0 Tw .580814 Tw /F5 10 Tf (__name__) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (__doc__) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (__module__ ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (__dict__ ) Tj /F1 10 Tf (from the original function to the decorated function) Tj T* 0 Tw (by hand\).) Tj T* ET +BT 1 0 0 1 0 14 Tm 2.517126 Tw 12 TL /F1 10 Tf 0 0 0 rg (The implementation above works in the sense that the decorator can accept functions with generic ) Tj T* 0 Tw 1.233615 Tw (signatures; unfortunately this implementation does ) Tj /F5 10 Tf (not ) Tj /F1 10 Tf (define a signature-preserving decorator, since in) Tj T* 0 Tw ET Q Q endstream - endobj -% 'R84': class PDFStream -84 0 obj +% 'R83': class PDFStream +83 0 obj % page stream -<< /Length 8051 >> +<< /Length 6791 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 729.0236 cm +1 0 0 1 62.69291 753.0236 cm q -BT 1 0 0 1 0 28.82 Tm 2.517126 Tw 12 TL /F1 10 Tf 0 0 0 rg (The implementation above works in the sense that the decorator can accept functions with generic) Tj T* 0 Tw 1.233615 Tw (signatures; unfortunately this implementation does ) Tj /F6 10 Tf (not ) Tj /F1 10 Tf (define a signature-preserving decorator, since in) Tj T* 0 Tw (general ) Tj /F5 10 Tf (memoize_uw ) Tj /F1 10 Tf (returns a function with a ) Tj /F6 10 Tf (different signature ) Tj /F1 10 Tf (from the original function.) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (general ) Tj /F4 10 Tf (memoize_uw ) Tj /F1 10 Tf (returns a function with a ) Tj /F5 10 Tf (different signature ) Tj /F1 10 Tf (from the original function.) Tj T* ET Q Q q -1 0 0 1 62.69291 711.0236 cm +1 0 0 1 62.69291 735.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Consider for instance the following case:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Consider for instance the following case:) Tj T* ET Q Q q -1 0 0 1 62.69291 641.8236 cm +1 0 0 1 62.69291 665.8236 cm q q 1 0 0 1 0 0 cm @@ -1987,20 +1969,20 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize_uw) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# simulate some long computation) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (x) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize_uw) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# simulate some long computation) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (x) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 609.8236 cm +1 0 0 1 62.69291 633.8236 cm q -BT 1 0 0 1 0 16.82 Tm .26311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here the original function takes a single argument named ) Tj /F5 10 Tf (x) Tj /F1 10 Tf (, but the decorated function takes any number) Tj T* 0 Tw (of arguments and keyword arguments:) Tj T* ET +BT 1 0 0 1 0 14 Tm .26311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here the original function takes a single argument named ) Tj /F4 10 Tf (x) Tj /F1 10 Tf (, but the decorated function takes any number) Tj T* 0 Tw (of arguments and keyword arguments:) Tj T* ET Q Q q -1 0 0 1 62.69291 552.6236 cm +1 0 0 1 62.69291 576.6236 cm q q 1 0 0 1 0 0 cm @@ -2013,20 +1995,20 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (inspect) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (f1) Tj (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# I am using Python 2.6+ here) Tj /F5 10 Tf 0 0 0 rg T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (inspect) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (f1) Tj (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# I am using Python 2.6+ here) Tj /F4 10 Tf 0 0 0 rg T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 508.6236 cm +1 0 0 1 62.69291 532.6236 cm q -BT 1 0 0 1 0 28.82 Tm .411235 Tw 12 TL /F1 10 Tf 0 0 0 rg (This means that introspection tools such as pydoc will give wrong informations about the signature of ) Tj /F5 10 Tf (f1) Tj /F1 10 Tf (.) Tj T* 0 Tw .161654 Tw (This is pretty bad: pydoc will tell you that the function accepts a generic signature ) Tj /F5 10 Tf (*args) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (**kw) Tj /F1 10 Tf (, but when) Tj T* 0 Tw (you try to call the function with more than an argument, you will get an error:) Tj T* ET +BT 1 0 0 1 0 26 Tm .411235 Tw 12 TL /F1 10 Tf 0 0 0 rg (This means that introspection tools such as pydoc will give wrong informations about the signature of ) Tj /F4 10 Tf (f1) Tj /F1 10 Tf (.) Tj T* 0 Tw .161654 Tw (This is pretty bad: pydoc will tell you that the function accepts a generic signature ) Tj /F4 10 Tf (*args) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (**kw) Tj /F1 10 Tf (, but when) Tj T* 0 Tw (you try to call the function with more than an argument, you will get an error:) Tj T* ET Q Q q -1 0 0 1 62.69291 439.4236 cm +1 0 0 1 62.69291 463.4236 cm q q 1 0 0 1 0 0 cm @@ -2039,26 +2021,26 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (TypeError) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj (f1) Tj (\(\)) Tj ( ) Tj (takes) Tj ( ) Tj (exactly) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg ( ) Tj (argument) Tj ( ) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg ( ) Tj (given) Tj (\)) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (TypeError) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj (f1) Tj (\(\)) Tj ( ) Tj (takes) Tj ( ) Tj (exactly) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg ( ) Tj (argument) Tj ( ) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg ( ) Tj (given) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 406.4236 cm +1 0 0 1 62.69291 430.4236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The solution) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The solution) Tj T* ET Q Q q -1 0 0 1 62.69291 364.4236 cm +1 0 0 1 62.69291 388.4236 cm q -BT 1 0 0 1 0 28.82 Tm 3.313984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The solution is to provide a generic factory of generators, which hides the complexity of making) Tj T* 0 Tw 3.362976 Tw (signature-preserving decorators from the application programmer. The ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (function in the) Tj T* 0 Tw /F5 10 Tf (decorator ) Tj /F1 10 Tf (module is such a factory:) Tj T* ET +BT 1 0 0 1 0 26 Tm 3.313984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The solution is to provide a generic factory of generators, which hides the complexity of making) Tj T* 0 Tw 3.362976 Tw (signature-preserving decorators from the application programmer. The ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (function in the) Tj T* 0 Tw /F4 10 Tf (decorator ) Tj /F1 10 Tf (module is such a factory:) Tj T* ET Q Q q -1 0 0 1 62.69291 331.2236 cm +1 0 0 1 62.69291 355.2236 cm q q 1 0 0 1 0 0 cm @@ -2071,20 +2053,20 @@ q n -6 -6 468.6898 24 re B* Q q -BT 1 0 0 1 0 5.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (decorator) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (decorator) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 275.2236 cm +1 0 0 1 62.69291 299.2236 cm q -BT 1 0 0 1 0 40.82 Tm 1.716412 Tw 12 TL /F5 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf (takes two arguments, a caller function describing the functionality of the decorator and a) Tj T* 0 Tw .821984 Tw (function to be decorated; it returns the decorated function. The caller function must have signature ) Tj /F5 10 Tf (\(f,) Tj T* 0 Tw .65061 Tw (*args, **kw\) ) Tj /F1 10 Tf (and it must call the original function ) Tj /F5 10 Tf (f ) Tj /F1 10 Tf (with arguments ) Tj /F5 10 Tf (args ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (kw) Tj /F1 10 Tf (, implementing the) Tj T* 0 Tw (wanted capability, i.e. memoization in this case:) Tj T* ET +BT 1 0 0 1 0 38 Tm 1.716412 Tw 12 TL /F4 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf (takes two arguments, a caller function describing the functionality of the decorator and a) Tj T* 0 Tw .821984 Tw (function to be decorated; it returns the decorated function. The caller function must have signature ) Tj /F4 10 Tf (\(f,) Tj T* 0 Tw .65061 Tw (*args, **kw\) ) Tj /F1 10 Tf (and it must call the original function ) Tj /F4 10 Tf (f ) Tj /F1 10 Tf (with arguments ) Tj /F4 10 Tf (args ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (kw) Tj /F1 10 Tf (, implementing the) Tj T* 0 Tw (wanted capability, i.e. memoization in this case:) Tj T* ET Q Q q -1 0 0 1 62.69291 122.0236 cm +1 0 0 1 62.69291 146.0236 cm q q 1 0 0 1 0 0 cm @@ -2097,31 +2079,52 @@ q n -6 -6 468.6898 144 re B* Q q -BT 1 0 0 1 0 125.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (_memoize) Tj 0 0 0 rg (\() Tj (func) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (kw) Tj (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# frozenset is used to ensure hashability) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (frozenset) Tj (\() Tj (kw) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (iteritems) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj T* ( ) Tj (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# attributed added by memoize) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (key) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 122 Tm /F4 10 Tf 12 TL (def _memoize\(func, *args, **kw\):) Tj T* ( if kw: # frozenset is used to ensure hashability) Tj T* ( key = args, frozenset\(kw.iteritems\(\)\)) Tj T* ( else:) Tj T* ( key = args) Tj T* ( cache = func.cache # attributed added by memoize) Tj T* ( if key in cache:) Tj T* ( return cache[key]) Tj T* ( else:) Tj T* ( cache[key] = result = func\(*args, **kw\)) Tj T* ( return result) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 102.0236 cm +1 0 0 1 62.69291 126.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (At this point you can define your decorator as follows:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (At this point you can define your decorator as follows:) Tj T* ET +Q +Q +q +1 0 0 1 62.69291 80.82362 cm +q +q +1 0 0 1 0 0 cm +q +1 0 0 1 6.6 6.6 cm +q +.662745 .662745 .662745 RG +.5 w +.960784 .960784 .862745 rg +n -6 -6 468.6898 36 re B* +Q +q +0 0 0 rg +BT 1 0 0 1 0 14 Tm /F4 10 Tf 12 TL (def memoize\(f\):) Tj T* ( f.cache = {}) Tj T* ET +Q +Q +Q Q Q endstream - endobj -% 'R85': class PDFStream -85 0 obj +% 'R84': class PDFStream +84 0 obj % page stream -<< /Length 7158 >> +<< /Length 6759 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 715.8236 cm +1 0 0 1 62.69291 739.8236 cm q q 1 0 0 1 0 0 cm @@ -2131,30 +2134,31 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 48 re B* +n -6 -6 468.6898 24 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize) Tj 0 0 0 rg (\() Tj (f) Tj (\):) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ({}) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (_memoize) Tj (,) Tj ( ) Tj (f) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 2 Tm /F4 10 Tf 12 TL ( return decorator\(_memoize, f\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 671.8236 cm +1 0 0 1 62.69291 695.8236 cm q -BT 1 0 0 1 0 28.82 Tm .12561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The difference with respect to the ) Tj /F5 10 Tf (memoize_uw ) Tj /F1 10 Tf (approach, which is based on nested functions, is that the) Tj T* 0 Tw 2.59528 Tw (decorator module forces you to lift the inner function at the outer level \() Tj /F6 10 Tf (flat is better than nested) Tj /F1 10 Tf (\).) Tj T* 0 Tw (Moreover, you are forced to pass explicitly the function you want to decorate to the caller function.) Tj T* ET +BT 1 0 0 1 0 26 Tm .12561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The difference with respect to the ) Tj /F4 10 Tf (memoize_uw ) Tj /F1 10 Tf (approach, which is based on nested functions, is that the) Tj T* 0 Tw 2.59528 Tw (decorator module forces you to lift the inner function at the outer level \() Tj /F5 10 Tf (flat is better than nested) Tj /F1 10 Tf (\).) Tj T* 0 Tw (Moreover, you are forced to pass explicitly the function you want to decorate to the caller function.) Tj T* ET Q Q q -1 0 0 1 62.69291 653.8236 cm +1 0 0 1 62.69291 677.8236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is a test of usage:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is a test of usage:) Tj T* ET Q Q q -1 0 0 1 62.69291 512.6236 cm +1 0 0 1 62.69291 536.6236 cm q q 1 0 0 1 0 0 cm @@ -2167,20 +2171,20 @@ q n -6 -6 468.6898 132 re B* Q q -BT 1 0 0 1 0 113.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (heavy_computation) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("done") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (heavy_computation) Tj (\(\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the first time it will take 2 seconds) Tj /F5 10 Tf 0 0 0 rg T* (done) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (heavy_computation) Tj (\(\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the second time it will be instantaneous) Tj /F5 10 Tf 0 0 0 rg T* (done) Tj T* ET +BT 1 0 0 1 0 110 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (heavy_computation) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("done") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (heavy_computation) Tj (\(\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the first time it will take 2 seconds) Tj /F4 10 Tf 0 0 0 rg T* (done) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (heavy_computation) Tj (\(\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the second time it will be instantaneous) Tj /F4 10 Tf 0 0 0 rg T* (done) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 492.6236 cm +1 0 0 1 62.69291 516.6236 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F1 10 Tf 0 0 0 rg (The signature of ) Tj /F5 10 Tf (heavy_computation ) Tj /F1 10 Tf (is the one you would expect:) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (The signature of ) Tj /F4 10 Tf (heavy_computation ) Tj /F1 10 Tf (is the one you would expect:) Tj T* ET Q Q q -1 0 0 1 62.69291 447.4236 cm +1 0 0 1 62.69291 471.4236 cm q q 1 0 0 1 0 0 cm @@ -2193,26 +2197,26 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (heavy_computation) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (heavy_computation) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 414.4236 cm +1 0 0 1 62.69291 438.4236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (A ) Tj /F3 17.5 Tf (trace ) Tj /F2 17.5 Tf (decorator) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (A ) Tj /F3 17.5 Tf (trace ) Tj /F2 17.5 Tf (decorator) Tj T* ET Q Q q -1 0 0 1 62.69291 384.4236 cm +1 0 0 1 62.69291 408.4236 cm q -BT 1 0 0 1 0 16.82 Tm .479398 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an additional example, here is how you can define a trivial ) Tj /F5 10 Tf (trace ) Tj /F1 10 Tf (decorator, which prints a message) Tj T* 0 Tw (everytime the traced function is called:) Tj T* ET +BT 1 0 0 1 0 14 Tm .479398 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an additional example, here is how you can define a trivial ) Tj /F4 10 Tf (trace ) Tj /F1 10 Tf (decorator, which prints a message) Tj T* 0 Tw (everytime the traced function is called:) Tj T* ET Q Q q -1 0 0 1 62.69291 327.2236 cm +1 0 0 1 62.69291 351.2236 cm q q 1 0 0 1 0 0 cm @@ -2225,14 +2229,15 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (_trace) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("calling ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg ( with args ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (, ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (") Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 26 Tm /F4 10 Tf 12 TL (def _trace\(f, *args, **kw\):) Tj T* ( print "calling %s with args %s, %s" % \(f.__name__, args, kw\)) Tj T* ( return f\(*args, **kw\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 282.0236 cm +1 0 0 1 62.69291 306.0236 cm q q 1 0 0 1 0 0 cm @@ -2245,21 +2250,22 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (trace) Tj 0 0 0 rg (\() Tj (f) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (_trace) Tj (,) Tj ( ) Tj (f) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 14 Tm /F4 10 Tf 12 TL (def trace\(f\):) Tj T* ( return decorator\(_trace, f\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 262.0236 cm +1 0 0 1 62.69291 286.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET Q Q q -1 0 0 1 62.69291 204.8236 cm +1 0 0 1 62.69291 228.8236 cm q q 1 0 0 1 0 0 cm @@ -2272,20 +2278,20 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 184.8236 cm +1 0 0 1 62.69291 208.8236 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F1 10 Tf 0 0 0 rg (It is immediate to verify that ) Tj /F5 10 Tf (f1 ) Tj /F1 10 Tf (works) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (It is immediate to verify that ) Tj /F4 10 Tf (f1 ) Tj /F1 10 Tf (works) Tj T* ET Q Q q -1 0 0 1 62.69291 139.6236 cm +1 0 0 1 62.69291 163.6236 cm q q 1 0 0 1 0 0 cm @@ -2298,31 +2304,21 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f1) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,\),) Tj ( ) Tj ({}) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f1) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,\),) Tj ( ) Tj ({}) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 119.6236 cm +1 0 0 1 62.69291 143.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (and it that it has the correct signature:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (and it that it has the correct signature:) Tj T* ET Q Q - -endstream - -endobj -% 'R86': class PDFStream -86 0 obj -% page stream -<< /Length 8829 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 727.8236 cm +1 0 0 1 62.69291 98.42362 cm q q 1 0 0 1 0 0 cm @@ -2335,21 +2331,30 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (f1) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (f1) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 707.8236 cm +1 0 0 1 62.69291 78.42362 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (The same decorator works with functions of any signature:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (The same decorator works with functions of any signature:) Tj T* ET Q Q + +endstream +endobj +% 'R85': class PDFStream +85 0 obj +% page stream +<< /Length 8633 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 579.978 cm +1 0 0 1 62.69291 645.178 cm q q .988825 0 0 .988825 0 0 cm @@ -2362,21 +2367,21 @@ q n -6 -6 474 120 re B* Q q -BT 1 0 0 1 0 101.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (x) Tj (,) Tj ( ) Tj (y) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (z) Tj .4 .4 .4 rg (=) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),) Tj ( ) Tj ({}) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (f) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('y') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('z') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)\)) Tj T* ET +BT 1 0 0 1 0 98 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (x) Tj (,) Tj ( ) Tj (y) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (z) Tj .4 .4 .4 rg (=) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),) Tj ( ) Tj ({}) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (f) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('y') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('z') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 559.978 cm +1 0 0 1 62.69291 625.178 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (That includes even functions with exotic signatures like the following:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (That includes even functions with exotic signatures like the following:) Tj T* ET Q Q q -1 0 0 1 62.69291 442.778 cm +1 0 0 1 62.69291 507.978 cm q q 1 0 0 1 0 0 cm @@ -2389,33 +2394,33 @@ q n -6 -6 468.6898 108 re B* Q q -BT 1 0 0 1 0 89.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (exotic_signature) Tj 0 0 0 rg (\(\() Tj (x) Tj (,) Tj ( ) Tj (y) Tj (\)) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (x) Tj .4 .4 .4 rg (+) Tj 0 0 0 rg (y) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (exotic_signature) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([[) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('y') Tj 0 0 0 rg (]],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\(\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),\)\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (exotic_signature) Tj (\(\)) Tj T* (calling) Tj ( ) Tj (exotic_signature) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\(\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),\),) Tj ( ) Tj ({}) Tj T* .4 .4 .4 rg (3) Tj T* ET +BT 1 0 0 1 0 86 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (exotic_signature) Tj 0 0 0 rg (\(\() Tj (x) Tj (,) Tj ( ) Tj (y) Tj (\)) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (x) Tj .4 .4 .4 rg (+) Tj 0 0 0 rg (y) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj (\() Tj (exotic_signature) Tj (\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([[) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('y') Tj 0 0 0 rg (]],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\(\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),\)\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (exotic_signature) Tj (\(\)) Tj T* (calling) Tj ( ) Tj (exotic_signature) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\(\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),\),) Tj ( ) Tj ({}) Tj T* .4 .4 .4 rg (3) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 410.778 cm +1 0 0 1 62.69291 475.978 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .84561 Tw (Notice that the support for exotic signatures has been deprecated in Python 2.6 and removed in Python) Tj T* 0 Tw (3.0.) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .84561 Tw (Notice that the support for exotic signatures has been deprecated in Python 2.6 and removed in Python) Tj T* 0 Tw (3.0.) Tj T* ET Q Q q -1 0 0 1 62.69291 377.778 cm +1 0 0 1 62.69291 442.978 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (decorator ) Tj /F2 17.5 Tf (is a decorator) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (decorator ) Tj /F2 17.5 Tf (is a decorator) Tj T* ET Q Q q -1 0 0 1 62.69291 275.778 cm +1 0 0 1 62.69291 340.978 cm q -BT 1 0 0 1 0 88.82 Tm .643876 Tw 12 TL /F1 10 Tf 0 0 0 rg (It may be annoying to write a caller function \(like the ) Tj /F5 10 Tf (_trace ) Tj /F1 10 Tf (function above\) and then a trivial wrapper) Tj T* 0 Tw 1.803615 Tw (\() Tj /F5 10 Tf (def trace\(f\): return decorator\(_trace, f\)) Tj /F1 10 Tf (\) every time. For this reason, the ) Tj /F5 10 Tf (decorator) Tj T* 0 Tw .334269 Tw /F1 10 Tf (module provides an easy shortcut to convert the caller function into a signature-preserving decorator: you) Tj T* 0 Tw 3.443735 Tw (can just call ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (with a single argument. In our example you can just write ) Tj /F5 10 Tf (trace =) Tj T* 0 Tw 1.056342 Tw (decorator\(_trace\)) Tj /F1 10 Tf (. The ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (function can also be used as a signature-changing decorator,) Tj T* 0 Tw 3.177752 Tw (just as ) Tj /F5 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (staticmethod) Tj /F1 10 Tf (. However, ) Tj /F5 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (staticmethod ) Tj /F1 10 Tf (return) Tj T* 0 Tw 1.693615 Tw (generic objects which are not callable, while ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (returns signature-preserving decorators, i.e.) Tj T* 0 Tw (functions of a single argument. For instance, you can write directly) Tj T* ET +BT 1 0 0 1 0 86 Tm .643876 Tw 12 TL /F1 10 Tf 0 0 0 rg (It may be annoying to write a caller function \(like the ) Tj /F4 10 Tf (_trace ) Tj /F1 10 Tf (function above\) and then a trivial wrapper) Tj T* 0 Tw 1.803615 Tw (\() Tj /F4 10 Tf (def trace\(f\): return decorator\(_trace, f\)) Tj /F1 10 Tf (\) every time. For this reason, the ) Tj /F4 10 Tf (decorator) Tj T* 0 Tw .334269 Tw /F1 10 Tf (module provides an easy shortcut to convert the caller function into a signature-preserving decorator: you) Tj T* 0 Tw 3.443735 Tw (can just call ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (with a single argument. In our example you can just write ) Tj /F4 10 Tf (trace =) Tj T* 0 Tw 1.056342 Tw (decorator\(_trace\)) Tj /F1 10 Tf (. The ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (function can also be used as a signature-changing decorator,) Tj T* 0 Tw 3.177752 Tw (just as ) Tj /F4 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (staticmethod) Tj /F1 10 Tf (. However, ) Tj /F4 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (staticmethod ) Tj /F1 10 Tf (return) Tj T* 0 Tw 1.693615 Tw (generic objects which are not callable, while ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (returns signature-preserving decorators, i.e.) Tj T* 0 Tw (functions of a single argument. For instance, you can write directly) Tj T* ET Q Q q -1 0 0 1 62.69291 206.578 cm +1 0 0 1 62.69291 271.778 cm q q 1 0 0 1 0 0 cm @@ -2428,20 +2433,20 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@decorator) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (trace) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("calling ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg ( with args ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (, ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (") Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func_name) Tj (,) Tj ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@decorator) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (trace) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("calling ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg ( with args ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (, ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (") Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func_name) Tj (,) Tj ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 174.578 cm +1 0 0 1 62.69291 239.778 cm q -BT 1 0 0 1 0 16.82 Tm 1.806654 Tw 12 TL /F1 10 Tf 0 0 0 rg (and now ) Tj /F5 10 Tf (trace ) Tj /F1 10 Tf (will be a decorator. Actually ) Tj /F5 10 Tf (trace ) Tj /F1 10 Tf (is a ) Tj /F5 10 Tf (partial ) Tj /F1 10 Tf (object which can be used as a) Tj T* 0 Tw (decorator:) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.806654 Tw 12 TL /F1 10 Tf 0 0 0 rg (and now ) Tj /F4 10 Tf (trace ) Tj /F1 10 Tf (will be a decorator. Actually ) Tj /F4 10 Tf (trace ) Tj /F1 10 Tf (is a ) Tj /F4 10 Tf (partial ) Tj /F1 10 Tf (object which can be used as a) Tj T* 0 Tw (decorator:) Tj T* ET Q Q q -1 0 0 1 62.69291 129.378 cm +1 0 0 1 62.69291 194.578 cm q q 1 0 0 1 0 0 cm @@ -2454,31 +2459,21 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (function) Tj ( ) Tj (trace) Tj ( ) Tj (at) Tj ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (x) Tj .4 .4 .4 rg (...) Tj (>) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (function) Tj ( ) Tj (trace) Tj ( ) Tj (at) Tj ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (x) Tj .4 .4 .4 rg (...) Tj (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 109.378 cm +1 0 0 1 62.69291 174.578 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET Q Q - -endstream - -endobj -% 'R87': class PDFStream -87 0 obj -% page stream -<< /Length 7175 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 691.8236 cm +1 0 0 1 62.69291 93.378 cm q q 1 0 0 1 0 0 cm @@ -2491,32 +2486,41 @@ q n -6 -6 468.6898 72 re B* Q q -BT 1 0 0 1 0 53.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (func) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (func) Tj (\(\)) Tj T* (calling) Tj ( ) Tj (func) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\(\),) Tj ( ) Tj ({}) Tj T* ET +BT 1 0 0 1 0 50 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (func) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (func) Tj (\(\)) Tj T* (calling) Tj ( ) Tj (func) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\(\),) Tj ( ) Tj ({}) Tj T* ET Q Q Q Q Q + +endstream +endobj +% 'R86': class PDFStream +86 0 obj +% page stream +<< /Length 5826 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 659.8236 cm +1 0 0 1 62.69291 741.0236 cm q -BT 1 0 0 1 0 16.82 Tm 2.44686 Tw 12 TL /F1 10 Tf 0 0 0 rg (If you are using an old Python version \(Python 2.4\) the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module provides a poor man) Tj T* 0 Tw (replacement for ) Tj /F5 10 Tf (functools.partial) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 14 Tm 2.44686 Tw 12 TL /F1 10 Tf 0 0 0 rg (If you are using an old Python version \(Python 2.4\) the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module provides a poor man) Tj T* 0 Tw (replacement for ) Tj /F4 10 Tf (functools.partial) Tj /F1 10 Tf (.) Tj T* ET Q Q q -1 0 0 1 62.69291 626.8236 cm +1 0 0 1 62.69291 708.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (blocking) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (blocking) Tj T* ET Q Q q -1 0 0 1 62.69291 584.8236 cm +1 0 0 1 62.69291 666.0236 cm q -BT 1 0 0 1 0 28.82 Tm 1.224692 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes one has to deal with blocking resources, such as ) Tj /F5 10 Tf (stdin) Tj /F1 10 Tf (, and sometimes it is best to have) Tj T* 0 Tw .266235 Tw (back a "busy" message than to block everything. This behavior can be implemented with a suitable family) Tj T* 0 Tw (of decorators, where the parameter is the busy message:) Tj T* ET +BT 1 0 0 1 0 26 Tm 1.224692 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes one has to deal with blocking resources, such as ) Tj /F4 10 Tf (stdin) Tj /F1 10 Tf (, and sometimes it is best to have) Tj T* 0 Tw .266235 Tw (back a "busy" message than to block everything. This behavior can be implemented with a suitable family) Tj T* 0 Tw (of decorators, where the parameter is the busy message:) Tj T* ET Q Q q -1 0 0 1 62.69291 407.6236 cm +1 0 0 1 62.69291 488.8236 cm q q 1 0 0 1 0 0 cm @@ -2529,20 +2533,21 @@ q n -6 -6 468.6898 168 re B* Q q -BT 1 0 0 1 0 149.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (blocking) Tj 0 0 0 rg (\() Tj (not_avail) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (blocking) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf .666667 .133333 1 rg (not) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (hasattr) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .729412 .129412 .129412 rg ("thread") Tj 0 0 0 rg (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# no thread running) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (set_result) Tj 0 0 0 rg (\(\):) Tj ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Thread) Tj (\() Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (set_result) Tj (\)) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (start) Tj (\(\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (not_avail) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (elif) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (isAlive) Tj (\(\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (not_avail) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the thread is ended, return the stored result) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (del) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (blocking) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 146 Tm /F4 10 Tf 12 TL (def blocking\(not_avail\):) Tj T* ( def blocking\(f, *args, **kw\):) Tj T* ( if not hasattr\(f, "thread"\): # no thread running) Tj T* ( def set_result\(\): f.result = f\(*args, **kw\)) Tj T* ( f.thread = threading.Thread\(None, set_result\)) Tj T* ( f.thread.start\(\)) Tj T* ( return not_avail) Tj T* ( elif f.thread.isAlive\(\):) Tj T* ( return not_avail) Tj T* ( else: # the thread is ended, return the stored result) Tj T* ( del f.thread) Tj T* ( return f.result) Tj T* ( return decorator\(blocking\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 375.6236 cm +1 0 0 1 62.69291 456.8236 cm q -BT 1 0 0 1 0 16.82 Tm 1.010651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Functions decorated with ) Tj /F5 10 Tf (blocking ) Tj /F1 10 Tf (will return a busy message if the resource is unavailable, and the) Tj T* 0 Tw (intended result if the resource is available. For instance:) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.010651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Functions decorated with ) Tj /F4 10 Tf (blocking ) Tj /F1 10 Tf (will return a busy message if the resource is unavailable, and the) Tj T* 0 Tw (intended result if the resource is available. For instance:) Tj T* ET Q Q q -1 0 0 1 62.69291 126.4236 cm +1 0 0 1 62.69291 207.6236 cm q q 1 0 0 1 0 0 cm @@ -2555,62 +2560,47 @@ q n -6 -6 468.6898 240 re B* Q q -BT 1 0 0 1 0 221.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@blocking) Tj 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("Please wait ...") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (read_data) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# simulate a blocking resource) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("some data") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F5 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F5 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F5 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1.1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# after 3.1 seconds, data is available) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj T* (some) Tj ( ) Tj (data) Tj T* ET +BT 1 0 0 1 0 218 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@blocking) Tj 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("Please wait ...") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (read_data) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# simulate a blocking resource) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("some data") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F4 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F4 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F4 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1.1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# after 3.1 seconds, data is available) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (read_data) Tj (\(\)) Tj T* (some) Tj ( ) Tj (data) Tj T* ET Q Q Q Q Q - -endstream - -endobj -% 'R88': class PDFStream -88 0 obj -% page stream -<< /Length 6889 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 744.0236 cm +1 0 0 1 62.69291 174.6236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (async) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (async) Tj T* ET Q Q q -1 0 0 1 62.69291 678.0236 cm -q -BT 1 0 0 1 0 52.82 Tm 1.647485 Tw 12 TL /F1 10 Tf 0 0 0 rg (We have just seen an examples of a simple decorator factory, implemented as a function returning a) Tj T* 0 Tw .29784 Tw (decorator. For more complex situations, it is more convenient to implement decorator factories as classes) Tj T* 0 Tw .657674 Tw (returning callable objects that can be used as signature-preserving decorators. The suggested pattern to) Tj T* 0 Tw 2.109398 Tw (do that is to introduce a helper method ) Tj /F5 10 Tf (call\(self, func, *args, **kw\) ) Tj /F1 10 Tf (and to call it in the) Tj T* 0 Tw /F5 10 Tf (__call__\(self, func\) ) Tj /F1 10 Tf (method.) Tj T* ET -Q -Q -q -1 0 0 1 62.69291 624.0236 cm -q -BT 1 0 0 1 0 40.82 Tm .166654 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an example, here I show a decorator which is able to convert a blocking function into an asynchronous) Tj T* 0 Tw .437633 Tw (function. The function, when called, is executed in a separate thread. Moreover, it is possible to set three) Tj T* 0 Tw .074597 Tw (callbacks ) Tj /F5 10 Tf (on_success) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (on_failure ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (on_closing) Tj /F1 10 Tf (, to specify how to manage the function call. The) Tj T* 0 Tw (implementation is the following:) Tj T* ET -Q -Q -q -1 0 0 1 62.69291 566.8236 cm -q -q -1 0 0 1 0 0 cm -q -1 0 0 1 6.6 6.6 cm -q -.662745 .662745 .662745 RG -.5 w -.960784 .960784 .862745 rg -n -6 -6 468.6898 48 re B* -Q +1 0 0 1 62.69291 108.6236 cm q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_success) Tj 0 0 0 rg (\() Tj (result) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called on the result of the function") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.647485 Tw 12 TL /F1 10 Tf 0 0 0 rg (We have just seen an examples of a simple decorator factory, implemented as a function returning a) Tj T* 0 Tw .29784 Tw (decorator. For more complex situations, it is more convenient to implement decorator factories as classes) Tj T* 0 Tw .657674 Tw (returning callable objects that can be used as signature-preserving decorators. The suggested pattern to) Tj T* 0 Tw 2.109398 Tw (do that is to introduce a helper method ) Tj /F4 10 Tf (call\(self, func, *args, **kw\) ) Tj /F1 10 Tf (and to call it in the) Tj T* 0 Tw /F4 10 Tf (__call__\(self, func\) ) Tj /F1 10 Tf (method.) Tj T* ET Q Q +q +1 0 0 1 62.69291 78.62362 cm +q +BT 1 0 0 1 0 14 Tm .166654 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an example, here I show a decorator which is able to convert a blocking function into an asynchronous ) Tj T* 0 Tw .437633 Tw (function. The function, when called, is executed in a separate thread. Moreover, it is possible to set three) Tj T* 0 Tw ET Q Q + +endstream +endobj +% 'R87': class PDFStream +87 0 obj +% page stream +<< /Length 3574 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +q +1 0 0 1 62.69291 741.0236 cm +q +BT 1 0 0 1 0 14 Tm .074597 Tw 12 TL /F1 10 Tf 0 0 0 rg (callbacks ) Tj /F4 10 Tf (on_success) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (on_failure ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (on_closing) Tj /F1 10 Tf (, to specify how to manage the function call. The) Tj T* 0 Tw (implementation is the following:) Tj T* ET +Q Q q -1 0 0 1 62.69291 509.6236 cm +1 0 0 1 62.69291 683.8236 cm q q 1 0 0 1 0 0 cm @@ -2623,14 +2613,15 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_failure) Tj 0 0 0 rg (\() Tj (exc_info) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called if the function fails") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 26 Tm /F4 10 Tf 12 TL (def on_success\(result\): # default implementation) Tj T* ( "Called on the result of the function") Tj T* ( return result) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 452.4236 cm +1 0 0 1 62.69291 626.6236 cm q q 1 0 0 1 0 0 cm @@ -2643,14 +2634,15 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_closing) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called at the end, both in case of success and failure") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 26 Tm /F4 10 Tf 12 TL (def on_failure\(exc_info\): # default implementation) Tj T* ( "Called if the function fails") Tj T* ( pass) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 83.22362 cm +1 0 0 1 62.69291 569.4236 cm q q 1 0 0 1 0 0 cm @@ -2660,27 +2652,18 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 360 re B* +n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 341.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (class) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (Async) Tj /F5 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* ( ) Tj /F7 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( A decorator converting blocking functions into asynchronous) Tj T* ( functions, by using threads or processes. Examples:) Tj T* T* ( async_with_threads = Async\(threading.Thread\)) Tj T* ( async_with_processes = Async\(multiprocessing.Process\)) Tj T* ( """) Tj /F5 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__init__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (threadfactory) Tj (\):) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (threadfactory) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (threadfactory) Tj T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__call__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (,) Tj ( ) Tj (on_success) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_success) Tj (,) Tj T* ( ) Tj (on_failure) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_failure) Tj (,) Tj ( ) Tj (on_closing) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_closing) Tj (\):) Tj T* ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# every decorated function has its own independent thread counter) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (counter) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (itertools) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (count) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_success) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_success) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_failure) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_failure) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_closing) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_closing) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (call) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (call) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (func_wrapper) Tj 0 0 0 rg (\(\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (try) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (except) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_failure) Tj (\() Tj (sys) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (exc_info) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_success) Tj (\() Tj (result) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 26 Tm /F4 10 Tf 12 TL (def on_closing\(\): # default implementation) Tj T* ( "Called at the end, both in case of success and failure") Tj T* ( pass) Tj T* ET Q Q Q Q Q - -endstream - -endobj -% 'R89': class PDFStream -89 0 obj -% page stream -<< /Length 7268 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 679.8236 cm +1 0 0 1 62.69291 128.2236 cm q q 1 0 0 1 0 0 cm @@ -2690,30 +2673,40 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 84 re B* +n -6 -6 468.6898 432 re B* Q q -BT 1 0 0 1 0 65.71 Tm 12 TL /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (finally) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_closing) Tj (\(\)) Tj T* ( ) Tj (name) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (') Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (-) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (') Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (counter) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (next) Tj (\(\)\)) Tj T* ( ) Tj (thread) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (threadfactory) Tj (\() Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (func_wrapper) Tj (,) Tj ( ) Tj (name) Tj (\)) Tj T* ( ) Tj (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (start) Tj (\(\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (thread) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 410 Tm /F4 10 Tf 12 TL (class Async\(object\):) Tj T* ( """) Tj T* ( A decorator converting blocking functions into asynchronous) Tj T* ( functions, by using threads or processes. Examples:) Tj T* T* ( async_with_threads = Async\(threading.Thread\)) Tj T* ( async_with_processes = Async\(multiprocessing.Process\)) Tj T* ( """) Tj T* T* ( def __init__\(self, threadfactory\):) Tj T* ( self.threadfactory = threadfactory) Tj T* T* ( def __call__\(self, func, on_success=on_success,) Tj T* ( on_failure=on_failure, on_closing=on_closing\):) Tj T* ( # every decorated function has its own independent thread counter) Tj T* ( func.counter = itertools.count\(1\)) Tj T* ( func.on_success = on_success) Tj T* ( func.on_failure = on_failure) Tj T* ( func.on_closing = on_closing) Tj T* ( return decorator\(self.call, func\)) Tj T* T* ( def call\(self, func, *args, **kw\):) Tj T* ( def func_wrapper\(\):) Tj T* ( try:) Tj T* ( result = func\(*args, **kw\)) Tj T* ( except:) Tj T* ( func.on_failure\(sys.exc_info\(\)\)) Tj T* ( else:) Tj T* ( return func.on_success\(result\)) Tj T* ( finally:) Tj T* ( func.on_closing\(\)) Tj T* ( name = '%s-%s' % \(func.__name__, func.counter.next\(\)\)) Tj T* ( thread = self.threadfactory\(None, func_wrapper, name\)) Tj T* ( thread.start\(\)) Tj T* ( return thread) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 647.8236 cm +1 0 0 1 62.69291 96.22362 cm q -BT 1 0 0 1 0 16.82 Tm .865984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The decorated function returns the current execution thread, which can be stored and checked later, for) Tj T* 0 Tw (instance to verify that the thread ) Tj /F5 10 Tf (.isAlive\(\)) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 14 Tm .865984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The decorated function returns the current execution thread, which can be stored and checked later, for) Tj T* 0 Tw (instance to verify that the thread ) Tj /F4 10 Tf (.isAlive\(\)) Tj /F1 10 Tf (.) Tj T* ET Q Q + +endstream +endobj +% 'R88': class PDFStream +88 0 obj +% page stream +<< /Length 7588 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 605.8236 cm +1 0 0 1 62.69291 729.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 28.82 Tm /F1 10 Tf 12 TL .691654 Tw (Here is an example of usage. Suppose one wants to write some data to an external resource which can) Tj T* 0 Tw .21683 Tw (be accessed by a single user at once \(for instance a printer\). Then the access to the writing function must) Tj T* 0 Tw (be locked. Here is a minimalistic example:) Tj T* ET +BT 1 0 0 1 0 26 Tm /F1 10 Tf 12 TL .691654 Tw (Here is an example of usage. Suppose one wants to write some data to an external resource which can) Tj T* 0 Tw .21683 Tw (be accessed by a single user at once \(for instance a printer\). Then the access to the writing function must) Tj T* 0 Tw (be locked. Here is a minimalistic example:) Tj T* ET Q Q q -1 0 0 1 62.69291 452.6236 cm +1 0 0 1 62.69291 575.8236 cm q q 1 0 0 1 0 0 cm @@ -2726,20 +2719,20 @@ q n -6 -6 468.6898 144 re B* Q q -BT 1 0 0 1 0 125.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (async) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (Async) Tj (\() Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Thread) Tj (\)) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (datalist) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ([]) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# for simplicity the written data are stored into a list.) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@async) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (write) Tj 0 0 0 rg (\() Tj (data) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# append data to the datalist by locking) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Lock) Tj (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# emulate some long running operation) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (datalist) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (append) Tj (\() Tj (data) Tj (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# other operations not requiring a lock here) Tj T* ET +BT 1 0 0 1 0 122 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (async) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (Async) Tj (\() Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Thread) Tj (\)) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (datalist) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ([]) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# for simplicity the written data are stored into a list.) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@async) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (write) Tj 0 0 0 rg (\() Tj (data) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# append data to the datalist by locking) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Lock) Tj (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# emulate some long running operation) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (datalist) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (append) Tj (\() Tj (data) Tj (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# other operations not requiring a lock here) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 420.6236 cm +1 0 0 1 62.69291 543.8236 cm q -BT 1 0 0 1 0 16.82 Tm .905868 Tw 12 TL /F1 10 Tf 0 0 0 rg (Each call to ) Tj /F5 10 Tf (write ) Tj /F1 10 Tf (will create a new writer thread, but there will be no synchronization problems since) Tj T* 0 Tw /F5 10 Tf (write ) Tj /F1 10 Tf (is locked.) Tj T* ET +BT 1 0 0 1 0 14 Tm .905868 Tw 12 TL /F1 10 Tf 0 0 0 rg (Each call to ) Tj /F4 10 Tf (write ) Tj /F1 10 Tf (will create a new writer thread, but there will be no synchronization problems since) Tj T* 0 Tw /F4 10 Tf (write ) Tj /F1 10 Tf (is locked.) Tj T* ET Q Q q -1 0 0 1 62.69291 255.4236 cm +1 0 0 1 62.69291 378.6236 cm q q 1 0 0 1 0 0 cm @@ -2752,42 +2745,32 @@ q n -6 -6 468.6898 156 re B* Q q -BT 1 0 0 1 0 137.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data1") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (.) Tj (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# wait a bit, so we are sure data2 is written after data1) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data2") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# wait for the writers to complete) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (datalist) Tj T* ([) Tj .729412 .129412 .129412 rg ('data1') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('data2') Tj 0 0 0 rg (]) Tj T* ET +BT 1 0 0 1 0 134 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data1") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (.) Tj (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# wait a bit, so we are sure data2 is written after data1) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data2") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# wait for the writers to complete) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (datalist) Tj T* ([) Tj .729412 .129412 .129412 rg ('data1') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('data2') Tj 0 0 0 rg (]) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 222.4236 cm +1 0 0 1 62.69291 345.6236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The ) Tj /F3 17.5 Tf (FunctionMaker ) Tj /F2 17.5 Tf (class) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The ) Tj /F3 17.5 Tf (FunctionMaker ) Tj /F2 17.5 Tf (class) Tj T* ET Q Q q -1 0 0 1 62.69291 156.4236 cm +1 0 0 1 62.69291 279.6236 cm q -BT 1 0 0 1 0 52.82 Tm 2.241412 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may wonder about how the functionality of the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module is implemented. The basic) Tj T* 0 Tw 1.545868 Tw (building block is a ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class which is able to generate on the fly functions with a given) Tj T* 0 Tw .047485 Tw (name and signature from a function template passed as a string. Generally speaking, you should not need) Tj T* 0 Tw 1.164983 Tw (to resort to ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (when writing ordinary decorators, but it is handy in some circumstances.) Tj T* 0 Tw (You will see an example shortly, in the implementation of a cool decorator utility \() Tj /F5 10 Tf (decorator_apply) Tj /F1 10 Tf (\).) Tj T* ET +BT 1 0 0 1 0 50 Tm 2.241412 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may wonder about how the functionality of the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module is implemented. The basic) Tj T* 0 Tw 1.545868 Tw (building block is a ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class which is able to generate on the fly functions with a given) Tj T* 0 Tw .047485 Tw (name and signature from a function template passed as a string. Generally speaking, you should not need) Tj T* 0 Tw 1.164983 Tw (to resort to ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (when writing ordinary decorators, but it is handy in some circumstances.) Tj T* 0 Tw (You will see an example shortly, in the implementation of a cool decorator utility \() Tj /F4 10 Tf (decorator_apply) Tj /F1 10 Tf (\).) Tj T* ET Q Q q -1 0 0 1 62.69291 114.4236 cm +1 0 0 1 62.69291 237.6236 cm q -BT 1 0 0 1 0 28.82 Tm .414597 Tw 12 TL /F5 10 Tf 0 0 0 rg (FunctionMaker ) Tj /F1 10 Tf (provides a ) Tj /F5 10 Tf (.create ) Tj /F1 10 Tf (classmethod which takes as input the name, signature, and body) Tj T* 0 Tw .632927 Tw (of the function we want to generate as well as the execution environment were the function is generated) Tj T* 0 Tw (by ) Tj /F5 10 Tf (exec) Tj /F1 10 Tf (. Here is an example:) Tj T* ET +BT 1 0 0 1 0 26 Tm .414597 Tw 12 TL /F4 10 Tf 0 0 0 rg (FunctionMaker ) Tj /F1 10 Tf (provides a ) Tj /F4 10 Tf (.create ) Tj /F1 10 Tf (classmethod which takes as input the name, signature, and body) Tj T* 0 Tw .632927 Tw (of the function we want to generate as well as the execution environment were the function is generated) Tj T* 0 Tw (by ) Tj /F4 10 Tf (exec) Tj /F1 10 Tf (. Here is an example:) Tj T* ET Q Q - -endstream - -endobj -% 'R90': class PDFStream -90 0 obj -% page stream -<< /Length 8188 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 679.8236 cm +1 0 0 1 62.69291 144.4236 cm q q 1 0 0 1 0 0 cm @@ -2800,32 +2783,47 @@ q n -6 -6 468.6898 84 re B* Q q -BT 1 0 0 1 0 65.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# a function with a generic signature) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\)\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj ({}) Tj T* ET +BT 1 0 0 1 0 62 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# a function with a generic signature) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\)\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj ({}) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 647.8236 cm +1 0 0 1 62.69291 112.4236 cm +q +BT 1 0 0 1 0 14 Tm .226654 Tw 12 TL /F1 10 Tf 0 0 0 rg (It is important to notice that the function body is interpolated before being executed, so be careful with the) Tj T* 0 Tw /F4 10 Tf (% ) Tj /F1 10 Tf (sign!) Tj T* ET +Q +Q +q +1 0 0 1 62.69291 82.42362 cm q -BT 1 0 0 1 0 16.82 Tm .226654 Tw 12 TL /F1 10 Tf 0 0 0 rg (It is important to notice that the function body is interpolated before being executed, so be careful with the) Tj T* 0 Tw /F5 10 Tf (% ) Tj /F1 10 Tf (sign!) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.995433 Tw 12 TL /F4 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (also accepts keyword arguments and such arguments are attached to the ) Tj T* 0 Tw 1.64686 Tw (resulting function. This is useful if you want to set some function attributes, for instance the docstring) Tj T* 0 Tw ET Q Q + +endstream +endobj +% 'R89': class PDFStream +89 0 obj +% page stream +<< /Length 7391 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 605.8236 cm +1 0 0 1 62.69291 753.0236 cm q -BT 1 0 0 1 0 28.82 Tm 1.995433 Tw 12 TL /F5 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (also accepts keyword arguments and such arguments are attached to the) Tj T* 0 Tw 1.64686 Tw (resulting function. This is useful if you want to set some function attributes, for instance the docstring) Tj T* 0 Tw /F5 10 Tf (__doc__) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F4 10 Tf 0 0 0 rg (__doc__) Tj /F1 10 Tf (.) Tj T* ET Q Q q -1 0 0 1 62.69291 563.8236 cm +1 0 0 1 62.69291 711.0236 cm q -BT 1 0 0 1 0 28.82 Tm .605318 Tw 12 TL /F1 10 Tf 0 0 0 rg (For debugging/introspection purposes it may be useful to see the source code of the generated function;) Tj T* 0 Tw 2.246235 Tw (to do that, just pass the flag ) Tj /F5 10 Tf (addsource=True ) Tj /F1 10 Tf (and a ) Tj /F5 10 Tf (__source__ ) Tj /F1 10 Tf (attribute will be added to the) Tj T* 0 Tw (generated function:) Tj T* ET +BT 1 0 0 1 0 26 Tm .605318 Tw 12 TL /F1 10 Tf 0 0 0 rg (For debugging/introspection purposes it may be useful to see the source code of the generated function;) Tj T* 0 Tw 2.246235 Tw (to do that, just pass the flag ) Tj /F4 10 Tf (addsource=True ) Tj /F1 10 Tf (and a ) Tj /F4 10 Tf (__source__ ) Tj /F1 10 Tf (attribute will be added to the) Tj T* 0 Tw (generated function:) Tj T* ET Q Q q -1 0 0 1 62.69291 470.6236 cm +1 0 0 1 62.69291 617.8236 cm q q 1 0 0 1 0 0 cm @@ -2838,38 +2836,38 @@ q n -6 -6 468.6898 84 re B* Q q -BT 1 0 0 1 0 65.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\),) Tj ( ) Tj (addsource) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f1) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__source__) Tj T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\):) Tj T* ( ) Tj (f) Tj (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET +BT 1 0 0 1 0 62 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\),) Tj ( ) Tj (addsource) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f1) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__source__) Tj T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\):) Tj T* ( ) Tj (f) Tj (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 330.6236 cm +1 0 0 1 62.69291 477.8236 cm q -BT 1 0 0 1 0 124.82 Tm .870651 Tw 12 TL /F5 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (can take as first argument a string, as in the examples before, or a function.) Tj T* 0 Tw .224985 Tw (This is the most common usage, since typically you want to decorate a pre-existing function. A framework) Tj T* 0 Tw 1.606136 Tw (author may want to use directly ) Tj /F5 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (instead of ) Tj /F5 10 Tf (decorator) Tj /F1 10 Tf (, since it gives you) Tj T* 0 Tw 1.36686 Tw (direct access to the body of the generated function. For instance, suppose you want to instrument the) Tj T* 0 Tw .372209 Tw /F5 10 Tf (__init__ ) Tj /F1 10 Tf (methods of a set of classes, by preserving their signature \(such use case is not made up; this) Tj T* 0 Tw .673828 Tw (is done in SQAlchemy and in other frameworks\). When the first argument of ) Tj /F5 10 Tf (FunctionMaker.create) Tj T* 0 Tw 3.405814 Tw /F1 10 Tf (is a function, a ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (object is instantiated internally, with attributes ) Tj /F5 10 Tf (args) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (varargs) Tj /F1 10 Tf (,) Tj T* 0 Tw 5.509982 Tw /F5 10 Tf (keywords ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (defaults ) Tj /F1 10 Tf (which are the the return values of the standard library function) Tj T* 0 Tw .561318 Tw /F5 10 Tf (inspect.getargspec) Tj /F1 10 Tf (. For each argument in the ) Tj /F5 10 Tf (args ) Tj /F1 10 Tf (\(which is a list of strings containing the names) Tj T* 0 Tw 1.599985 Tw (of the mandatory arguments\) an attribute ) Tj /F5 10 Tf (arg0) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (arg1) Tj /F1 10 Tf (, ..., ) Tj /F5 10 Tf (argN ) Tj /F1 10 Tf (is also generated. Finally, there is a) Tj T* 0 Tw /F5 10 Tf (signature ) Tj /F1 10 Tf (attribute, a string with the signature of the original function.) Tj T* ET +BT 1 0 0 1 0 122 Tm .870651 Tw 12 TL /F4 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (can take as first argument a string, as in the examples before, or a function.) Tj T* 0 Tw .224985 Tw (This is the most common usage, since typically you want to decorate a pre-existing function. A framework) Tj T* 0 Tw 1.606136 Tw (author may want to use directly ) Tj /F4 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (instead of ) Tj /F4 10 Tf (decorator) Tj /F1 10 Tf (, since it gives you) Tj T* 0 Tw 1.36686 Tw (direct access to the body of the generated function. For instance, suppose you want to instrument the) Tj T* 0 Tw .372209 Tw /F4 10 Tf (__init__ ) Tj /F1 10 Tf (methods of a set of classes, by preserving their signature \(such use case is not made up; this) Tj T* 0 Tw .673828 Tw (is done in SQAlchemy and in other frameworks\). When the first argument of ) Tj /F4 10 Tf (FunctionMaker.create) Tj T* 0 Tw 3.405814 Tw /F1 10 Tf (is a function, a ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (object is instantiated internally, with attributes ) Tj /F4 10 Tf (args) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (varargs) Tj /F1 10 Tf (,) Tj T* 0 Tw 5.509982 Tw /F4 10 Tf (keywords ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (defaults ) Tj /F1 10 Tf (which are the the return values of the standard library function) Tj T* 0 Tw .561318 Tw /F4 10 Tf (inspect.getargspec) Tj /F1 10 Tf (. For each argument in the ) Tj /F4 10 Tf (args ) Tj /F1 10 Tf (\(which is a list of strings containing the names) Tj T* 0 Tw 1.599985 Tw (of the mandatory arguments\) an attribute ) Tj /F4 10 Tf (arg0) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (arg1) Tj /F1 10 Tf (, ..., ) Tj /F4 10 Tf (argN ) Tj /F1 10 Tf (is also generated. Finally, there is a) Tj T* 0 Tw /F4 10 Tf (signature ) Tj /F1 10 Tf (attribute, a string with the signature of the original function.) Tj T* ET Q Q q -1 0 0 1 62.69291 252.6236 cm +1 0 0 1 62.69291 399.8236 cm q -BT 1 0 0 1 0 64.82 Tm 4.63311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that while I do not have plans to change or remove the functionality provided in the) Tj T* 0 Tw 1.00936 Tw /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class, I do not guarantee that it will stay unchanged forever. For instance, right now I) Tj T* 0 Tw .791318 Tw (am using the traditional string interpolation syntax for function templates, but Python 2.6 and Python 3.0) Tj T* 0 Tw .712093 Tw (provide a newer interpolation syntax and I may use the new syntax in the future. On the other hand, the) Tj T* 0 Tw .639985 Tw (functionality provided by ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (has been there from version 0.1 and it is guaranteed to stay there) Tj T* 0 Tw (forever.) Tj T* ET +BT 1 0 0 1 0 62 Tm 4.63311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that while I do not have plans to change or remove the functionality provided in the) Tj T* 0 Tw 1.00936 Tw /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class, I do not guarantee that it will stay unchanged forever. For instance, right now I) Tj T* 0 Tw .791318 Tw (am using the traditional string interpolation syntax for function templates, but Python 2.6 and Python 3.0) Tj T* 0 Tw .712093 Tw (provide a newer interpolation syntax and I may use the new syntax in the future. On the other hand, the) Tj T* 0 Tw .639985 Tw (functionality provided by ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (has been there from version 0.1 and it is guaranteed to stay there) Tj T* 0 Tw (forever.) Tj T* ET Q Q q -1 0 0 1 62.69291 219.6236 cm +1 0 0 1 62.69291 366.8236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Getting the source code) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Getting the source code) Tj T* ET Q Q q -1 0 0 1 62.69291 141.6236 cm +1 0 0 1 62.69291 288.8236 cm q -BT 1 0 0 1 0 64.82 Tm 5.045529 Tw 12 TL /F1 10 Tf 0 0 0 rg (Internally ) Tj /F5 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (uses ) Tj /F5 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Therefore) Tj T* 0 Tw 2.542126 Tw /F5 10 Tf (inspect.getsource ) Tj /F1 10 Tf (will not work for decorated functions. That means that the usual '??' trick in) Tj T* 0 Tw 2.163059 Tw (IPython will give you the \(right on the spot\) message ) Tj /F5 10 Tf (Dynamically generated function. No) Tj T* 0 Tw .563314 Tw (source code available) Tj /F1 10 Tf (. In the past I have considered this acceptable, since ) Tj /F5 10 Tf (inspect.getsource) Tj T* 0 Tw 1.790697 Tw /F1 10 Tf (does not really work even with regular decorators. In that case ) Tj /F5 10 Tf (inspect.getsource ) Tj /F1 10 Tf (gives you the) Tj T* 0 Tw (wrapper source code which is probably not what you want:) Tj T* ET +BT 1 0 0 1 0 62 Tm 5.045529 Tw 12 TL /F1 10 Tf 0 0 0 rg (Internally ) Tj /F4 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (uses ) Tj /F4 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Therefore) Tj T* 0 Tw 2.542126 Tw /F4 10 Tf (inspect.getsource ) Tj /F1 10 Tf (will not work for decorated functions. That means that the usual '??' trick in) Tj T* 0 Tw 2.163059 Tw (IPython will give you the \(right on the spot\) message ) Tj /F4 10 Tf (Dynamically generated function. No) Tj T* 0 Tw .563314 Tw (source code available) Tj /F1 10 Tf (. In the past I have considered this acceptable, since ) Tj /F4 10 Tf (inspect.getsource) Tj T* 0 Tw 1.790697 Tw /F1 10 Tf (does not really work even with regular decorators. In that case ) Tj /F4 10 Tf (inspect.getsource ) Tj /F1 10 Tf (gives you the) Tj T* 0 Tw (wrapper source code which is probably not what you want:) Tj T* ET Q Q q -1 0 0 1 62.69291 84.42362 cm +1 0 0 1 62.69291 219.6236 cm q q 1 0 0 1 0 0 cm @@ -2879,27 +2877,18 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 48 re B* +n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (identity_dec) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (wrapper) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 38 Tm /F4 10 Tf 12 TL (def identity_dec\(func\):) Tj T* ( def wrapper\(*args, **kw\):) Tj T* ( return func\(*args, **kw\)) Tj T* ( return wrapper) Tj T* ET Q Q Q Q Q - -endstream - -endobj -% 'R91': class PDFStream -91 0 obj -% page stream -<< /Length 7306 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 739.8236 cm +1 0 0 1 62.69291 114.4236 cm q q 1 0 0 1 0 0 cm @@ -2909,43 +2898,38 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 24 re B* +n -6 -6 468.6898 96 re B* Q q -BT 1 0 0 1 0 5.71 Tm 12 TL /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (wrapper) Tj T* ET +BT 1 0 0 1 0 74 Tm 12 TL /F4 10 Tf .666667 .133333 1 rg (@identity_dec) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (example) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (example) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (wrapper) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 634.6236 cm -q -q -1 0 0 1 0 0 cm -q -1 0 0 1 6.6 6.6 cm -q -.662745 .662745 .662745 RG -.5 w -.960784 .960784 .862745 rg -n -6 -6 468.6898 96 re B* -Q +1 0 0 1 62.69291 82.42362 cm q -BT 1 0 0 1 0 77.71 Tm 12 TL /F5 10 Tf .666667 .133333 1 rg (@identity_dec) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (example) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (example) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (wrapper) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET -Q -Q -Q +BT 1 0 0 1 0 14 Tm 1.471235 Tw 12 TL /F1 10 Tf 0 0 0 rg (\(see bug report ) Tj 0 0 .501961 rg (1764286 ) Tj 0 0 0 rg (for an explanation of what is happening\). Unfortunately the bug is still there, ) Tj T* 0 Tw 1.541235 Tw (even in Python 2.7 and 3.1. There is however a workaround. The decorator module adds an attribute) Tj T* 0 Tw ET Q Q + +endstream +endobj +% 'R90': class PDFStream +90 0 obj +% page stream +<< /Length 5339 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 578.6236 cm +1 0 0 1 62.69291 741.0236 cm q -BT 1 0 0 1 0 40.82 Tm 1.471235 Tw 12 TL /F1 10 Tf 0 0 0 rg (\(see bug report ) Tj 0 0 .501961 rg (1764286 ) Tj 0 0 0 rg (for an explanation of what is happening\). Unfortunately the bug is still there,) Tj T* 0 Tw 1.541235 Tw (even in Python 2.6 and 3.0. There is however a workaround. The decorator module adds an attribute) Tj T* 0 Tw .103984 Tw /F5 10 Tf (.undecorated ) Tj /F1 10 Tf (to the decorated function, containing a reference to the original function. The easy way to) Tj T* 0 Tw (get the source code is to call ) Tj /F5 10 Tf (inspect.getsource ) Tj /F1 10 Tf (on the undecorated function:) Tj T* ET +BT 1 0 0 1 0 14 Tm .103984 Tw 12 TL /F4 10 Tf 0 0 0 rg (.undecorated ) Tj /F1 10 Tf (to the decorated function, containing a reference to the original function. The easy way to) Tj T* 0 Tw (get the source code is to call ) Tj /F4 10 Tf (inspect.getsource ) Tj /F1 10 Tf (on the undecorated function:) Tj T* ET Q Q q -1 0 0 1 62.69291 473.4236 cm +1 0 0 1 62.69291 635.8236 cm q q 1 0 0 1 0 0 cm @@ -2958,26 +2942,26 @@ q n -6 -6 468.6898 96 re B* Q q -BT 1 0 0 1 0 77.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (factorial) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (undecorated) Tj (\)) Tj T* .666667 .133333 1 rg (@tail_recursive) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (factorial) Tj 0 0 0 rg (\() Tj (n) Tj (,) Tj ( ) Tj (acc) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (\):) Tj T* ( ) Tj .729412 .129412 .129412 rg ("The good old factorial") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (acc) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (n) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (acc) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET +BT 1 0 0 1 0 74 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (factorial) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (undecorated) Tj (\)) Tj T* .666667 .133333 1 rg (@tail_recursive) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (factorial) Tj 0 0 0 rg (\() Tj (n) Tj (,) Tj ( ) Tj (acc) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (\):) Tj T* ( ) Tj .729412 .129412 .129412 rg ("The good old factorial") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (acc) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (n) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (acc) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 440.4236 cm +1 0 0 1 62.69291 602.8236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Dealing with third party decorators) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Dealing with third party decorators) Tj T* ET Q Q q -1 0 0 1 62.69291 386.4236 cm +1 0 0 1 62.69291 548.8236 cm q -BT 1 0 0 1 0 40.82 Tm .321654 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes you find on the net some cool decorator that you would like to include in your code. However,) Tj T* 0 Tw .50061 Tw (more often than not the cool decorator is not signature-preserving. Therefore you may want an easy way) Tj T* 0 Tw 1.814597 Tw (to upgrade third party decorators to signature-preserving decorators without having to rewrite them in) Tj T* 0 Tw (terms of ) Tj /F5 10 Tf (decorator) Tj /F1 10 Tf (. You can use a ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (to implement that functionality as follows:) Tj T* ET +BT 1 0 0 1 0 38 Tm .321654 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes you find on the net some cool decorator that you would like to include in your code. However,) Tj T* 0 Tw .50061 Tw (more often than not the cool decorator is not signature-preserving. Therefore you may want an easy way) Tj T* 0 Tw 1.814597 Tw (to upgrade third party decorators to signature-preserving decorators without having to rewrite them in) Tj T* 0 Tw (terms of ) Tj /F4 10 Tf (decorator) Tj /F1 10 Tf (. You can use a ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (to implement that functionality as follows:) Tj T* ET Q Q q -1 0 0 1 62.69291 269.2236 cm +1 0 0 1 62.69291 431.6236 cm q q 1 0 0 1 0 0 cm @@ -2990,32 +2974,33 @@ q n -6 -6 468.6898 108 re B* Q q -BT 1 0 0 1 0 89.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (decorator_apply) Tj 0 0 0 rg (\() Tj (dec) Tj (,) Tj ( ) Tj (func) Tj (\):) Tj T* ( ) Tj /F7 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( Decorate a function by preserving the signature even if dec) Tj T* ( is not a signature-preserving decorator.) Tj T* ( """) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj T* ( ) Tj (func) Tj (,) Tj ( ) Tj .729412 .129412 .129412 rg ('return decorated\() Tj /F3 10 Tf .733333 .4 .533333 rg (%\(signature\)s) Tj /F5 10 Tf .729412 .129412 .129412 rg (\)') Tj 0 0 0 rg (,) Tj T* ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (decorated) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (dec) Tj (\() Tj (func) Tj (\)\),) Tj ( ) Tj (undecorated) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (func) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 86 Tm /F4 10 Tf 12 TL (def decorator_apply\(dec, func\):) Tj T* ( """) Tj T* ( Decorate a function by preserving the signature even if dec) Tj T* ( is not a signature-preserving decorator.) Tj T* ( """) Tj T* ( return FunctionMaker.create\() Tj T* ( func, 'return decorated\(%\(signature\)s\)',) Tj T* ( dict\(decorated=dec\(func\)\), undecorated=func\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 237.2236 cm +1 0 0 1 62.69291 399.6236 cm q -BT 1 0 0 1 0 16.82 Tm .698314 Tw 12 TL /F5 10 Tf 0 0 0 rg (decorator_apply ) Tj /F1 10 Tf (sets the attribute ) Tj /F5 10 Tf (.undecorated ) Tj /F1 10 Tf (of the generated function to the original function,) Tj T* 0 Tw (so that you can get the right source code.) Tj T* ET +BT 1 0 0 1 0 14 Tm .698314 Tw 12 TL /F4 10 Tf 0 0 0 rg (decorator_apply ) Tj /F1 10 Tf (sets the attribute ) Tj /F4 10 Tf (.undecorated ) Tj /F1 10 Tf (of the generated function to the original function,) Tj T* 0 Tw (so that you can get the right source code.) Tj T* ET Q Q q -1 0 0 1 62.69291 195.2236 cm +1 0 0 1 62.69291 357.6236 cm q -BT 1 0 0 1 0 28.82 Tm .13104 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that I am not providing this functionality in the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module directly since I think it is best to) Tj T* 0 Tw 2.070751 Tw (rewrite the decorator rather than adding an additional level of indirection. However, practicality beats) Tj T* 0 Tw (purity, so you can add ) Tj /F5 10 Tf (decorator_apply ) Tj /F1 10 Tf (to your toolbox and use it if you need to.) Tj T* ET +BT 1 0 0 1 0 26 Tm .13104 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that I am not providing this functionality in the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module directly since I think it is best to) Tj T* 0 Tw 2.070751 Tw (rewrite the decorator rather than adding an additional level of indirection. However, practicality beats) Tj T* 0 Tw (purity, so you can add ) Tj /F4 10 Tf (decorator_apply ) Tj /F1 10 Tf (to your toolbox and use it if you need to.) Tj T* ET Q Q q -1 0 0 1 62.69291 141.2236 cm +1 0 0 1 62.69291 303.6236 cm q -BT 1 0 0 1 0 40.82 Tm 1.74881 Tw 12 TL /F1 10 Tf 0 0 0 rg (In order to give an example of usage of ) Tj /F5 10 Tf (decorator_apply) Tj /F1 10 Tf (, I will show a pretty slick decorator that) Tj T* 0 Tw 1.276651 Tw (converts a tail-recursive function in an iterative function. I have shamelessly stolen the basic idea from) Tj T* 0 Tw 43.62829 Tw (Kay Schluehr's recipe in the Python Cookbook,) Tj T* 0 Tw 0 0 .501961 rg (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj 0 0 0 rg (.) Tj T* ET +BT 1 0 0 1 0 38 Tm 1.74881 Tw 12 TL /F1 10 Tf 0 0 0 rg (In order to give an example of usage of ) Tj /F4 10 Tf (decorator_apply) Tj /F1 10 Tf (, I will show a pretty slick decorator that) Tj T* 0 Tw 1.276651 Tw (converts a tail-recursive function in an iterative function. I have shamelessly stolen the basic idea from) Tj T* 0 Tw 43.62829 Tw (Kay Schluehr's recipe in the Python Cookbook,) Tj T* 0 Tw 0 0 .501961 rg (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj 0 0 0 rg (.) Tj T* ET Q Q q -1 0 0 1 62.69291 84.02362 cm +1 0 0 1 62.69291 78.42362 cm q q 1 0 0 1 0 0 cm @@ -3025,10 +3010,11 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 48 re B* +n -6 -6 468.6898 216 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (class) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (TailRecursive) Tj /F5 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* ( ) Tj /F7 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( tail_recursive decorator based on Kay Schluehr's recipe) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 194 Tm /F4 10 Tf 12 TL (class TailRecursive\(object\):) Tj T* ( """) Tj T* ( tail_recursive decorator based on Kay Schluehr's recipe) Tj T* ( http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj T* ( with improvements by me and George Sakkis.) Tj T* ( """) Tj T* T* ( def __init__\(self, func\):) Tj T* ( self.func = func) Tj T* ( self.firstcall = True) Tj T* ( self.CONTINUE = object\(\) # sentinel) Tj T* T* ( def __call__\(self, *args, **kwd\):) Tj T* ( CONTINUE = self.CONTINUE) Tj T* ( if self.firstcall:) Tj T* ( func = self.func) Tj T* ( self.firstcall = False) Tj T* ET Q Q Q @@ -3036,16 +3022,15 @@ Q Q endstream - endobj -% 'R92': class PDFStream -92 0 obj +% 'R91': class PDFStream +91 0 obj % page stream -<< /Length 7889 >> +<< /Length 4367 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 439.8236 cm +1 0 0 1 62.69291 607.8236 cm q q 1 0 0 1 0 0 cm @@ -3055,24 +3040,25 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 324 re B* +n -6 -6 468.6898 156 re B* Q q -BT 1 0 0 1 0 305.71 Tm 12 TL /F7 10 Tf .729412 .129412 .129412 rg ( http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj T* ( with improvements by me and George Sakkis.) Tj T* ( """) Tj /F5 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__init__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (\):) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (CONTINUE) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\(\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# sentinel) Tj /F5 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__call__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kwd) Tj (\):) Tj T* ( ) Tj (CONTINUE) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (CONTINUE) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj (:) Tj T* ( ) Tj (func) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (False) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (try) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (while) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (:) Tj T* ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kwd) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (is) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (CONTINUE) Tj (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# update arguments) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (args) Tj (,) Tj ( ) Tj (kwd) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (argskwd) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# last call) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (finally) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# return the arguments of the tail call) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (argskwd) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (kwd) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (CONTINUE) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 134 Tm /F4 10 Tf 12 TL ( try:) Tj T* ( while True:) Tj T* ( result = func\(*args, **kwd\)) Tj T* ( if result is CONTINUE: # update arguments) Tj T* ( args, kwd = self.argskwd) Tj T* ( else: # last call) Tj T* ( return result) Tj T* ( finally:) Tj T* ( self.firstcall = True) Tj T* ( else: # return the arguments of the tail call) Tj T* ( self.argskwd = args, kwd) Tj T* ( return CONTINUE) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 419.8236 cm +1 0 0 1 62.69291 587.8236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here the decorator is implemented as a class returning callable objects.) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here the decorator is implemented as a class returning callable objects.) Tj T* ET Q Q q -1 0 0 1 62.69291 374.6236 cm +1 0 0 1 62.69291 542.6236 cm q q 1 0 0 1 0 0 cm @@ -3085,21 +3071,22 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (tail_recursive) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator_apply) Tj (\() Tj (TailRecursive) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 14 Tm /F4 10 Tf 12 TL (def tail_recursive\(func\):) Tj T* ( return decorator_apply\(TailRecursive, func\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 354.6236 cm +1 0 0 1 62.69291 522.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is how you apply the upgraded decorator to the good old factorial:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is how you apply the upgraded decorator to the good old factorial:) Tj T* ET Q Q q -1 0 0 1 62.69291 273.4236 cm +1 0 0 1 62.69291 441.4236 cm q q 1 0 0 1 0 0 cm @@ -3112,14 +3099,15 @@ q n -6 -6 468.6898 72 re B* Q q -BT 1 0 0 1 0 53.71 Tm 12 TL /F5 10 Tf .666667 .133333 1 rg (@tail_recursive) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (factorial) Tj 0 0 0 rg (\() Tj (n) Tj (,) Tj ( ) Tj (acc) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (\):) Tj T* ( ) Tj .729412 .129412 .129412 rg ("The good old factorial") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (acc) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (n) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (acc) Tj (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 50 Tm /F4 10 Tf 12 TL (@tail_recursive) Tj T* (def factorial\(n, acc=1\):) Tj T* ( "The good old factorial") Tj T* ( if n == 0: return acc) Tj T* ( return factorial\(n-1, n*acc\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 228.2236 cm +1 0 0 1 62.69291 396.2236 cm q q 1 0 0 1 0 0 cm @@ -3132,20 +3120,20 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (24) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (24) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 172.2236 cm +1 0 0 1 62.69291 340.2236 cm q -BT 1 0 0 1 0 40.82 Tm .188935 Tw 12 TL /F1 10 Tf 0 0 0 rg (This decorator is pretty impressive, and should give you some food for your mind ;\) Notice that there is no) Tj T* 0 Tw 1.339983 Tw (recursion limit now, and you can easily compute ) Tj /F5 10 Tf (factorial\(1001\) ) Tj /F1 10 Tf (or larger without filling the stack) Tj T* 0 Tw .909431 Tw (frame. Notice also that the decorator will not work on functions which are not tail recursive, such as the) Tj T* 0 Tw (following) Tj T* ET +BT 1 0 0 1 0 38 Tm .188935 Tw 12 TL /F1 10 Tf 0 0 0 rg (This decorator is pretty impressive, and should give you some food for your mind ;\) Notice that there is no) Tj T* 0 Tw 1.339983 Tw (recursion limit now, and you can easily compute ) Tj /F4 10 Tf (factorial\(1001\) ) Tj /F1 10 Tf (or larger without filling the stack) Tj T* 0 Tw .909431 Tw (frame. Notice also that the decorator will not work on functions which are not tail recursive, such as the) Tj T* 0 Tw (following) Tj T* ET Q Q q -1 0 0 1 62.69291 115.0236 cm +1 0 0 1 62.69291 283.0236 cm q q 1 0 0 1 0 0 cm @@ -3158,44 +3146,35 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (fact) Tj 0 0 0 rg (\() Tj (n) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# this is not tail-recursive) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg ( ) Tj (fact) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (\)) Tj T* ET +0 0 0 rg +BT 1 0 0 1 0 26 Tm /F4 10 Tf 12 TL (def fact\(n\): # this is not tail-recursive) Tj T* ( if n == 0: return 1) Tj T* ( return n * fact\(n-1\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 83.02362 cm +1 0 0 1 62.69291 251.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .541098 Tw (\(reminder: a function is tail recursive if it either returns a value without making a recursive call, or returns) Tj T* 0 Tw (directly the result of a recursive call\).) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .541098 Tw (\(reminder: a function is tail recursive if it either returns a value without making a recursive call, or returns) Tj T* 0 Tw (directly the result of a recursive call\).) Tj T* ET Q Q - -endstream - -endobj -% 'R93': class PDFStream -93 0 obj -% page stream -<< /Length 5004 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 744.0236 cm +1 0 0 1 62.69291 218.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Caveats and limitations) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Caveats and limitations) Tj T* ET Q Q q -1 0 0 1 62.69291 714.0236 cm +1 0 0 1 62.69291 188.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .474987 Tw (The first thing you should be aware of, it the fact that decorators have a performance penalty. The worse) Tj T* 0 Tw (case is shown by the following example:) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .474987 Tw (The first thing you should be aware of, it the fact that decorators have a performance penalty. The worse) Tj T* 0 Tw (case is shown by the following example:) Tj T* ET Q Q q -1 0 0 1 62.69291 488.8236 cm +1 0 0 1 62.69291 82.82362 cm q q 1 0 0 1 0 0 cm @@ -3205,24 +3184,54 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 216 re B* +n -6 -6 468.6898 96 re B* +Q +q +0 0 0 rg +BT 1 0 0 1 0 74 Tm /F4 10 Tf 12 TL ($ cat performance.sh) Tj T* (python -m timeit -s ") Tj T* (from decorator import decorator) Tj T* T* (@decorator) Tj T* (def do_nothing\(func, *args, **kw\):) Tj T* ( return func\(*args, **kw\)) Tj T* ET +Q +Q +Q +Q +Q + +endstream +endobj +% 'R92': class PDFStream +92 0 obj +% page stream +<< /Length 6135 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +q +1 0 0 1 62.69291 631.8236 cm +q +q +1 0 0 1 0 0 cm +q +1 0 0 1 6.6 6.6 cm +q +.662745 .662745 .662745 RG +.5 w +.960784 .960784 .862745 rg +n -6 -6 468.6898 132 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 197.71 Tm /F5 10 Tf 12 TL ($ cat performance.sh) Tj T* (python -m timeit -s ") Tj T* (from decorator import decorator) Tj T* T* (@decorator) Tj T* (def do_nothing\(func, *args, **kw\):) Tj T* ( return func\(*args, **kw\)) Tj T* T* (@do_nothing) Tj T* (def f\(\):) Tj T* ( pass) Tj T* (" "f\(\)") Tj T* T* (python -m timeit -s ") Tj T* (def f\(\):) Tj T* ( pass) Tj T* (" "f\(\)") Tj T* ET +BT 1 0 0 1 0 110 Tm /F4 10 Tf 12 TL T* (@do_nothing) Tj T* (def f\(\):) Tj T* ( pass) Tj T* (" "f\(\)") Tj T* T* (python -m timeit -s ") Tj T* (def f\(\):) Tj T* ( pass) Tj T* (" "f\(\)") Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 456.8236 cm +1 0 0 1 62.69291 599.8236 cm q -BT 1 0 0 1 0 16.82 Tm .266235 Tw 12 TL /F1 10 Tf 0 0 0 rg (On my MacBook, using the ) Tj /F5 10 Tf (do_nothing ) Tj /F1 10 Tf (decorator instead of the plain function is more than three times) Tj T* 0 Tw (slower:) Tj T* ET +BT 1 0 0 1 0 14 Tm .266235 Tw 12 TL /F1 10 Tf 0 0 0 rg (On my MacBook, using the ) Tj /F4 10 Tf (do_nothing ) Tj /F1 10 Tf (decorator instead of the plain function is more than three times) Tj T* 0 Tw (slower:) Tj T* ET Q Q q -1 0 0 1 62.69291 399.6236 cm +1 0 0 1 62.69291 542.6236 cm q q 1 0 0 1 0 0 cm @@ -3236,27 +3245,27 @@ n -6 -6 468.6898 48 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 29.71 Tm /F5 10 Tf 12 TL ($ bash performance.sh) Tj T* (1000000 loops, best of 3: 0.995 usec per loop) Tj T* (1000000 loops, best of 3: 0.273 usec per loop) Tj T* ET +BT 1 0 0 1 0 26 Tm /F4 10 Tf 12 TL ($ bash performance.sh) Tj T* (1000000 loops, best of 3: 0.995 usec per loop) Tj T* (1000000 loops, best of 3: 0.273 usec per loop) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 355.6236 cm +1 0 0 1 62.69291 498.6236 cm q -BT 1 0 0 1 0 28.82 Tm 1.25832 Tw 12 TL /F1 10 Tf 0 0 0 rg (It should be noted that a real life function would probably do something more useful than ) Tj /F5 10 Tf (f ) Tj /F1 10 Tf (here, and) Tj T* 0 Tw .91811 Tw (therefore in real life the performance penalty could be completely negligible. As always, the only way to) Tj T* 0 Tw (know if there is a penalty in your specific use case is to measure it.) Tj T* ET +BT 1 0 0 1 0 26 Tm 1.25832 Tw 12 TL /F1 10 Tf 0 0 0 rg (It should be noted that a real life function would probably do something more useful than ) Tj /F4 10 Tf (f ) Tj /F1 10 Tf (here, and) Tj T* 0 Tw .91811 Tw (therefore in real life the performance penalty could be completely negligible. As always, the only way to) Tj T* 0 Tw (know if there is a penalty in your specific use case is to measure it.) Tj T* ET Q Q q -1 0 0 1 62.69291 325.6236 cm +1 0 0 1 62.69291 468.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .867984 Tw (You should be aware that decorators will make your tracebacks longer and more difficult to understand.) Tj T* 0 Tw (Consider this example:) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .867984 Tw (You should be aware that decorators will make your tracebacks longer and more difficult to understand.) Tj T* 0 Tw (Consider this example:) Tj T* ET Q Q q -1 0 0 1 62.69291 268.4236 cm +1 0 0 1 62.69291 411.4236 cm q q 1 0 0 1 0 0 cm @@ -3269,20 +3278,20 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 236.4236 cm +1 0 0 1 62.69291 379.4236 cm q -BT 1 0 0 1 0 16.82 Tm .583318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Calling ) Tj /F5 10 Tf (f\(\) ) Tj /F1 10 Tf (will give you a ) Tj /F5 10 Tf (ZeroDivisionError) Tj /F1 10 Tf (, but since the function is decorated the traceback will) Tj T* 0 Tw (be longer:) Tj T* ET +BT 1 0 0 1 0 14 Tm .583318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Calling ) Tj /F4 10 Tf (f\(\) ) Tj /F1 10 Tf (will give you a ) Tj /F4 10 Tf (ZeroDivisionError) Tj /F1 10 Tf (, but since the function is decorated the traceback will) Tj T* 0 Tw (be longer:) Tj T* ET Q Q q -1 0 0 1 62.69291 107.2236 cm +1 0 0 1 62.69291 250.2236 cm q q 1 0 0 1 0 0 cm @@ -3295,42 +3304,41 @@ q n -6 -6 468.6898 120 re B* Q q -BT 1 0 0 1 0 101.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\(\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (string) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[18]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (trace) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[47]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (ZeroDivisionError) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj (integer) Tj ( ) Tj (division) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (or) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (modulo) Tj ( ) Tj (by) Tj ( ) Tj (zero) Tj T* ET +BT 1 0 0 1 0 98 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\(\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (string) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[18]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (trace) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[47]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (ZeroDivisionError) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj (integer) Tj ( ) Tj (division) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (or) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (modulo) Tj ( ) Tj (by) Tj ( ) Tj (zero) Tj T* ET Q Q Q Q Q - -endstream - -endobj -% 'R94': class PDFStream -94 0 obj -% page stream -<< /Length 7526 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 705.0236 cm +1 0 0 1 62.69291 182.2236 cm q -BT 1 0 0 1 0 52.82 Tm 1.05528 Tw 12 TL /F1 10 Tf 0 0 0 rg (You see here the inner call to the decorator ) Tj /F5 10 Tf (trace) Tj /F1 10 Tf (, which calls ) Tj /F5 10 Tf (f\(*args, **kw\)) Tj /F1 10 Tf (, and a reference to) Tj T* 0 Tw .265868 Tw /F5 10 Tf (File ") Tj (<) Tj (string) Tj (>) Tj (", line 2, in f) Tj /F1 10 Tf (. This latter reference is due to the fact that internally the decorator) Tj T* 0 Tw 2.053318 Tw (module uses ) Tj /F5 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Notice that ) Tj /F5 10 Tf (exec ) Tj /F1 10 Tf (is ) Tj /F6 10 Tf (not ) Tj /F1 10 Tf (responsibile for the) Tj T* 0 Tw 1.507485 Tw (performance penalty, since is the called ) Tj /F6 10 Tf (only once ) Tj /F1 10 Tf (at function decoration time, and not every time the) Tj T* 0 Tw (decorated function is called.) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.05528 Tw 12 TL /F1 10 Tf 0 0 0 rg (You see here the inner call to the decorator ) Tj /F4 10 Tf (trace) Tj /F1 10 Tf (, which calls ) Tj /F4 10 Tf (f\(*args, **kw\)) Tj /F1 10 Tf (, and a reference to) Tj T* 0 Tw .265868 Tw /F4 10 Tf (File ") Tj (<) Tj (string) Tj (>) Tj (", line 2, in f) Tj /F1 10 Tf (. This latter reference is due to the fact that internally the decorator) Tj T* 0 Tw 2.053318 Tw (module uses ) Tj /F4 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Notice that ) Tj /F4 10 Tf (exec ) Tj /F1 10 Tf (is ) Tj /F5 10 Tf (not ) Tj /F1 10 Tf (responsibile for the) Tj T* 0 Tw 1.507485 Tw (performance penalty, since is the called ) Tj /F5 10 Tf (only once ) Tj /F1 10 Tf (at function decoration time, and not every time the) Tj T* 0 Tw (decorated function is called.) Tj T* ET Q Q q -1 0 0 1 62.69291 627.0236 cm +1 0 0 1 62.69291 104.2236 cm q -BT 1 0 0 1 0 64.82 Tm .932209 Tw 12 TL /F1 10 Tf 0 0 0 rg (At present, there is no clean way to avoid ) Tj /F5 10 Tf (exec) Tj /F1 10 Tf (. A clean solution would require to change the CPython) Tj T* 0 Tw .777485 Tw (implementation of functions and add an hook to make it possible to change their signature directly. That) Tj T* 0 Tw .74186 Tw (could happen in future versions of Python \(see PEP ) Tj 0 0 .501961 rg (362) Tj 0 0 0 rg (\) and then the decorator module would become) Tj T* 0 Tw 2.385318 Tw (obsolete. However, at present, even in Python 3.1 it is impossible to change the function signature) Tj T* 0 Tw .931751 Tw (directly, therefore the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module is still useful. Actually, this is one of the main reasons why I) Tj T* 0 Tw (keep maintaining the module and releasing new versions.) Tj T* ET +BT 1 0 0 1 0 62 Tm .932209 Tw 12 TL /F1 10 Tf 0 0 0 rg (At present, there is no clean way to avoid ) Tj /F4 10 Tf (exec) Tj /F1 10 Tf (. A clean solution would require to change the CPython) Tj T* 0 Tw .777485 Tw (implementation of functions and add an hook to make it possible to change their signature directly. That) Tj T* 0 Tw .74186 Tw (could happen in future versions of Python \(see PEP ) Tj 0 0 .501961 rg (362) Tj 0 0 0 rg (\) and then the decorator module would become) Tj T* 0 Tw 2.385318 Tw (obsolete. However, at present, even in Python 3.1 it is impossible to change the function signature) Tj T* 0 Tw .931751 Tw (directly, therefore the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module is still useful. Actually, this is one of the main reasons why I) Tj T* 0 Tw (keep maintaining the module and releasing new versions.) Tj T* ET Q Q + +endstream +endobj +% 'R93': class PDFStream +93 0 obj +% page stream +<< /Length 7992 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 561.0236 cm +1 0 0 1 62.69291 705.0236 cm q -BT 1 0 0 1 0 52.82 Tm 1.043828 Tw 12 TL /F1 10 Tf 0 0 0 rg (In the present implementation, decorators generated by ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (can only be used on user-defined) Tj T* 0 Tw .152485 Tw (Python functions or methods, not on generic callable objects, nor on built-in functions, due to limitations of) Tj T* 0 Tw .591235 Tw (the ) Tj /F5 10 Tf (inspect ) Tj /F1 10 Tf (module in the standard library. Moreover, notice that you can decorate a method, but only) Tj T* 0 Tw 2.693516 Tw (before if becomes a bound or unbound method, i.e. inside the class. Here is an example of valid) Tj T* 0 Tw (decoration:) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.043828 Tw 12 TL /F1 10 Tf 0 0 0 rg (In the present implementation, decorators generated by ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (can only be used on user-defined) Tj T* 0 Tw .152485 Tw (Python functions or methods, not on generic callable objects, nor on built-in functions, due to limitations of) Tj T* 0 Tw .591235 Tw (the ) Tj /F4 10 Tf (inspect ) Tj /F1 10 Tf (module in the standard library. Moreover, notice that you can decorate a method, but only) Tj T* 0 Tw 2.693516 Tw (before if becomes a bound or unbound method, i.e. inside the class. Here is an example of valid) Tj T* 0 Tw (decoration:) Tj T* ET Q Q q -1 0 0 1 62.69291 491.8236 cm +1 0 0 1 62.69291 635.8236 cm q q 1 0 0 1 0 0 cm @@ -3343,21 +3351,21 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (class) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (C) Tj /F5 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (meth) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (class) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (C) Tj /F4 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (meth) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 471.8236 cm +1 0 0 1 62.69291 615.8236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is an example of invalid decoration, when the decorator in called too late:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is an example of invalid decoration, when the decorator in called too late:) Tj T* ET Q Q q -1 0 0 1 62.69291 354.6236 cm +1 0 0 1 62.69291 498.6236 cm q q 1 0 0 1 0 0 cm @@ -3370,21 +3378,21 @@ q n -6 -6 468.6898 108 re B* Q q -BT 1 0 0 1 0 89.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (class) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (C) Tj /F5 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (meth) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (C) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (meth) Tj (\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (TypeError) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj (You) Tj ( ) Tj (are) Tj ( ) Tj (decorating) Tj ( ) Tj (a) Tj ( ) Tj (non) Tj ( ) Tj (function) Tj (:) Tj ( ) Tj .4 .4 .4 rg (<) Tj 0 0 0 rg (unbound) Tj ( ) Tj (method) Tj ( ) Tj (C) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (meth) Tj .4 .4 .4 rg (>) Tj T* ET +BT 1 0 0 1 0 86 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (class) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (C) Tj /F4 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (meth) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (C) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (meth) Tj (\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (TypeError) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj (You) Tj ( ) Tj (are) Tj ( ) Tj (decorating) Tj ( ) Tj (a) Tj ( ) Tj (non) Tj ( ) Tj (function) Tj (:) Tj ( ) Tj .4 .4 .4 rg (<) Tj 0 0 0 rg (unbound) Tj ( ) Tj (method) Tj ( ) Tj (C) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (meth) Tj .4 .4 .4 rg (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 334.6236 cm +1 0 0 1 62.69291 478.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (The solution is to extract the inner function from the unbound method:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (The solution is to extract the inner function from the unbound method:) Tj T* ET Q Q q -1 0 0 1 62.69291 289.4236 cm +1 0 0 1 62.69291 433.4236 cm q q 1 0 0 1 0 0 cm @@ -3397,20 +3405,20 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (C) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (meth) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (im_func) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (function) Tj ( ) Tj (meth) Tj ( ) Tj (at) Tj ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (x) Tj .4 .4 .4 rg (...) Tj (>) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (C) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (meth) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (im_func) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (function) Tj ( ) Tj (meth) Tj ( ) Tj (at) Tj ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (x) Tj .4 .4 .4 rg (...) Tj (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 257.4236 cm +1 0 0 1 62.69291 401.4236 cm q -BT 1 0 0 1 0 16.82 Tm .785777 Tw 12 TL /F1 10 Tf 0 0 0 rg (There is a restriction on the names of the arguments: for instance, if try to call an argument ) Tj /F5 10 Tf (_call_ ) Tj /F1 10 Tf (or) Tj T* 0 Tw /F5 10 Tf (_func_ ) Tj /F1 10 Tf (you will get a ) Tj /F5 10 Tf (NameError) Tj /F1 10 Tf (:) Tj T* ET +BT 1 0 0 1 0 14 Tm .785777 Tw 12 TL /F1 10 Tf 0 0 0 rg (There is a restriction on the names of the arguments: for instance, if try to call an argument ) Tj /F4 10 Tf (_call_ ) Tj /F1 10 Tf (or) Tj T* 0 Tw /F4 10 Tf (_func_ ) Tj /F1 10 Tf (you will get a ) Tj /F4 10 Tf (NameError) Tj /F1 10 Tf (:) Tj T* ET Q Q q -1 0 0 1 62.69291 140.2236 cm +1 0 0 1 62.69291 284.2236 cm q q 1 0 0 1 0 0 cm @@ -3423,30 +3431,20 @@ q n -6 -6 468.6898 108 re B* Q q -BT 1 0 0 1 0 89.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (NameError) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj (_func_) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (is) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (overridden) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (_call_) Tj (\() Tj (_func_) Tj (,) Tj ( ) Tj (_func_) Tj (\)) Tj T* ET +BT 1 0 0 1 0 86 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (NameError) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj (_func_) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (is) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (overridden) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (_call_) Tj (\() Tj (_func_) Tj (,) Tj ( ) Tj (_func_) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 108.2236 cm +1 0 0 1 62.69291 240.2236 cm q -BT 1 0 0 1 0 16.82 Tm 1.533318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally, the implementation is such that the decorated function contains a ) Tj /F6 10 Tf (copy ) Tj /F1 10 Tf (of the original function) Tj T* 0 Tw (dictionary \() Tj /F5 10 Tf (vars\(decorated_f\) is not vars\(f\)) Tj /F1 10 Tf (\):) Tj T* ET +BT 1 0 0 1 0 26 Tm .194651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally, the implementation is such that the decorated function attribute ) Tj /F4 10 Tf (.func_globals ) Tj /F1 10 Tf (is a ) Tj /F5 10 Tf (copy ) Tj /F1 10 Tf (of the) Tj T* 0 Tw 2.966136 Tw (original function attribute. Moreover the decorated function contains a ) Tj /F5 10 Tf (copy ) Tj /F1 10 Tf (of the original function) Tj T* 0 Tw (dictionary \() Tj /F4 10 Tf (vars\(decorated_f\) is not vars\(f\)) Tj /F1 10 Tf (\):) Tj T* ET Q Q - -endstream - -endobj -% 'R95': class PDFStream -95 0 obj -% page stream -<< /Length 7171 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 619.8236 cm +1 0 0 1 62.69291 87.02362 cm q q 1 0 0 1 0 0 cm @@ -3459,63 +3457,72 @@ q n -6 -6 468.6898 144 re B* Q q -BT 1 0 0 1 0 125.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the original function) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something") Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# setting an attribute) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something else") Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# setting another attribute) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (f) Tj (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the decorated function) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj T* .729412 .129412 .129412 rg ('something') Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something different") Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# setting attr) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the original attribute did not change) Tj /F5 10 Tf 0 0 0 rg T* .729412 .129412 .129412 rg ('something else') Tj T* ET +BT 1 0 0 1 0 122 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the original function) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something") Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# setting an attribute) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something else") Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# setting another attribute) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (f) Tj (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the decorated function) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj T* .729412 .129412 .129412 rg ('something') Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something different") Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# setting attr) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the original attribute did not change) Tj /F4 10 Tf 0 0 0 rg T* .729412 .129412 .129412 rg ('something else') Tj T* ET Q Q Q Q Q + +endstream +endobj +% 'R94': class PDFStream +94 0 obj +% page stream +<< /Length 6011 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 586.8236 cm +1 0 0 1 62.69291 744.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Compatibility notes) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Compatibility notes) Tj T* ET Q Q q -1 0 0 1 62.69291 520.8236 cm +1 0 0 1 62.69291 678.0236 cm q -BT 1 0 0 1 0 52.82 Tm 1.71811 Tw 12 TL /F1 10 Tf 0 0 0 rg (Version 3.2 is the first version of the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module to officially support Python 3. Actually, the) Tj T* 0 Tw .273516 Tw (module has supported Python 3 from the beginning, via the ) Tj /F5 10 Tf (2to3 ) Tj /F1 10 Tf (conversion tool, but this step has been) Tj T* 0 Tw .37284 Tw (now integrated in the build process, thanks to the ) Tj 0 0 .501961 rg (distribute ) Tj 0 0 0 rg (project, the Python 3-compatible replacement) Tj T* 0 Tw .11811 Tw (of easy_install. The hard work \(for me\) has been converting the documentation and the doctests. This has) Tj T* 0 Tw (been possible only now that ) Tj 0 0 .501961 rg (docutils ) Tj 0 0 0 rg (and ) Tj 0 0 .501961 rg (pygments ) Tj 0 0 0 rg (have been ported to Python 3.) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.71811 Tw 12 TL /F1 10 Tf 0 0 0 rg (Version 3.2 is the first version of the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module to officially support Python 3. Actually, the) Tj T* 0 Tw .273516 Tw (module has supported Python 3 from the beginning, via the ) Tj /F4 10 Tf (2to3 ) Tj /F1 10 Tf (conversion tool, but this step has been) Tj T* 0 Tw .37284 Tw (now integrated in the build process, thanks to the ) Tj 0 0 .501961 rg (distribute ) Tj 0 0 0 rg (project, the Python 3-compatible replacement) Tj T* 0 Tw .11811 Tw (of easy_install. The hard work \(for me\) has been converting the documentation and the doctests. This has) Tj T* 0 Tw (been possible only now that ) Tj 0 0 .501961 rg (docutils ) Tj 0 0 0 rg (and ) Tj 0 0 .501961 rg (pygments ) Tj 0 0 0 rg (have been ported to Python 3.) Tj T* ET Q Q q -1 0 0 1 62.69291 442.8236 cm +1 0 0 1 62.69291 600.0236 cm q -BT 1 0 0 1 0 64.82 Tm 1.19561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module ) Tj /F6 10 Tf (per se ) Tj /F1 10 Tf (does not contain any change, apart from the removal of the functions) Tj T* 0 Tw 1.348314 Tw /F5 10 Tf (get_info ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (new_wrapper) Tj /F1 10 Tf (, which have been deprecated for years. ) Tj /F5 10 Tf (get_info ) Tj /F1 10 Tf (has been removed) Tj T* 0 Tw .921654 Tw (since it was little used and since it had to be changed anyway to work with Python 3.0; ) Tj /F5 10 Tf (new_wrapper) Tj T* 0 Tw .609318 Tw /F1 10 Tf (has been removed since it was useless: its major use case \(converting signature changing decorators to) Tj T* 0 Tw .028443 Tw (signature preserving decorators\) has been subsumed by ) Tj /F5 10 Tf (decorator_apply ) Tj /F1 10 Tf (and the other use case can) Tj T* 0 Tw (be managed with the ) Tj /F5 10 Tf (FunctionMaker) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 62 Tm 1.19561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module ) Tj /F5 10 Tf (per se ) Tj /F1 10 Tf (does not contain any change, apart from the removal of the functions) Tj T* 0 Tw 1.348314 Tw /F4 10 Tf (get_info ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (new_wrapper) Tj /F1 10 Tf (, which have been deprecated for years. ) Tj /F4 10 Tf (get_info ) Tj /F1 10 Tf (has been removed) Tj T* 0 Tw .921654 Tw (since it was little used and since it had to be changed anyway to work with Python 3.0; ) Tj /F4 10 Tf (new_wrapper) Tj T* 0 Tw .609318 Tw /F1 10 Tf (has been removed since it was useless: its major use case \(converting signature changing decorators to) Tj T* 0 Tw .028443 Tw (signature preserving decorators\) has been subsumed by ) Tj /F4 10 Tf (decorator_apply ) Tj /F1 10 Tf (and the other use case can) Tj T* 0 Tw (be managed with the ) Tj /F4 10 Tf (FunctionMaker) Tj /F1 10 Tf (.) Tj T* ET Q Q q -1 0 0 1 62.69291 376.8236 cm +1 0 0 1 62.69291 534.0236 cm q -BT 1 0 0 1 0 52.82 Tm 1.329213 Tw 12 TL /F1 10 Tf 0 0 0 rg (There are a few changes in the documentation: I removed the ) Tj /F5 10 Tf (decorator_factory ) Tj /F1 10 Tf (example, which) Tj T* 0 Tw 2.562927 Tw (was confusing some of my users, and I removed the part about exotic signatures in the Python 3) Tj T* 0 Tw 2.20061 Tw (documentation, since Python 3 does not support them. Notice that there is no support for Python 3) Tj T* 0 Tw 1.163984 Tw 0 0 .501961 rg (function annotations ) Tj 0 0 0 rg (since it seems premature at the moment, when most people are still using Python) Tj T* 0 Tw (2.X.) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.329213 Tw 12 TL /F1 10 Tf 0 0 0 rg (There are a few changes in the documentation: I removed the ) Tj /F4 10 Tf (decorator_factory ) Tj /F1 10 Tf (example, which) Tj T* 0 Tw 2.562927 Tw (was confusing some of my users, and I removed the part about exotic signatures in the Python 3) Tj T* 0 Tw 2.20061 Tw (documentation, since Python 3 does not support them. Notice that there is no support for Python 3) Tj T* 0 Tw 1.163984 Tw 0 0 .501961 rg (function annotations ) Tj 0 0 0 rg (since it seems premature at the moment, when most people are still using Python) Tj T* 0 Tw (2.X.) Tj T* ET Q Q q -1 0 0 1 62.69291 310.8236 cm +1 0 0 1 62.69291 468.0236 cm q -BT 1 0 0 1 0 52.82 Tm .942651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (cannot be used as a class decorator and the ) Tj 0 0 .501961 rg (functionality introduced in version 2.3) Tj T* 0 Tw .241163 Tw 0 0 0 rg (has been removed. That means that in order to define decorator factories with classes you need to define) Tj T* 0 Tw 1.122126 Tw (the ) Tj /F5 10 Tf (__call__ ) Tj /F1 10 Tf (method explicitly \(no magic anymore\). All these changes should not cause any trouble,) Tj T* 0 Tw .601163 Tw (since they were all rarely used features. Should you have any trouble, you can always downgrade to the) Tj T* 0 Tw (2.3 version.) Tj T* ET +BT 1 0 0 1 0 50 Tm .942651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (cannot be used as a class decorator and the ) Tj 0 0 .501961 rg (functionality introduced in version 2.3) Tj T* 0 Tw .241163 Tw 0 0 0 rg (has been removed. That means that in order to define decorator factories with classes you need to define) Tj T* 0 Tw 1.122126 Tw (the ) Tj /F4 10 Tf (__call__ ) Tj /F1 10 Tf (method explicitly \(no magic anymore\). All these changes should not cause any trouble,) Tj T* 0 Tw .601163 Tw (since they were all rarely used features. Should you have any trouble, you can always downgrade to the) Tj T* 0 Tw (2.3 version.) Tj T* ET Q Q q -1 0 0 1 62.69291 244.8236 cm +1 0 0 1 62.69291 402.0236 cm q -BT 1 0 0 1 0 52.82 Tm .196098 Tw 12 TL /F1 10 Tf 0 0 0 rg (The examples shown here have been tested with Python 2.6. Python 2.4 is also supported - of course the) Tj T* 0 Tw 1.649398 Tw (examples requiring the ) Tj /F5 10 Tf (with ) Tj /F1 10 Tf (statement will not work there. Python 2.5 works fine, but if you run the) Tj T* 0 Tw 1.41784 Tw (examples in the interactive interpreter you will notice a few differences since ) Tj /F5 10 Tf (getargspec ) Tj /F1 10 Tf (returns an) Tj T* 0 Tw .909982 Tw /F5 10 Tf (ArgSpec ) Tj /F1 10 Tf (namedtuple instead of a regular tuple. That means that running the file ) Tj /F5 10 Tf (documentation.py) Tj T* 0 Tw /F1 10 Tf (under Python 2.5 will print a few errors, but they are not serious.) Tj T* ET +BT 1 0 0 1 0 50 Tm .196098 Tw 12 TL /F1 10 Tf 0 0 0 rg (The examples shown here have been tested with Python 2.6. Python 2.4 is also supported - of course the) Tj T* 0 Tw 1.649398 Tw (examples requiring the ) Tj /F4 10 Tf (with ) Tj /F1 10 Tf (statement will not work there. Python 2.5 works fine, but if you run the) Tj T* 0 Tw 1.41784 Tw (examples in the interactive interpreter you will notice a few differences since ) Tj /F4 10 Tf (getargspec ) Tj /F1 10 Tf (returns an) Tj T* 0 Tw .909982 Tw /F4 10 Tf (ArgSpec ) Tj /F1 10 Tf (namedtuple instead of a regular tuple. That means that running the file ) Tj /F4 10 Tf (documentation.py) Tj T* 0 Tw /F1 10 Tf (under Python 2.5 will print a few errors, but they are not serious.) Tj T* ET Q Q q -1 0 0 1 62.69291 211.8236 cm +1 0 0 1 62.69291 369.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (LICENCE) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (LICENCE) Tj T* ET Q Q q -1 0 0 1 62.69291 181.8236 cm +1 0 0 1 62.69291 339.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL 1.328555 Tw (Redistribution and use in source and binary forms, with or without modification, are permitted provided) Tj T* 0 Tw (that the following conditions are met:) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL 1.328555 Tw (Redistribution and use in source and binary forms, with or without modification, are permitted provided) Tj T* 0 Tw (that the following conditions are met:) Tj T* ET Q Q q -1 0 0 1 62.69291 88.62362 cm +1 0 0 1 62.69291 77.82362 cm q q 1 0 0 1 0 0 cm @@ -3525,11 +3532,11 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 84 re B* +n -6 -6 468.6898 252 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 65.71 Tm /F5 10 Tf 12 TL (Copyright \(c\) 2005, Michele Simionato) Tj T* (All rights reserved.) Tj T* T* (Redistributions of source code must retain the above copyright) Tj T* (notice, this list of conditions and the following disclaimer.) Tj T* (Redistributions in bytecode form must reproduce the above copyright) Tj T* ET +BT 1 0 0 1 0 230 Tm /F4 10 Tf 12 TL (Copyright \(c\) 2005, Michele Simionato) Tj T* (All rights reserved.) Tj T* T* (Redistributions of source code must retain the above copyright) Tj T* (notice, this list of conditions and the following disclaimer.) Tj T* (Redistributions in bytecode form must reproduce the above copyright) Tj T* (notice, this list of conditions and the following disclaimer in) Tj T* (the documentation and/or other materials provided with the) Tj T* (distribution.) Tj T* T* (THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS) Tj T* ("AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT) Tj T* (LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR) Tj T* (A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT) Tj T* (HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,) Tj T* (INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING,) Tj T* (BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS) Tj T* (OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND) Tj T* (ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR) Tj T* (TORT \(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT OF THE) Tj T* ET Q Q Q @@ -3537,16 +3544,15 @@ Q Q endstream - endobj -% 'R96': class PDFStream -96 0 obj +% 'R95': class PDFStream +95 0 obj % page stream -<< /Length 1630 >> +<< /Length 690 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 559.8236 cm +1 0 0 1 62.69291 727.8236 cm q q 1 0 0 1 0 0 cm @@ -3556,274 +3562,272 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 204 re B* +n -6 -6 468.6898 36 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 185.71 Tm /F5 10 Tf 12 TL (notice, this list of conditions and the following disclaimer in) Tj T* (the documentation and/or other materials provided with the) Tj T* (distribution.) Tj T* T* (THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS) Tj T* ("AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT) Tj T* (LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR) Tj T* (A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT) Tj T* (HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,) Tj T* (INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING,) Tj T* (BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS) Tj T* (OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND) Tj T* (ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR) Tj T* (TORT \(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT OF THE) Tj T* (USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH) Tj T* (DAMAGE.) Tj T* ET +BT 1 0 0 1 0 14 Tm /F4 10 Tf 12 TL (USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH) Tj T* (DAMAGE.) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 527.8236 cm +1 0 0 1 62.69291 695.8236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .407132 Tw (If you use this software and you are happy with it, consider sending me a note, just to gratify my ego. On) Tj T* 0 Tw (the other hand, if you use this software and you are unhappy with it, send me a patch!) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .407132 Tw (If you use this software and you are happy with it, consider sending me a note, just to gratify my ego. On) Tj T* 0 Tw (the other hand, if you use this software and you are unhappy with it, send me a patch!) Tj T* ET Q Q endstream - endobj -% 'R97': class PDFPageLabels -97 0 obj +% 'R96': class PDFPageLabels +96 0 obj % Document Root << /Nums [ 0 - 98 0 R + 97 0 R 1 - 99 0 R + 98 0 R 2 - 100 0 R + 99 0 R 3 - 101 0 R + 100 0 R 4 - 102 0 R + 101 0 R 5 - 103 0 R + 102 0 R 6 - 104 0 R + 103 0 R 7 - 105 0 R + 104 0 R 8 - 106 0 R + 105 0 R 9 - 107 0 R + 106 0 R 10 - 108 0 R + 107 0 R 11 - 109 0 R + 108 0 R 12 - 110 0 R + 109 0 R 13 - 111 0 R + 110 0 R 14 - 112 0 R ] >> + 111 0 R ] >> +endobj +% 'R97': class PDFPageLabel +97 0 obj +% None +<< /S /D + /St 1 >> endobj % 'R98': class PDFPageLabel 98 0 obj % None << /S /D - /St 1 >> + /St 2 >> endobj % 'R99': class PDFPageLabel 99 0 obj % None << /S /D - /St 2 >> + /St 3 >> endobj % 'R100': class PDFPageLabel 100 0 obj % None << /S /D - /St 3 >> + /St 4 >> endobj % 'R101': class PDFPageLabel 101 0 obj % None << /S /D - /St 4 >> + /St 5 >> endobj % 'R102': class PDFPageLabel 102 0 obj % None << /S /D - /St 5 >> + /St 6 >> endobj % 'R103': class PDFPageLabel 103 0 obj % None << /S /D - /St 6 >> + /St 7 >> endobj % 'R104': class PDFPageLabel 104 0 obj % None << /S /D - /St 7 >> + /St 8 >> endobj % 'R105': class PDFPageLabel 105 0 obj % None << /S /D - /St 8 >> + /St 9 >> endobj % 'R106': class PDFPageLabel 106 0 obj % None << /S /D - /St 9 >> + /St 10 >> endobj % 'R107': class PDFPageLabel 107 0 obj % None << /S /D - /St 10 >> + /St 11 >> endobj % 'R108': class PDFPageLabel 108 0 obj % None << /S /D - /St 11 >> + /St 12 >> endobj % 'R109': class PDFPageLabel 109 0 obj % None << /S /D - /St 12 >> + /St 13 >> endobj % 'R110': class PDFPageLabel 110 0 obj % None << /S /D - /St 13 >> + /St 14 >> endobj % 'R111': class PDFPageLabel 111 0 obj % None -<< /S /D - /St 14 >> -endobj -% 'R112': class PDFPageLabel -112 0 obj -% None << /S /D /St 15 >> endobj xref -0 113 +0 112 0000000000 65535 f 0000000113 00000 n -0000000283 00000 n -0000000448 00000 n -0000000623 00000 n +0000000271 00000 n +0000000436 00000 n +0000000611 00000 n 0000000794 00000 n -0000000975 00000 n -0000001227 00000 n -0000001476 00000 n -0000001650 00000 n -0000001891 00000 n -0000002133 00000 n -0000002375 00000 n -0000002617 00000 n -0000002859 00000 n -0000003101 00000 n -0000003344 00000 n -0000003587 00000 n -0000003830 00000 n -0000004073 00000 n -0000004315 00000 n -0000004557 00000 n -0000004800 00000 n -0000005043 00000 n -0000005286 00000 n -0000005529 00000 n -0000005772 00000 n -0000006015 00000 n -0000006258 00000 n -0000006501 00000 n -0000006744 00000 n -0000006987 00000 n -0000007230 00000 n -0000007473 00000 n -0000007716 00000 n -0000007959 00000 n -0000008202 00000 n -0000008429 00000 n -0000008990 00000 n -0000009185 00000 n -0000009441 00000 n -0000009632 00000 n -0000009892 00000 n -0000010202 00000 n -0000010482 00000 n -0000010762 00000 n -0000011042 00000 n -0000011322 00000 n -0000011602 00000 n -0000011882 00000 n -0000012177 00000 n -0000012432 00000 n -0000012700 00000 n -0000013011 00000 n -0000013292 00000 n -0000013587 00000 n -0000013832 00000 n -0000014148 00000 n -0000014406 00000 n -0000014658 00000 n -0000014898 00000 n -0000015158 00000 n -0000015465 00000 n -0000015803 00000 n -0000016084 00000 n -0000016243 00000 n -0000016492 00000 n -0000016618 00000 n -0000016791 00000 n -0000016978 00000 n -0000017178 00000 n -0000017366 00000 n -0000017559 00000 n -0000017758 00000 n -0000017942 00000 n -0000018123 00000 n -0000018322 00000 n -0000018522 00000 n -0000018734 00000 n -0000018934 00000 n -0000019130 00000 n -0000019282 00000 n -0000019517 00000 n -0000028721 00000 n -0000036458 00000 n -0000044610 00000 n -0000051869 00000 n -0000060799 00000 n -0000068075 00000 n -0000075065 00000 n -0000082434 00000 n -0000090723 00000 n -0000098130 00000 n -0000106120 00000 n -0000111225 00000 n -0000118852 00000 n -0000126124 00000 n -0000127859 00000 n -0000128152 00000 n -0000128229 00000 n -0000128307 00000 n -0000128386 00000 n -0000128465 00000 n -0000128544 00000 n -0000128623 00000 n -0000128702 00000 n -0000128781 00000 n -0000128860 00000 n -0000128940 00000 n -0000129020 00000 n -0000129100 00000 n -0000129180 00000 n -0000129260 00000 n +0000001046 00000 n +0000001295 00000 n +0000001469 00000 n +0000001710 00000 n +0000001951 00000 n +0000002193 00000 n +0000002435 00000 n +0000002677 00000 n +0000002919 00000 n +0000003162 00000 n +0000003405 00000 n +0000003648 00000 n +0000003891 00000 n +0000004133 00000 n +0000004375 00000 n +0000004618 00000 n +0000004861 00000 n +0000005104 00000 n +0000005347 00000 n +0000005590 00000 n +0000005833 00000 n +0000006076 00000 n +0000006319 00000 n +0000006562 00000 n +0000006805 00000 n +0000007048 00000 n +0000007291 00000 n +0000007534 00000 n +0000007777 00000 n +0000008020 00000 n +0000008247 00000 n +0000008807 00000 n +0000009002 00000 n +0000009271 00000 n +0000009531 00000 n +0000009843 00000 n +0000010019 00000 n +0000010299 00000 n +0000010579 00000 n +0000010859 00000 n +0000011139 00000 n +0000011419 00000 n +0000011714 00000 n +0000011954 00000 n +0000012270 00000 n +0000012538 00000 n +0000012840 00000 n +0000013135 00000 n +0000013380 00000 n +0000013682 00000 n +0000013977 00000 n +0000014235 00000 n +0000014487 00000 n +0000014727 00000 n +0000014987 00000 n +0000015294 00000 n +0000015632 00000 n +0000015913 00000 n +0000016072 00000 n +0000016357 00000 n +0000016483 00000 n +0000016656 00000 n +0000016843 00000 n +0000017043 00000 n +0000017231 00000 n +0000017424 00000 n +0000017623 00000 n +0000017807 00000 n +0000017988 00000 n +0000018187 00000 n +0000018387 00000 n +0000018599 00000 n +0000018799 00000 n +0000018995 00000 n +0000019147 00000 n +0000019382 00000 n +0000028641 00000 n +0000034896 00000 n +0000041786 00000 n +0000048644 00000 n +0000057376 00000 n +0000063301 00000 n +0000066974 00000 n +0000074661 00000 n +0000082151 00000 n +0000087589 00000 n +0000092055 00000 n +0000098289 00000 n +0000106380 00000 n +0000112490 00000 n +0000113282 00000 n +0000113574 00000 n +0000113651 00000 n +0000113728 00000 n +0000113806 00000 n +0000113885 00000 n +0000113964 00000 n +0000114043 00000 n +0000114122 00000 n +0000114201 00000 n +0000114280 00000 n +0000114360 00000 n +0000114440 00000 n +0000114520 00000 n +0000114600 00000 n +0000114680 00000 n trailer << /ID % ReportLab generated PDF document -- digest (http://www.reportlab.com) - [(\363Nq\342d\231;\362\233\230U\322\341\3541Q) (\363Nq\342d\231;\362\233\230U\322\341\3541Q)] + [(\312w\302.\333f\302\352&\222\237#[\341\226\343) (\312w\302.\333f\302\352&\222\237#[\341\226\343)] - /Info 65 0 R - /Root 64 0 R - /Size 113 >> + /Info 64 0 R + /Root 63 0 R + /Size 112 >> startxref -129309 +114729 %%EOF diff --git a/decorator/documentation3.html b/decorator/documentation3.html index 2110f8c..fce2187 100644 --- a/decorator/documentation3.html +++ b/decorator/documentation3.html @@ -83,10 +83,10 @@ E-mail:michele.simionato@gmail.com Version: -3.2.0 (2010-05-25) +3.2.1 (2010-11-28) Requires:Python 2.4+ -Download page:http://pypi.python.org/pypi/decorator/3.2.0 +Download page:http://pypi.python.org/pypi/decorator/3.2.1 Installation:easy_install decorator @@ -184,7 +184,7 @@ that depends on non-hashable arguments):

func.cache = {} def memoize(*args, **kw): if kw: # frozenset is used to ensure hashability - key = args, frozenset(kw.iteritems()) + key = args, frozenset(kw.iteritems()) else: key = args cache = func.cache @@ -211,7 +211,7 @@ general memoize_uw returns a function with a
>>> @memoize_uw
 ... def f1(x):
-...     time.sleep(1) # simulate some long computation
+...     time.sleep(1) # simulate some long computation
 ...     return x
 
@@ -232,10 +232,10 @@ pydoc will tell you that the function accepts a generic signature *args, **kw, but when you try to call the function with more than an argument, you will get an error:

-
>>> f1(0, 1)
+
>>> f1(0, 1)
 Traceback (most recent call last):
    ...
-TypeError: f1() takes exactly 1 positional argument (2 given)
+TypeError: f1() takes exactly 1 positional argument (2 given)
 
@@ -260,7 +260,7 @@ i.e. memoization in this case:

def _memoize(func, *args, **kw):
     if kw: # frozenset is used to ensure hashability
-        key = args, frozenset(kw.iteritems())
+        key = args, frozenset(kw.iteritems())
     else:
         key = args
     cache = func.cache # attributed added by memoize
@@ -289,7 +289,7 @@ decorate to the caller function.

>>> @memoize
 ... def heavy_computation():
-...     time.sleep(2)
+...     time.sleep(2)
 ...     return "done"
 
 >>> print(heavy_computation()) # the first time it will take 2 seconds
@@ -336,8 +336,8 @@ function is called:

It is immediate to verify that f1 works

-
>>> f1(0)
-calling f1 with args (0,), {}
+
>>> f1(0)
+calling f1 with args (0,), {}
 
@@ -351,14 +351,14 @@ function is called:

The same decorator works with functions of any signature:

>>> @trace
-... def f(x, y=1, z=2, *args, **kw):
+... def f(x, y=1, z=2, *args, **kw):
 ...     pass
 
->>> f(0, 3)
-calling f with args (0, 3, 2), {}
+>>> f(0, 3)
+calling f with args (0, 3, 2), {}
 
 >>> print(getargspec(f))
-ArgSpec(args=['x', 'y', 'z'], varargs='args', keywords='kw', defaults=(1, 2))
+ArgSpec(args=['x', 'y', 'z'], varargs='args', keywords='kw', defaults=(1, 2))
 
@@ -390,7 +390,7 @@ For instance, you can write directly

object which can be used as a decorator:

>>> trace
-<function trace at 0x...>
+<function trace at 0x...>
 
@@ -437,17 +437,17 @@ available. For instance:

>>> @blocking("Please wait ...")
 ... def read_data():
-...     time.sleep(3) # simulate a blocking resource
+...     time.sleep(3) # simulate a blocking resource
 ...     return "some data"
 
 >>> print(read_data()) # data is not available yet
 Please wait ...
 
->>> time.sleep(1)
+>>> time.sleep(1)
 >>> print(read_data()) # data is not available yet
 Please wait ...
 
->>> time.sleep(1)
+>>> time.sleep(1)
 >>> print(read_data()) # data is not available yet
 Please wait ...
 
@@ -512,7 +512,7 @@ The implementation is the following:

def __call__(self, func, on_success=on_success, on_failure=on_failure, on_closing=on_closing): # every decorated function has its own independent thread counter - func.counter = itertools.count(1) + func.counter = itertools.count(1) func.on_success = on_success func.on_failure = on_failure func.on_closing = on_closing @@ -528,7 +528,7 @@ The implementation is the following:

return func.on_success(result) finally: func.on_closing() - name = '%s-%s' % (func.__name__, next(func.counter)) + name = '%s-%s' % (func.__name__, next(func.counter)) thread = self.threadfactory(None, func_wrapper, name) thread.start() return thread @@ -551,7 +551,7 @@ be locked. Here is a minimalistic example:

... def write(data): ... # append data to the datalist by locking ... with threading.Lock(): -... time.sleep(1) # emulate some long running operation +... time.sleep(1) # emulate some long running operation ... datalist.append(data) ... # other operations not requiring a lock here
@@ -561,14 +561,14 @@ be locked. Here is a minimalistic example:

be no synchronization problems since write is locked.

>>> write("data1")
-<Thread(write-1, started...)>
+<Thread(write-1, started...)>
 
->>> time.sleep(.1) # wait a bit, so we are sure data2 is written after data1
+>>> time.sleep(.1) # wait a bit, so we are sure data2 is written after data1
 
 >>> write("data2")
-<Thread(write-2, started...)>
+<Thread(write-2, started...)>
 
->>> time.sleep(2) # wait for the writers to complete
+>>> time.sleep(2) # wait for the writers to complete
 
 >>> print(datalist)
 ['data1', 'data2']
@@ -595,8 +595,8 @@ were the function is generated by exec. Here i
 ...     print(args, kw)
 
 >>> f1 = FunctionMaker.create('f1(a, b)', 'f(a, b)', dict(f=f))
->>> f1(1,2)
-(1, 2) {}
+>>> f1(1,2)
+(1, 2) {}
 
@@ -679,7 +679,7 @@ source code which is probably not what you want:

(see bug report 1764286 for an explanation of what is happening). -Unfortunately the bug is still there, even in Python 2.6 and 3.0. +Unfortunately the bug is still there, even in Python 2.7 and 3.1. There is however a workaround. The decorator module adds an attribute .undecorated to the decorated function, containing a reference to the original function. The easy way to get @@ -688,10 +688,10 @@ undecorated function:

>>> print(inspect.getsource(factorial.undecorated))
 @tail_recursive
-def factorial(n, acc=1):
+def factorial(n, acc=1):
     "The good old factorial"
-    if n == 0: return acc
-    return factorial(n-1, n*acc)
+    if n == 0: return acc
+    return factorial(n-1, n*acc)
 <BLANKLINE>
 
@@ -774,16 +774,16 @@ objects.

Here is how you apply the upgraded decorator to the good old factorial:

@tail_recursive
-def factorial(n, acc=1):
+def factorial(n, acc=1):
     "The good old factorial"
-    if n == 0: return acc
-    return factorial(n-1, n*acc)
+    if n == 0: return acc
+    return factorial(n-1, n*acc)
 
-
>>> print(factorial(4))
-24
+
>>> print(factorial(4))
+24
 
@@ -794,8 +794,8 @@ frame. Notice also that the decorator will not work on functions which are not tail recursive, such as the following

def fact(n): # this is not tail-recursive
-    if n == 0: return 1
-    return n * fact(n-1)
+    if n == 0: return 1
+    return n * fact(n-1)
 
@@ -844,7 +844,7 @@ longer and more difficult to understand. Consider this example:

>>> @trace
 ... def f():
-...     1/0
+...     1/0
 
@@ -854,11 +854,11 @@ function is decorated the traceback will be longer:

>>> f()
 Traceback (most recent call last):
   ...
-     File "<string>", line 2, in f
-     File "<doctest __main__[22]>", line 4, in trace
+     File "<string>", line 2, in f
+     File "<doctest __main__[22]>", line 4, in trace
        return f(*args, **kw)
-     File "<doctest __main__[51]>", line 3, in f
-       1/0
+     File "<doctest __main__[51]>", line 3, in f
+       1/0
 ZeroDivisionError: int division or modulo by zero
 
diff --git a/decorator/documentation3.pdf b/decorator/documentation3.pdf index 14b4ee2..4428d24 100644 --- a/decorator/documentation3.pdf +++ b/decorator/documentation3.pdf @@ -1,4 +1,4 @@ -%PDF-1.3 +%PDF-1.4 %“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com % 'BasicFonts': class PDFDictionary 1 0 obj @@ -6,10 +6,9 @@ << /F1 2 0 R /F2 3 0 R /F3 4 0 R - /F4 5 0 R - /F5 8 0 R - /F6 38 0 R - /F7 40 0 R >> + /F4 7 0 R + /F5 37 0 R + /F6 39 0 R >> endobj % 'F1': class PDFType1Font 2 0 obj @@ -38,17 +37,8 @@ endobj /Subtype /Type1 /Type /Font >> endobj -% 'F4': class PDFType1Font -5 0 obj -% Font Times-Roman -<< /BaseFont /Times-Roman - /Encoding /WinAnsiEncoding - /Name /F4 - /Subtype /Type1 - /Type /Font >> -endobj % 'Annot.NUMBER1': class PDFDictionary -6 0 obj +5 0 obj << /A << /S /URI /Type /Action /URI (mailto:michele.simionato@gmail.com) >> @@ -56,545 +46,546 @@ endobj 0 0 ] /Rect [ 153.7323 - 707.5936 - 526.5827 - 719.5936 ] + 704.7736 + 289.4623 + 716.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER2': class PDFDictionary -7 0 obj +6 0 obj << /A << /S /URI /Type /Action - /URI (http://pypi.python.org/pypi/decorator/3.2.0) >> + /URI (http://pypi.python.org/pypi/decorator/3.2.1) >> /Border [ 0 0 0 ] /Rect [ 153.7323 - 662.5936 + 659.7736 526.5827 - 674.5936 ] + 671.7736 ] /Subtype /Link /Type /Annot >> endobj -% 'F5': class PDFType1Font -8 0 obj +% 'F4': class PDFType1Font +7 0 obj % Font Courier << /BaseFont /Courier /Encoding /WinAnsiEncoding - /Name /F5 + /Name /F4 /Subtype /Type1 /Type /Font >> endobj % 'Annot.NUMBER3': class LinkAnnotation -9 0 obj +8 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 37 0 R + /Dest [ 36 0 R /XYZ 62.69291 311.0236 0 ] /Rect [ 62.69291 - 563.5936 + 560.7736 121.0229 - 575.5936 ] + 572.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER4': class LinkAnnotation -10 0 obj +9 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 37 0 R + /Dest [ 36 0 R /XYZ 62.69291 311.0236 0 ] /Rect [ 527.0227 - 563.5936 + 560.7736 532.5827 - 575.5936 ] + 572.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER5': class LinkAnnotation -11 0 obj +10 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 41 0 R /XYZ 62.69291 - 675.0236 + 699.0236 0 ] /Rect [ 62.69291 - 545.5936 + 542.7736 114.3629 - 557.5936 ] + 554.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER6': class LinkAnnotation -12 0 obj +11 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 41 0 R /XYZ 62.69291 - 675.0236 + 699.0236 0 ] /Rect [ 527.0227 - 545.5936 + 542.7736 532.5827 - 557.5936 ] + 554.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER7': class LinkAnnotation -13 0 obj +12 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 41 0 R /XYZ 62.69291 - 432.0236 + 462.0236 0 ] /Rect [ 62.69291 - 527.5936 + 524.7736 183.2629 - 539.5936 ] + 536.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER8': class LinkAnnotation -14 0 obj +13 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 42 0 R + /Dest [ 41 0 R /XYZ 62.69291 - 432.0236 + 462.0236 0 ] /Rect [ 527.0227 - 527.5936 + 524.7736 532.5827 - 539.5936 ] + 536.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER9': class LinkAnnotation -15 0 obj +14 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 43 0 R + /Dest [ 42 0 R /XYZ 62.69291 - 427.4236 + 451.4236 0 ] /Rect [ 62.69291 - 509.5936 + 506.7736 122.1429 - 521.5936 ] + 518.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER10': class LinkAnnotation -16 0 obj +15 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 43 0 R + /Dest [ 42 0 R /XYZ 62.69291 - 427.4236 + 451.4236 0 ] /Rect [ 527.0227 - 509.5936 + 506.7736 532.5827 - 521.5936 ] + 518.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER11': class LinkAnnotation -17 0 obj +16 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 44 0 R + /Dest [ 43 0 R /XYZ 62.69291 - 435.4236 + 459.4236 0 ] /Rect [ 62.69291 - 491.5936 + 488.7736 154.8129 - 503.5936 ] + 500.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER12': class LinkAnnotation -18 0 obj +17 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 44 0 R + /Dest [ 43 0 R /XYZ 62.69291 - 435.4236 + 459.4236 0 ] /Rect [ 527.0227 - 491.5936 + 488.7736 532.5827 - 503.5936 ] + 500.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER13': class LinkAnnotation -19 0 obj +18 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 45 0 R + /Dest [ 44 0 R /XYZ 62.69291 - 567.978 + 633.178 0 ] /Rect [ 62.69291 - 473.5936 + 470.7736 188.2729 - 485.5936 ] + 482.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER14': class LinkAnnotation -20 0 obj +19 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 45 0 R + /Dest [ 44 0 R /XYZ 62.69291 - 567.978 + 633.178 0 ] /Rect [ 527.0227 - 473.5936 + 470.7736 532.5827 - 485.5936 ] + 482.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER15': class LinkAnnotation -21 0 obj +20 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 45 0 R + /Dest [ 44 0 R /XYZ 62.69291 - 153.378 + 218.578 0 ] /Rect [ 62.69291 - 455.5936 + 452.7736 110.6929 - 467.5936 ] + 464.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER16': class LinkAnnotation -22 0 obj +21 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 45 0 R + /Dest [ 44 0 R /XYZ 62.69291 - 153.378 + 218.578 0 ] /Rect [ 527.0227 - 455.5936 + 452.7736 532.5827 - 467.5936 ] + 464.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER17': class LinkAnnotation -23 0 obj +22 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 46 0 R + /Dest [ 45 0 R /XYZ 62.69291 - 302.6236 + 350.6236 0 ] /Rect [ 62.69291 - 437.5936 + 434.7736 92.69291 - 449.5936 ] + 446.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER18': class LinkAnnotation -24 0 obj +23 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 46 0 R + /Dest [ 45 0 R /XYZ 62.69291 - 302.6236 + 350.6236 0 ] /Rect [ 527.0227 - 437.5936 + 434.7736 532.5827 - 449.5936 ] + 446.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER19': class LinkAnnotation -25 0 obj +24 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 48 0 R + /Dest [ 47 0 R /XYZ 62.69291 - 446.6236 + 506.6236 0 ] /Rect [ 62.69291 - 419.5936 + 416.7736 192.2729 - 431.5936 ] + 428.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER20': class LinkAnnotation -26 0 obj +25 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 48 0 R + /Dest [ 47 0 R /XYZ 62.69291 - 446.6236 + 506.6236 0 ] /Rect [ 527.0227 - 419.5936 + 416.7736 532.5827 - 431.5936 ] + 428.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER21': class LinkAnnotation -27 0 obj +26 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 50 0 R + /Dest [ 49 0 R /XYZ 62.69291 - 449.8236 + 509.8236 0 ] /Rect [ 62.69291 - 401.5936 + 398.7736 177.1629 - 413.5936 ] + 410.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER22': class LinkAnnotation -28 0 obj +27 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 50 0 R + /Dest [ 49 0 R /XYZ 62.69291 - 449.8236 + 509.8236 0 ] /Rect [ 527.0227 - 401.5936 + 398.7736 532.5827 - 413.5936 ] + 410.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER23': class LinkAnnotation -29 0 obj +28 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 52 0 R + /Dest [ 51 0 R /XYZ 62.69291 - 655.8236 + 727.8236 0 ] /Rect [ 62.69291 - 383.5936 + 380.7736 228.2829 - 395.5936 ] + 392.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER24': class LinkAnnotation -30 0 obj +29 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 52 0 R + /Dest [ 51 0 R /XYZ 62.69291 - 655.8236 + 727.8236 0 ] /Rect [ 521.4627 - 383.5936 + 380.7736 532.5827 - 395.5936 ] + 392.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER25': class LinkAnnotation -31 0 obj +30 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 53 0 R + /Dest [ 52 0 R /XYZ 62.69291 - 263.0236 + 335.0236 0 ] /Rect [ 62.69291 - 365.5936 + 362.7736 174.3929 - 377.5936 ] + 374.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER26': class LinkAnnotation -32 0 obj +31 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 53 0 R + /Dest [ 52 0 R /XYZ 62.69291 - 263.0236 + 335.0236 0 ] /Rect [ 521.4627 - 365.5936 + 362.7736 532.5827 - 377.5936 ] + 374.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER27': class LinkAnnotation -33 0 obj +32 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 61 0 R + /Dest [ 60 0 R /XYZ 62.69291 - 426.6236 + 482.6236 0 ] /Rect [ 62.69291 - 347.5936 + 344.7736 155.4829 - 359.5936 ] + 356.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER28': class LinkAnnotation -34 0 obj +33 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 61 0 R + /Dest [ 60 0 R /XYZ 62.69291 - 426.6236 + 482.6236 0 ] /Rect [ 521.4627 - 347.5936 + 344.7736 532.5827 - 359.5936 ] + 356.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER29': class LinkAnnotation -35 0 obj +34 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 62 0 R + /Dest [ 61 0 R /XYZ 62.69291 - 729.0236 + 765.0236 0 ] /Rect [ 62.69291 - 329.5936 + 326.7736 106.5829 - 341.5936 ] + 338.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER30': class LinkAnnotation -36 0 obj +35 0 obj << /Border [ 0 0 0 ] /Contents () - /Dest [ 62 0 R + /Dest [ 61 0 R /XYZ 62.69291 - 729.0236 + 765.0236 0 ] /Rect [ 521.4627 - 329.5936 + 326.7736 532.5827 - 341.5936 ] + 338.7736 ] /Subtype /Link /Type /Annot >> endobj % 'Page1': class PDFPage -37 0 obj +36 0 obj % Page dictionary -<< /Annots [ 6 0 R - 7 0 R +<< /Annots [ 5 0 R + 6 0 R + 8 0 R 9 0 R 10 0 R 11 0 R @@ -621,14 +612,13 @@ endobj 32 0 R 33 0 R 34 0 R - 35 0 R - 36 0 R ] - /Contents 81 0 R + 35 0 R ] + /Contents 80 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -639,17 +629,17 @@ endobj /Trans << >> /Type /Page >> endobj -% 'F6': class PDFType1Font -38 0 obj +% 'F5': class PDFType1Font +37 0 obj % Font Helvetica-Oblique << /BaseFont /Helvetica-Oblique /Encoding /WinAnsiEncoding - /Name /F6 + /Name /F5 /Subtype /Type1 /Type /Font >> endobj % 'Annot.NUMBER31': class PDFDictionary -39 0 obj +38 0 obj << /A << /S /URI /Type /Action /URI (http://www.python.org/moin/PythonDecoratorLibrary) >> @@ -657,23 +647,23 @@ endobj 0 0 ] /Rect [ 219.6428 - 360.5936 + 387.7736 449.1728 - 372.5936 ] + 399.7736 ] /Subtype /Link /Type /Annot >> endobj -% 'F7': class PDFType1Font -40 0 obj +% 'F6': class PDFType1Font +39 0 obj % Font Courier-Oblique << /BaseFont /Courier-Oblique /Encoding /WinAnsiEncoding - /Name /F7 + /Name /F6 /Subtype /Type1 /Type /Font >> endobj % 'Annot.NUMBER32': class PDFDictionary -41 0 obj +40 0 obj << /A << /S /URI /Type /Action /URI (http://www.python.org/doc/2.5.2/lib/module-functools.html) >> @@ -681,23 +671,23 @@ endobj 0 0 ] /Rect [ 151.0486 - 127.3936 + 154.5736 270.69 - 139.3936 ] + 166.5736 ] /Subtype /Link /Type /Annot >> endobj % 'Page2': class PDFPage -42 0 obj +41 0 obj % Page dictionary -<< /Annots [ 39 0 R - 41 0 R ] - /Contents 82 0 R +<< /Annots [ 38 0 R + 40 0 R ] + /Contents 81 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -709,14 +699,14 @@ endobj /Type /Page >> endobj % 'Page3': class PDFPage -43 0 obj +42 0 obj % Page dictionary -<< /Contents 83 0 R +<< /Contents 82 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -728,14 +718,14 @@ endobj /Type /Page >> endobj % 'Page4': class PDFPage -44 0 obj +43 0 obj % Page dictionary -<< /Contents 84 0 R +<< /Contents 83 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -747,14 +737,14 @@ endobj /Type /Page >> endobj % 'Page5': class PDFPage -45 0 obj +44 0 obj % Page dictionary -<< /Contents 85 0 R +<< /Contents 84 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -766,14 +756,14 @@ endobj /Type /Page >> endobj % 'Page6': class PDFPage -46 0 obj +45 0 obj % Page dictionary -<< /Contents 86 0 R +<< /Contents 85 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -785,14 +775,14 @@ endobj /Type /Page >> endobj % 'Page7': class PDFPage -47 0 obj +46 0 obj % Page dictionary -<< /Contents 87 0 R +<< /Contents 86 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -804,14 +794,14 @@ endobj /Type /Page >> endobj % 'Page8': class PDFPage -48 0 obj +47 0 obj % Page dictionary -<< /Contents 88 0 R +<< /Contents 87 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -823,7 +813,7 @@ endobj /Type /Page >> endobj % 'Annot.NUMBER33': class PDFDictionary -49 0 obj +48 0 obj << /A << /S /URI /Type /Action /URI (http://bugs.python.org/issue1764286) >> @@ -831,22 +821,22 @@ endobj 0 0 ] /Rect [ 137.6966 - 159.9936 + 217.1736 180.8679 - 171.9936 ] + 229.1736 ] /Subtype /Link /Type /Annot >> endobj % 'Page9': class PDFPage -50 0 obj +49 0 obj % Page dictionary -<< /Annots [ 49 0 R ] - /Contents 89 0 R +<< /Annots [ 48 0 R ] + /Contents 88 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -858,7 +848,7 @@ endobj /Type /Page >> endobj % 'Annot.NUMBER34': class PDFDictionary -51 0 obj +50 0 obj << /A << /S /URI /Type /Action /URI (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) >> @@ -866,22 +856,22 @@ endobj 0 0 ] /Rect [ 62.69291 - 339.1936 + 408.3736 363.4029 - 351.1936 ] + 420.3736 ] /Subtype /Link /Type /Annot >> endobj % 'Page10': class PDFPage -52 0 obj +51 0 obj % Page dictionary -<< /Annots [ 51 0 R ] - /Contents 90 0 R +<< /Annots [ 50 0 R ] + /Contents 89 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -893,14 +883,14 @@ endobj /Type /Page >> endobj % 'Page11': class PDFPage -53 0 obj +52 0 obj % Page dictionary -<< /Contents 91 0 R +<< /Contents 90 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -912,7 +902,7 @@ endobj /Type /Page >> endobj % 'Annot.NUMBER35': class PDFDictionary -54 0 obj +53 0 obj << /A << /S /URI /Type /Action /URI (http://www.python.org/dev/peps/pep-0362) >> @@ -920,22 +910,22 @@ endobj 0 0 ] /Rect [ 301.1597 - 167.7936 + 236.9736 317.8397 - 179.7936 ] + 248.9736 ] /Subtype /Link /Type /Annot >> endobj % 'Page12': class PDFPage -55 0 obj +54 0 obj % Page dictionary -<< /Annots [ 54 0 R ] - /Contents 92 0 R +<< /Annots [ 53 0 R ] + /Contents 91 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -947,7 +937,7 @@ endobj /Type /Page >> endobj % 'Annot.NUMBER36': class PDFDictionary -56 0 obj +55 0 obj << /A << /S /URI /Type /Action /URI (http://packages.python.org/distribute/) >> @@ -955,14 +945,14 @@ endobj 0 0 ] /Rect [ 286.1685 - 367.1936 + 420.3736 329.8913 - 379.1936 ] + 432.3736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER37': class PDFDictionary -57 0 obj +56 0 obj << /A << /S /URI /Type /Action /URI (http://docutils.sourceforge.net/) >> @@ -970,14 +960,14 @@ endobj 0 0 ] /Rect [ 188.8729 - 343.1936 + 396.3736 225.5529 - 355.1936 ] + 408.3736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER38': class PDFDictionary -58 0 obj +57 0 obj << /A << /S /URI /Type /Action /URI (http://pygments.org/) >> @@ -985,14 +975,14 @@ endobj 0 0 ] /Rect [ 245.0129 - 343.1936 + 396.3736 291.1429 - 355.1936 ] + 408.3736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER39': class PDFDictionary -59 0 obj +58 0 obj << /A << /S /URI /Type /Action /URI (http://www.python.org/dev/peps/pep-3107/) >> @@ -1000,14 +990,14 @@ endobj 0 0 ] /Rect [ 62.69291 - 211.1936 + 264.3736 157.3009 - 223.1936 ] + 276.3736 ] /Subtype /Link /Type /Annot >> endobj % 'Annot.NUMBER40': class PDFDictionary -60 0 obj +59 0 obj << /A << /S /URI /Type /Action /URI (http://www.phyast.pitt.edu/~micheles/python/documentation.html#class-decorators-and-decorator-factories) >> @@ -1015,26 +1005,26 @@ endobj 0 0 ] /Rect [ 364.2921 - 181.1936 + 234.3736 531.64 - 193.1936 ] + 246.3736 ] /Subtype /Link /Type /Annot >> endobj % 'Page13': class PDFPage -61 0 obj +60 0 obj % Page dictionary -<< /Annots [ 56 0 R +<< /Annots [ 55 0 R + 56 0 R 57 0 R 58 0 R - 59 0 R - 60 0 R ] - /Contents 93 0 R + 59 0 R ] + /Contents 92 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -1046,14 +1036,14 @@ endobj /Type /Page >> endobj % 'Page14': class PDFPage -62 0 obj +61 0 obj % Page dictionary -<< /Contents 94 0 R +<< /Contents 93 0 R /MediaBox [ 0 0 595.2756 841.8898 ] - /Parent 80 0 R + /Parent 79 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text @@ -1064,245 +1054,246 @@ endobj /Trans << >> /Type /Page >> endobj -% 'R63': class PDFCatalog -63 0 obj +% 'R62': class PDFCatalog +62 0 obj % Document Root -<< /Outlines 65 0 R - /PageLabels 95 0 R +<< /Outlines 64 0 R + /PageLabels 94 0 R /PageMode /UseNone - /Pages 80 0 R + /Pages 79 0 R /Type /Catalog >> endobj -% 'R64': class PDFInfo -64 0 obj +% 'R63': class PDFInfo +63 0 obj << /Author (Michele Simionato) - /CreationDate (D:20100525055112-01'00') + /CreationDate (D:20101128103409-01'00') + /Creator (\(unspecified\)) /Keywords () - /Producer (ReportLab http://www.reportlab.com) + /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (\(unspecified\)) /Title (The decorator module) >> endobj -% 'R65': class PDFOutlines -65 0 obj +% 'R64': class PDFOutlines +64 0 obj << /Count 14 - /First 66 0 R - /Last 79 0 R + /First 65 0 R + /Last 78 0 R /Type /Outlines >> endobj % 'Outline.0': class OutlineEntryObject -66 0 obj -<< /Dest [ 37 0 R +65 0 obj +<< /Dest [ 36 0 R /XYZ 62.69291 311.0236 0 ] - /Next 67 0 R - /Parent 65 0 R + /Next 66 0 R + /Parent 64 0 R /Title (Introduction) >> endobj % 'Outline.1': class OutlineEntryObject +66 0 obj +<< /Dest [ 41 0 R + /XYZ + 62.69291 + 699.0236 + 0 ] + /Next 67 0 R + /Parent 64 0 R + /Prev 65 0 R + /Title (Definitions) >> +endobj +% 'Outline.2': class OutlineEntryObject 67 0 obj -<< /Dest [ 42 0 R +<< /Dest [ 41 0 R /XYZ 62.69291 - 675.0236 + 462.0236 0 ] /Next 68 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 66 0 R - /Title (Definitions) >> + /Title (Statement of the problem) >> endobj -% 'Outline.2': class OutlineEntryObject +% 'Outline.3': class OutlineEntryObject 68 0 obj << /Dest [ 42 0 R /XYZ 62.69291 - 432.0236 + 451.4236 0 ] /Next 69 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 67 0 R - /Title (Statement of the problem) >> + /Title (The solution) >> endobj -% 'Outline.3': class OutlineEntryObject +% 'Outline.4': class OutlineEntryObject 69 0 obj << /Dest [ 43 0 R /XYZ 62.69291 - 427.4236 + 459.4236 0 ] /Next 70 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 68 0 R - /Title (The solution) >> + /Title (A trace decorator) >> endobj -% 'Outline.4': class OutlineEntryObject +% 'Outline.5': class OutlineEntryObject 70 0 obj << /Dest [ 44 0 R /XYZ 62.69291 - 435.4236 + 633.178 0 ] /Next 71 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 69 0 R - /Title (A trace decorator) >> + /Title (decorator is a decorator) >> endobj -% 'Outline.5': class OutlineEntryObject +% 'Outline.6': class OutlineEntryObject 71 0 obj -<< /Dest [ 45 0 R +<< /Dest [ 44 0 R /XYZ 62.69291 - 567.978 + 218.578 0 ] /Next 72 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 70 0 R - /Title (decorator is a decorator) >> + /Title (blocking) >> endobj -% 'Outline.6': class OutlineEntryObject +% 'Outline.7': class OutlineEntryObject 72 0 obj << /Dest [ 45 0 R /XYZ 62.69291 - 153.378 + 350.6236 0 ] /Next 73 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 71 0 R - /Title (blocking) >> + /Title (async) >> endobj -% 'Outline.7': class OutlineEntryObject +% 'Outline.8': class OutlineEntryObject 73 0 obj -<< /Dest [ 46 0 R +<< /Dest [ 47 0 R /XYZ 62.69291 - 302.6236 + 506.6236 0 ] /Next 74 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 72 0 R - /Title (async) >> + /Title (The FunctionMaker class) >> endobj -% 'Outline.8': class OutlineEntryObject +% 'Outline.9': class OutlineEntryObject 74 0 obj -<< /Dest [ 48 0 R +<< /Dest [ 49 0 R /XYZ 62.69291 - 446.6236 + 509.8236 0 ] /Next 75 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 73 0 R - /Title (The FunctionMaker class) >> + /Title (Getting the source code) >> endobj -% 'Outline.9': class OutlineEntryObject +% 'Outline.10': class OutlineEntryObject 75 0 obj -<< /Dest [ 50 0 R +<< /Dest [ 51 0 R /XYZ 62.69291 - 449.8236 + 727.8236 0 ] /Next 76 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 74 0 R - /Title (Getting the source code) >> + /Title (Dealing with third party decorators) >> endobj -% 'Outline.10': class OutlineEntryObject +% 'Outline.11': class OutlineEntryObject 76 0 obj << /Dest [ 52 0 R /XYZ 62.69291 - 655.8236 + 335.0236 0 ] /Next 77 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 75 0 R - /Title (Dealing with third party decorators) >> + /Title (Caveats and limitations) >> endobj -% 'Outline.11': class OutlineEntryObject +% 'Outline.12': class OutlineEntryObject 77 0 obj -<< /Dest [ 53 0 R +<< /Dest [ 60 0 R /XYZ 62.69291 - 263.0236 + 482.6236 0 ] /Next 78 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 76 0 R - /Title (Caveats and limitations) >> + /Title (Compatibility notes) >> endobj -% 'Outline.12': class OutlineEntryObject +% 'Outline.13': class OutlineEntryObject 78 0 obj << /Dest [ 61 0 R /XYZ 62.69291 - 426.6236 + 765.0236 0 ] - /Next 79 0 R - /Parent 65 0 R + /Parent 64 0 R /Prev 77 0 R - /Title (Compatibility notes) >> -endobj -% 'Outline.13': class OutlineEntryObject -79 0 obj -<< /Dest [ 62 0 R - /XYZ - 62.69291 - 729.0236 - 0 ] - /Parent 65 0 R - /Prev 78 0 R /Title (LICENCE) >> endobj -% 'R80': class PDFPages -80 0 obj +% 'R79': class PDFPages +79 0 obj % page tree << /Count 14 - /Kids [ 37 0 R + /Kids [ 36 0 R + 41 0 R 42 0 R 43 0 R 44 0 R 45 0 R 46 0 R 47 0 R - 48 0 R - 50 0 R + 49 0 R + 51 0 R 52 0 R - 53 0 R - 55 0 R - 61 0 R - 62 0 R ] + 54 0 R + 60 0 R + 61 0 R ] /Type /Pages >> endobj -% 'R81': class PDFStream -81 0 obj +% 'R80': class PDFStream +80 0 obj % page stream -<< /Length 9103 >> +<< /Length 9160 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q 1 0 0 1 62.69291 741.0236 cm q -BT 1 0 0 1 0 9.64 Tm 118.8249 0 Td 24 TL /F2 20 Tf 0 0 0 rg (The ) Tj /F3 20 Tf (decorator ) Tj /F2 20 Tf (module) Tj T* -118.8249 0 Td ET +BT 1 0 0 1 0 4 Tm 118.8249 0 Td 24 TL /F2 20 Tf 0 0 0 rg (The ) Tj /F3 20 Tf (decorator ) Tj /F2 20 Tf (module) Tj T* -118.8249 0 Td ET Q Q q 1 0 0 1 62.69291 716.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 36.93937 0 Td (Author:) Tj T* -36.93937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 36.93937 0 Td (Author:) Tj T* -36.93937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Michele Simionato) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Michele Simionato) Tj T* ET Q Q q @@ -1311,20 +1302,18 @@ Q q 1 0 0 1 62.69291 701.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 39.69937 0 Td (E-mail:) Tj T* -39.69937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 39.69937 0 Td (E-mail:) Tj T* -39.69937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q -0 0 .501961 rg -0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (michele.simionato@gmail.com) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 .501961 rg (michele.simionato@gmail.com) Tj T* ET Q Q q @@ -1333,19 +1322,19 @@ Q q 1 0 0 1 62.69291 686.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 33.02937 0 Td (Version:) Tj T* -33.02937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 33.02937 0 Td (Version:) Tj T* -33.02937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (3.2.0 \(2010-05-25\)) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (3.2.1 \(2010-11-28\)) Tj T* ET Q Q q @@ -1354,19 +1343,19 @@ Q q 1 0 0 1 62.69291 671.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 26.91937 0 Td (Requires:) Tj T* -26.91937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 26.91937 0 Td (Requires:) Tj T* -26.91937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Python 2.4+) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Python 2.4+) Tj T* ET Q Q q @@ -1375,12 +1364,12 @@ Q q 1 0 0 1 62.69291 644.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F2 10 Tf 12 TL 25.25937 0 Td (Download) Tj T* 21.11 0 Td (page:) Tj T* -46.36937 0 Td ET +BT 1 0 0 1 0 14 Tm /F2 10 Tf 12 TL 25.25937 0 Td (Download) Tj T* 21.11 0 Td (page:) Tj T* -46.36937 0 Td ET Q Q q @@ -1388,7 +1377,7 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (http://pypi.python.org/pypi/decorator/3.2.0) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (http://pypi.python.org/pypi/decorator/3.2.1) Tj T* ET Q Q q @@ -1397,19 +1386,19 @@ Q q 1 0 0 1 62.69291 629.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 16.91937 0 Td (Installation:) Tj T* -16.91937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 16.91937 0 Td (Installation:) Tj T* -16.91937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 5.71 Tm /F5 10 Tf 12 TL (easy_install decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm /F4 10 Tf 12 TL (easy_install decorator) Tj T* ET Q Q q @@ -1418,19 +1407,19 @@ Q q 1 0 0 1 62.69291 614.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 6 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 32.46937 0 Td (License:) Tj T* -32.46937 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 32.46937 0 Td (License:) Tj T* -32.46937 0 Td ET Q Q q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (BSD license) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (BSD license) Tj T* ET Q Q q @@ -1439,17 +1428,17 @@ Q q 1 0 0 1 62.69291 581.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Contents) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Contents) Tj T* ET Q Q q 1 0 0 1 62.69291 323.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q 1 0 0 1 0 237 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Introduction) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Introduction) Tj T* ET Q Q q @@ -1457,13 +1446,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (1) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (1) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 219 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Definitions) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Definitions) Tj T* ET Q Q q @@ -1471,13 +1460,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 201 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Statement of the problem) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Statement of the problem) Tj T* ET Q Q q @@ -1485,13 +1474,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (2) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 183 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The solution) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The solution) Tj T* ET Q Q q @@ -1499,13 +1488,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (3) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (3) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 165 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (A ) Tj /F3 10 Tf (trace ) Tj /F2 10 Tf (decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (A ) Tj /F3 10 Tf (trace ) Tj /F2 10 Tf (decorator) Tj T* ET Q Q q @@ -1513,13 +1502,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (4) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (4) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 147 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (decorator ) Tj /F2 10 Tf (is a decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (decorator ) Tj /F2 10 Tf (is a decorator) Tj T* ET Q Q q @@ -1527,13 +1516,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (5) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (5) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 129 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (blocking) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (blocking) Tj T* ET Q Q q @@ -1541,13 +1530,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (5) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (5) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 111 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (async) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F3 10 Tf 0 0 .501961 rg (async) Tj T* ET Q Q q @@ -1555,13 +1544,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (6) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (6) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 93 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The ) Tj /F3 10 Tf (FunctionMaker ) Tj /F2 10 Tf (class) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (The ) Tj /F3 10 Tf (FunctionMaker ) Tj /F2 10 Tf (class) Tj T* ET Q Q q @@ -1569,13 +1558,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (8) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (8) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 75 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Getting the source code) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Getting the source code) Tj T* ET Q Q q @@ -1583,13 +1572,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 66.44 0 Td (9) Tj T* -66.44 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 66.44 0 Td (9) Tj T* -66.44 0 Td ET Q Q q 1 0 0 1 0 57 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Dealing with third party decorators) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Dealing with third party decorators) Tj T* ET Q Q q @@ -1597,13 +1586,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (10) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (10) Tj T* -60.88 0 Td ET Q Q q 1 0 0 1 0 39 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Caveats and limitations) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Caveats and limitations) Tj T* ET Q Q q @@ -1611,13 +1600,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (11) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (11) Tj T* -60.88 0 Td ET Q Q q 1 0 0 1 0 21 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Compatibility notes) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (Compatibility notes) Tj T* ET Q Q q @@ -1625,13 +1614,13 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (13) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (13) Tj T* -60.88 0 Td ET Q Q q 1 0 0 1 0 3 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (LICENCE) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F2 10 Tf 0 0 .501961 rg (LICENCE) Tj T* ET Q Q q @@ -1639,7 +1628,7 @@ q q 0 0 .501961 rg 0 0 .501961 RG -BT 1 0 0 1 0 4.82 Tm /F2 10 Tf 12 TL 60.88 0 Td (14) Tj T* -60.88 0 Td ET +BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (14) Tj T* -60.88 0 Td ET Q Q q @@ -1648,14 +1637,14 @@ Q q 1 0 0 1 62.69291 290.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Introduction) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Introduction) Tj T* ET Q Q q 1 0 0 1 62.69291 224.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 52.82 Tm /F1 10 Tf 12 TL 3.995366 Tw (Python decorators are an interesting example of why syntactic sugar matters. In principle, their) Tj T* 0 Tw .151235 Tw (introduction in Python 2.4 changed nothing, since they do not provide any new functionality which was not) Tj T* 0 Tw 2.238555 Tw (already present in the language. In practice, their introduction has significantly changed the way we) Tj T* 0 Tw .098409 Tw (structure our programs in Python. I believe the change is for the best, and that decorators are a great idea) Tj T* 0 Tw (since:) Tj T* ET +BT 1 0 0 1 0 50 Tm /F1 10 Tf 12 TL 3.995366 Tw (Python decorators are an interesting example of why syntactic sugar matters. In principle, their) Tj T* 0 Tw .151235 Tw (introduction in Python 2.4 changed nothing, since they do not provide any new functionality which was not) Tj T* 0 Tw 2.238555 Tw (already present in the language. In practice, their introduction has significantly changed the way we) Tj T* 0 Tw .098409 Tw (structure our programs in Python. I believe the change is for the best, and that decorators are a great idea) Tj T* 0 Tw (since:) Tj T* ET Q Q q @@ -1665,21 +1654,21 @@ q 1 0 0 1 62.69291 218.0236 cm Q q -1 0 0 1 62.69291 200.0236 cm +1 0 0 1 62.69291 206.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators help reducing boilerplate code;) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators help reducing boilerplate code;) Tj T* ET Q Q q @@ -1689,24 +1678,21 @@ q 1 0 0 1 62.69291 200.0236 cm Q q -1 0 0 1 62.69291 200.0236 cm -Q -q -1 0 0 1 62.69291 182.0236 cm +1 0 0 1 62.69291 188.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators help separation of concerns;) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators help separation of concerns;) Tj T* ET Q Q q @@ -1716,24 +1702,21 @@ q 1 0 0 1 62.69291 182.0236 cm Q q -1 0 0 1 62.69291 182.0236 cm -Q -q -1 0 0 1 62.69291 164.0236 cm +1 0 0 1 62.69291 170.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators enhance readability and maintenability;) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators enhance readability and maintenability;) Tj T* ET Q Q q @@ -1743,169 +1726,162 @@ q 1 0 0 1 62.69291 164.0236 cm Q q -1 0 0 1 62.69291 164.0236 cm -Q -q -1 0 0 1 62.69291 146.0236 cm +1 0 0 1 62.69291 152.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 3 cm +1 0 0 1 6 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (decorators are explicit.) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (decorators are explicit.) Tj T* ET Q Q q Q Q q -1 0 0 1 62.69291 146.0236 cm +1 0 0 1 62.69291 152.0236 cm Q q -1 0 0 1 62.69291 146.0236 cm +1 0 0 1 62.69291 110.0236 cm +q +0 0 0 rg +BT 1 0 0 1 0 26 Tm /F1 10 Tf 12 TL .848876 Tw (Still, as of now, writing custom decorators correctly requires some experience and it is not as easy as it) Tj T* 0 Tw 1.049269 Tw (could be. For instance, typical implementations of decorators involve nested functions, and we all know) Tj T* 0 Tw (that flat is better than nested.) Tj T* ET +Q Q q -1 0 0 1 62.69291 104.0236 cm +1 0 0 1 62.69291 80.02362 cm q -0 0 0 rg -BT 1 0 0 1 0 28.82 Tm /F1 10 Tf 12 TL .848876 Tw (Still, as of now, writing custom decorators correctly requires some experience and it is not as easy as it) Tj T* 0 Tw 1.049269 Tw (could be. For instance, typical implementations of decorators involve nested functions, and we all know) Tj T* 0 Tw (that flat is better than nested.) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.093735 Tw 12 TL /F1 10 Tf 0 0 0 rg (The aim of the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module it to simplify the usage of decorators for the average programmer, ) Tj T* 0 Tw 2.456136 Tw (and to popularize decorators by showing various non-trivial examples. Of course, as all techniques,) Tj T* 0 Tw ET Q Q endstream - endobj -% 'R82': class PDFStream -82 0 obj +% 'R81': class PDFStream +81 0 obj % page stream -<< /Length 7636 >> +<< /Length 7640 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 717.0236 cm +1 0 0 1 62.69291 741.0236 cm q -BT 1 0 0 1 0 40.82 Tm 1.093735 Tw 12 TL /F1 10 Tf 0 0 0 rg (The aim of the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module it to simplify the usage of decorators for the average programmer,) Tj T* 0 Tw 2.456136 Tw (and to popularize decorators by showing various non-trivial examples. Of course, as all techniques,) Tj T* 0 Tw 2.234987 Tw (decorators can be abused \(I have seen that\) and you should not try to solve every problem with a) Tj T* 0 Tw (decorator, just because you can.) Tj T* ET +BT 1 0 0 1 0 14 Tm 2.234987 Tw 12 TL /F1 10 Tf 0 0 0 rg (decorators can be abused \(I have seen that\) and you should not try to solve every problem with a) Tj T* 0 Tw (decorator, just because you can.) Tj T* ET Q Q q -1 0 0 1 62.69291 687.0236 cm +1 0 0 1 62.69291 711.0236 cm q -BT 1 0 0 1 0 16.82 Tm .13561 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may find the source code for all the examples discussed here in the ) Tj /F5 10 Tf (documentation.py ) Tj /F1 10 Tf (file, which) Tj T* 0 Tw (contains this documentation in the form of doctests.) Tj T* ET +BT 1 0 0 1 0 14 Tm .13561 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may find the source code for all the examples discussed here in the ) Tj /F4 10 Tf (documentation.py ) Tj /F1 10 Tf (file, which) Tj T* 0 Tw (contains this documentation in the form of doctests.) Tj T* ET Q Q q -1 0 0 1 62.69291 654.0236 cm +1 0 0 1 62.69291 678.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Definitions) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Definitions) Tj T* ET Q Q q -1 0 0 1 62.69291 612.0236 cm +1 0 0 1 62.69291 636.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 28.82 Tm /F1 10 Tf 12 TL 2.37561 Tw (Technically speaking, any Python object which can be called with one argument can be used as a) Tj T* 0 Tw .472339 Tw (decorator. However, this definition is somewhat too large to be really useful. It is more convenient to split) Tj T* 0 Tw (the generic class of decorators in two subclasses:) Tj T* ET +BT 1 0 0 1 0 26 Tm /F1 10 Tf 12 TL 2.37561 Tw (Technically speaking, any Python object which can be called with one argument can be used as a) Tj T* 0 Tw .472339 Tw (decorator. However, this definition is somewhat too large to be really useful. It is more convenient to split) Tj T* 0 Tw (the generic class of decorators in two subclasses:) Tj T* ET Q Q q -1 0 0 1 62.69291 606.0236 cm +1 0 0 1 62.69291 630.0236 cm Q q -1 0 0 1 62.69291 606.0236 cm +1 0 0 1 62.69291 630.0236 cm Q q -1 0 0 1 62.69291 576.0236 cm +1 0 0 1 62.69291 606.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 15 cm +1 0 0 1 6 9 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q -BT 1 0 0 1 0 16.82 Tm 2.68748 Tw 12 TL /F6 10 Tf 0 0 0 rg (signature-preserving ) Tj /F1 10 Tf (decorators, i.e. callable objects taking a function as input and returning a) Tj T* 0 Tw (function ) Tj /F6 10 Tf (with the same signature ) Tj /F1 10 Tf (as output;) Tj T* ET +BT 1 0 0 1 0 14 Tm 2.68748 Tw 12 TL /F5 10 Tf 0 0 0 rg (signature-preserving ) Tj /F1 10 Tf (decorators, i.e. callable objects taking a function as input and returning a) Tj T* 0 Tw (function ) Tj /F5 10 Tf (with the same signature ) Tj /F1 10 Tf (as output;) Tj T* ET Q Q q Q Q q -1 0 0 1 62.69291 576.0236 cm +1 0 0 1 62.69291 600.0236 cm Q q 1 0 0 1 62.69291 576.0236 cm -Q -q -1 0 0 1 62.69291 546.0236 cm 0 0 0 rg -BT /F4 10 Tf 12 TL ET +BT /F1 10 Tf 12 TL ET q -1 0 0 1 6 15 cm +1 0 0 1 6 9 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL 10.5 0 Td (\177) Tj T* -10.5 0 Td ET Q Q q -1 0 0 1 23 3 cm +1 0 0 1 23 -3 cm q -BT 1 0 0 1 0 16.82 Tm 1.43498 Tw 12 TL /F6 10 Tf 0 0 0 rg (signature-changing ) Tj /F1 10 Tf (decorators, i.e. decorators that change the signature of their input function, or) Tj T* 0 Tw (decorators returning non-callable objects.) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.43498 Tw 12 TL /F5 10 Tf 0 0 0 rg (signature-changing ) Tj /F1 10 Tf (decorators, i.e. decorators that change the signature of their input function, or) Tj T* 0 Tw (decorators returning non-callable objects.) Tj T* ET Q Q q Q Q q -1 0 0 1 62.69291 546.0236 cm -Q -q -1 0 0 1 62.69291 546.0236 cm +1 0 0 1 62.69291 576.0236 cm Q q -1 0 0 1 62.69291 504.0236 cm +1 0 0 1 62.69291 534.0236 cm q -BT 1 0 0 1 0 28.82 Tm 2.832706 Tw 12 TL /F1 10 Tf 0 0 0 rg (Signature-changing decorators have their use: for instance the builtin classes ) Tj /F5 10 Tf (staticmethod ) Tj /F1 10 Tf (and) Tj T* 0 Tw 1.506651 Tw /F5 10 Tf (classmethod ) Tj /F1 10 Tf (are in this group, since they take functions and return descriptor objects which are not) Tj T* 0 Tw (functions, nor callables.) Tj T* ET +BT 1 0 0 1 0 26 Tm 2.832706 Tw 12 TL /F1 10 Tf 0 0 0 rg (Signature-changing decorators have their use: for instance the builtin classes ) Tj /F4 10 Tf (staticmethod ) Tj /F1 10 Tf (and) Tj T* 0 Tw 1.506651 Tw /F4 10 Tf (classmethod ) Tj /F1 10 Tf (are in this group, since they take functions and return descriptor objects which are not) Tj T* 0 Tw (functions, nor callables.) Tj T* ET Q Q q -1 0 0 1 62.69291 474.0236 cm +1 0 0 1 62.69291 504.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL 1.735814 Tw (However, signature-preserving decorators are more common and easier to reason about; in particular) Tj T* 0 Tw (signature-preserving decorators can be composed together whereas other decorators in general cannot.) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL 1.735814 Tw (However, signature-preserving decorators are more common and easier to reason about; in particular) Tj T* 0 Tw (signature-preserving decorators can be composed together whereas other decorators in general cannot.) Tj T* ET Q Q q -1 0 0 1 62.69291 444.0236 cm +1 0 0 1 62.69291 474.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .494983 Tw (Writing signature-preserving decorators from scratch is not that obvious, especially if one wants to define) Tj T* 0 Tw (proper decorators that can accept functions with any signature. A simple example will clarify the issue.) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .494983 Tw (Writing signature-preserving decorators from scratch is not that obvious, especially if one wants to define) Tj T* 0 Tw (proper decorators that can accept functions with any signature. A simple example will clarify the issue.) Tj T* ET Q Q q -1 0 0 1 62.69291 411.0236 cm +1 0 0 1 62.69291 441.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Statement of the problem) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Statement of the problem) Tj T* ET Q Q q -1 0 0 1 62.69291 333.0236 cm +1 0 0 1 62.69291 363.0236 cm q -BT 1 0 0 1 0 64.82 Tm .351235 Tw 12 TL /F1 10 Tf 0 0 0 rg (A very common use case for decorators is the memoization of functions. A ) Tj /F5 10 Tf (memoize ) Tj /F1 10 Tf (decorator works by) Tj T* 0 Tw .871988 Tw (caching the result of the function call in a dictionary, so that the next time the function is called with the) Tj T* 0 Tw 2.350651 Tw (same input parameters the result is retrieved from the cache and not recomputed. There are many) Tj T* 0 Tw 2.92247 Tw (implementations of ) Tj /F5 10 Tf (memoize ) Tj /F1 10 Tf (in ) Tj 0 0 .501961 rg (http://www.python.org/moin/PythonDecoratorLibrary) Tj 0 0 0 rg (, but they do not) Tj T* 0 Tw 2.683984 Tw (preserve the signature. A simple implementation could be the following \(notice that in general it is) Tj T* 0 Tw (impossible to memoize correctly something that depends on non-hashable arguments\):) Tj T* ET +BT 1 0 0 1 0 62 Tm .351235 Tw 12 TL /F1 10 Tf 0 0 0 rg (A very common use case for decorators is the memoization of functions. A ) Tj /F4 10 Tf (memoize ) Tj /F1 10 Tf (decorator works by) Tj T* 0 Tw .871988 Tw (caching the result of the function call in a dictionary, so that the next time the function is called with the) Tj T* 0 Tw 2.350651 Tw (same input parameters the result is retrieved from the cache and not recomputed. There are many) Tj T* 0 Tw 2.92247 Tw (implementations of ) Tj /F4 10 Tf (memoize ) Tj /F1 10 Tf (in ) Tj 0 0 .501961 rg (http://www.python.org/moin/PythonDecoratorLibrary) Tj 0 0 0 rg (, but they do not) Tj T* 0 Tw 2.683984 Tw (preserve the signature. A simple implementation could be the following \(notice that in general it is) Tj T* 0 Tw (impossible to memoize correctly something that depends on non-hashable arguments\):) Tj T* ET Q Q q -1 0 0 1 62.69291 143.8236 cm +1 0 0 1 62.69291 173.8236 cm q q 1 0 0 1 0 0 cm @@ -1918,43 +1894,48 @@ q n -6 -6 468.6898 180 re B* Q q -BT 1 0 0 1 0 161.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize_uw) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ({}) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (kw) Tj (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# frozenset is used to ensure hashability) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (frozenset) Tj (\() Tj (kw) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (iteritems) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj T* ( ) Tj (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (key) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (functools) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (update_wrapper) Tj (\() Tj (memoize) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* ET +BT 1 0 0 1 0 158 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize_uw) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ({}) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (kw) Tj (:) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# frozenset is used to ensure hashability) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj 0 .501961 0 rg (frozenset) Tj 0 0 0 rg (\() Tj (kw) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (iteritems) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj T* ( ) Tj (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (key) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (cache) Tj (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (functools) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (update_wrapper) Tj (\() Tj (memoize) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* ET Q Q Q Q Q q +1 0 0 1 62.69291 117.8236 cm +q +BT 1 0 0 1 0 38 Tm 1.801412 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here we used the ) Tj 0 0 .501961 rg (functools.update_wrapper ) Tj 0 0 0 rg (utility, which has been added in Python 2.5 expressly to) Tj T* 0 Tw .91686 Tw (simplify the definition of decorators \(in older versions of Python you need to copy the function attributes) Tj T* 0 Tw .580814 Tw /F4 10 Tf (__name__) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (__doc__) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (__module__ ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (__dict__ ) Tj /F1 10 Tf (from the original function to the decorated function) Tj T* 0 Tw (by hand\).) Tj T* ET +Q +Q +q 1 0 0 1 62.69291 87.82362 cm q -BT 1 0 0 1 0 40.82 Tm 1.801412 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here we used the ) Tj 0 0 .501961 rg (functools.update_wrapper ) Tj 0 0 0 rg (utility, which has been added in Python 2.5 expressly to) Tj T* 0 Tw .91686 Tw (simplify the definition of decorators \(in older versions of Python you need to copy the function attributes) Tj T* 0 Tw .580814 Tw /F5 10 Tf (__name__) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (__doc__) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (__module__ ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (__dict__ ) Tj /F1 10 Tf (from the original function to the decorated function) Tj T* 0 Tw (by hand\).) Tj T* ET +BT 1 0 0 1 0 14 Tm 2.517126 Tw 12 TL /F1 10 Tf 0 0 0 rg (The implementation above works in the sense that the decorator can accept functions with generic ) Tj T* 0 Tw 1.233615 Tw (signatures; unfortunately this implementation does ) Tj /F5 10 Tf (not ) Tj /F1 10 Tf (define a signature-preserving decorator, since in) Tj T* 0 Tw ET Q Q endstream - endobj -% 'R83': class PDFStream -83 0 obj +% 'R82': class PDFStream +82 0 obj % page stream -<< /Length 7980 >> +<< /Length 8131 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 729.0236 cm +1 0 0 1 62.69291 753.0236 cm q -BT 1 0 0 1 0 28.82 Tm 2.517126 Tw 12 TL /F1 10 Tf 0 0 0 rg (The implementation above works in the sense that the decorator can accept functions with generic) Tj T* 0 Tw 1.233615 Tw (signatures; unfortunately this implementation does ) Tj /F6 10 Tf (not ) Tj /F1 10 Tf (define a signature-preserving decorator, since in) Tj T* 0 Tw (general ) Tj /F5 10 Tf (memoize_uw ) Tj /F1 10 Tf (returns a function with a ) Tj /F6 10 Tf (different signature ) Tj /F1 10 Tf (from the original function.) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (general ) Tj /F4 10 Tf (memoize_uw ) Tj /F1 10 Tf (returns a function with a ) Tj /F5 10 Tf (different signature ) Tj /F1 10 Tf (from the original function.) Tj T* ET Q Q q -1 0 0 1 62.69291 711.0236 cm +1 0 0 1 62.69291 735.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Consider for instance the following case:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Consider for instance the following case:) Tj T* ET Q Q q -1 0 0 1 62.69291 641.8236 cm +1 0 0 1 62.69291 665.8236 cm q q 1 0 0 1 0 0 cm @@ -1967,20 +1948,20 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize_uw) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# simulate some long computation) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (x) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize_uw) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# simulate some long computation) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (x) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 609.8236 cm +1 0 0 1 62.69291 633.8236 cm q -BT 1 0 0 1 0 16.82 Tm .26311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here the original function takes a single argument named ) Tj /F5 10 Tf (x) Tj /F1 10 Tf (, but the decorated function takes any number) Tj T* 0 Tw (of arguments and keyword arguments:) Tj T* ET +BT 1 0 0 1 0 14 Tm .26311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here the original function takes a single argument named ) Tj /F4 10 Tf (x) Tj /F1 10 Tf (, but the decorated function takes any number) Tj T* 0 Tw (of arguments and keyword arguments:) Tj T* ET Q Q q -1 0 0 1 62.69291 552.6236 cm +1 0 0 1 62.69291 576.6236 cm q q 1 0 0 1 0 0 cm @@ -1993,20 +1974,20 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (inspect) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (f1) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (inspect) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (getargspec) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (f1) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 508.6236 cm +1 0 0 1 62.69291 532.6236 cm q -BT 1 0 0 1 0 28.82 Tm .411235 Tw 12 TL /F1 10 Tf 0 0 0 rg (This means that introspection tools such as pydoc will give wrong informations about the signature of ) Tj /F5 10 Tf (f1) Tj /F1 10 Tf (.) Tj T* 0 Tw .161654 Tw (This is pretty bad: pydoc will tell you that the function accepts a generic signature ) Tj /F5 10 Tf (*args) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (**kw) Tj /F1 10 Tf (, but when) Tj T* 0 Tw (you try to call the function with more than an argument, you will get an error:) Tj T* ET +BT 1 0 0 1 0 26 Tm .411235 Tw 12 TL /F1 10 Tf 0 0 0 rg (This means that introspection tools such as pydoc will give wrong informations about the signature of ) Tj /F4 10 Tf (f1) Tj /F1 10 Tf (.) Tj T* 0 Tw .161654 Tw (This is pretty bad: pydoc will tell you that the function accepts a generic signature ) Tj /F4 10 Tf (*args) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (**kw) Tj /F1 10 Tf (, but when) Tj T* 0 Tw (you try to call the function with more than an argument, you will get an error:) Tj T* ET Q Q q -1 0 0 1 62.69291 439.4236 cm +1 0 0 1 62.69291 463.4236 cm q q 1 0 0 1 0 0 cm @@ -2019,26 +2000,26 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (TypeError) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj (f1) Tj (\(\)) Tj ( ) Tj (takes) Tj ( ) Tj (exactly) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg ( ) Tj (positional) Tj ( ) Tj (argument) Tj ( ) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg ( ) Tj (given) Tj (\)) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (TypeError) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj (f1) Tj (\(\)) Tj ( ) Tj (takes) Tj ( ) Tj (exactly) Tj ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg ( ) Tj (positional) Tj ( ) Tj (argument) Tj ( ) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg ( ) Tj (given) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 406.4236 cm +1 0 0 1 62.69291 430.4236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The solution) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The solution) Tj T* ET Q Q q -1 0 0 1 62.69291 364.4236 cm +1 0 0 1 62.69291 388.4236 cm q -BT 1 0 0 1 0 28.82 Tm 3.313984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The solution is to provide a generic factory of generators, which hides the complexity of making) Tj T* 0 Tw 3.362976 Tw (signature-preserving decorators from the application programmer. The ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (function in the) Tj T* 0 Tw /F5 10 Tf (decorator ) Tj /F1 10 Tf (module is such a factory:) Tj T* ET +BT 1 0 0 1 0 26 Tm 3.313984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The solution is to provide a generic factory of generators, which hides the complexity of making) Tj T* 0 Tw 3.362976 Tw (signature-preserving decorators from the application programmer. The ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (function in the) Tj T* 0 Tw /F4 10 Tf (decorator ) Tj /F1 10 Tf (module is such a factory:) Tj T* ET Q Q q -1 0 0 1 62.69291 331.2236 cm +1 0 0 1 62.69291 355.2236 cm q q 1 0 0 1 0 0 cm @@ -2051,20 +2032,20 @@ q n -6 -6 468.6898 24 re B* Q q -BT 1 0 0 1 0 5.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (decorator) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (from) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (decorator) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (import) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 275.2236 cm +1 0 0 1 62.69291 299.2236 cm q -BT 1 0 0 1 0 40.82 Tm 1.716412 Tw 12 TL /F5 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf (takes two arguments, a caller function describing the functionality of the decorator and a) Tj T* 0 Tw .821984 Tw (function to be decorated; it returns the decorated function. The caller function must have signature ) Tj /F5 10 Tf (\(f,) Tj T* 0 Tw .65061 Tw (*args, **kw\) ) Tj /F1 10 Tf (and it must call the original function ) Tj /F5 10 Tf (f ) Tj /F1 10 Tf (with arguments ) Tj /F5 10 Tf (args ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (kw) Tj /F1 10 Tf (, implementing the) Tj T* 0 Tw (wanted capability, i.e. memoization in this case:) Tj T* ET +BT 1 0 0 1 0 38 Tm 1.716412 Tw 12 TL /F4 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf (takes two arguments, a caller function describing the functionality of the decorator and a) Tj T* 0 Tw .821984 Tw (function to be decorated; it returns the decorated function. The caller function must have signature ) Tj /F4 10 Tf (\(f,) Tj T* 0 Tw .65061 Tw (*args, **kw\) ) Tj /F1 10 Tf (and it must call the original function ) Tj /F4 10 Tf (f ) Tj /F1 10 Tf (with arguments ) Tj /F4 10 Tf (args ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (kw) Tj /F1 10 Tf (, implementing the) Tj T* 0 Tw (wanted capability, i.e. memoization in this case:) Tj T* ET Q Q q -1 0 0 1 62.69291 122.0236 cm +1 0 0 1 62.69291 146.0236 cm q q 1 0 0 1 0 0 cm @@ -2077,31 +2058,50 @@ q n -6 -6 468.6898 144 re B* Q q -BT 1 0 0 1 0 125.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (_memoize) Tj 0 0 0 rg (\() Tj (func) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (kw) Tj (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# frozenset is used to ensure hashability) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (frozenset) Tj (\() Tj (kw) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (iteritems) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj T* ( ) Tj (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# attributed added by memoize) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (key) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ET +BT 1 0 0 1 0 122 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (_memoize) Tj 0 0 0 rg (\() Tj (func) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (kw) Tj (:) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# frozenset is used to ensure hashability) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj 0 .501961 0 rg (frozenset) Tj 0 0 0 rg (\() Tj (kw) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (iteritems) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (key) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj T* ( ) Tj (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# attributed added by memoize) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (key) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (cache) Tj (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (cache) Tj ([) Tj (key) Tj (]) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 102.0236 cm +1 0 0 1 62.69291 126.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (At this point you can define your decorator as follows:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (At this point you can define your decorator as follows:) Tj T* ET +Q +Q +q +1 0 0 1 62.69291 80.82362 cm +q +q +1 0 0 1 0 0 cm +q +1 0 0 1 6.6 6.6 cm +q +.662745 .662745 .662745 RG +.5 w +.960784 .960784 .862745 rg +n -6 -6 468.6898 36 re B* +Q +q +BT 1 0 0 1 0 14 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize) Tj 0 0 0 rg (\() Tj (f) Tj (\):) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ({}) Tj T* ET +Q +Q +Q Q Q endstream - endobj -% 'R84': class PDFStream -84 0 obj +% 'R83': class PDFStream +83 0 obj % page stream -<< /Length 7170 >> +<< /Length 7825 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 715.8236 cm +1 0 0 1 62.69291 739.8236 cm q q 1 0 0 1 0 0 cm @@ -2111,30 +2111,30 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 48 re B* +n -6 -6 468.6898 24 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (memoize) Tj 0 0 0 rg (\() Tj (f) Tj (\):) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (cache) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ({}) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (_memoize) Tj (,) Tj ( ) Tj (f) Tj (\)) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (_memoize) Tj (,) Tj ( ) Tj (f) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 671.8236 cm +1 0 0 1 62.69291 695.8236 cm q -BT 1 0 0 1 0 28.82 Tm .12561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The difference with respect to the ) Tj /F5 10 Tf (memoize_uw ) Tj /F1 10 Tf (approach, which is based on nested functions, is that the) Tj T* 0 Tw 2.59528 Tw (decorator module forces you to lift the inner function at the outer level \() Tj /F6 10 Tf (flat is better than nested) Tj /F1 10 Tf (\).) Tj T* 0 Tw (Moreover, you are forced to pass explicitly the function you want to decorate to the caller function.) Tj T* ET +BT 1 0 0 1 0 26 Tm .12561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The difference with respect to the ) Tj /F4 10 Tf (memoize_uw ) Tj /F1 10 Tf (approach, which is based on nested functions, is that the) Tj T* 0 Tw 2.59528 Tw (decorator module forces you to lift the inner function at the outer level \() Tj /F5 10 Tf (flat is better than nested) Tj /F1 10 Tf (\).) Tj T* 0 Tw (Moreover, you are forced to pass explicitly the function you want to decorate to the caller function.) Tj T* ET Q Q q -1 0 0 1 62.69291 653.8236 cm +1 0 0 1 62.69291 677.8236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is a test of usage:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is a test of usage:) Tj T* ET Q Q q -1 0 0 1 62.69291 512.6236 cm +1 0 0 1 62.69291 536.6236 cm q q 1 0 0 1 0 0 cm @@ -2147,20 +2147,20 @@ q n -6 -6 468.6898 132 re B* Q q -BT 1 0 0 1 0 113.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (heavy_computation) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("done") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (heavy_computation) Tj (\(\)\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the first time it will take 2 seconds) Tj /F5 10 Tf 0 0 0 rg T* (done) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (heavy_computation) Tj (\(\)\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the second time it will be instantaneous) Tj /F5 10 Tf 0 0 0 rg T* (done) Tj T* ET +BT 1 0 0 1 0 110 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@memoize) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (heavy_computation) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("done") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (heavy_computation) Tj (\(\)\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the first time it will take 2 seconds) Tj /F4 10 Tf 0 0 0 rg T* (done) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (heavy_computation) Tj (\(\)\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the second time it will be instantaneous) Tj /F4 10 Tf 0 0 0 rg T* (done) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 492.6236 cm +1 0 0 1 62.69291 516.6236 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F1 10 Tf 0 0 0 rg (The signature of ) Tj /F5 10 Tf (heavy_computation ) Tj /F1 10 Tf (is the one you would expect:) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (The signature of ) Tj /F4 10 Tf (heavy_computation ) Tj /F1 10 Tf (is the one you would expect:) Tj T* ET Q Q q -1 0 0 1 62.69291 447.4236 cm +1 0 0 1 62.69291 471.4236 cm q q 1 0 0 1 0 0 cm @@ -2173,26 +2173,26 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (heavy_computation) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (heavy_computation) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 414.4236 cm +1 0 0 1 62.69291 438.4236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (A ) Tj /F3 17.5 Tf (trace ) Tj /F2 17.5 Tf (decorator) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (A ) Tj /F3 17.5 Tf (trace ) Tj /F2 17.5 Tf (decorator) Tj T* ET Q Q q -1 0 0 1 62.69291 384.4236 cm +1 0 0 1 62.69291 408.4236 cm q -BT 1 0 0 1 0 16.82 Tm .479398 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an additional example, here is how you can define a trivial ) Tj /F5 10 Tf (trace ) Tj /F1 10 Tf (decorator, which prints a message) Tj T* 0 Tw (everytime the traced function is called:) Tj T* ET +BT 1 0 0 1 0 14 Tm .479398 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an additional example, here is how you can define a trivial ) Tj /F4 10 Tf (trace ) Tj /F1 10 Tf (decorator, which prints a message) Tj T* 0 Tw (everytime the traced function is called:) Tj T* ET Q Q q -1 0 0 1 62.69291 327.2236 cm +1 0 0 1 62.69291 351.2236 cm q q 1 0 0 1 0 0 cm @@ -2205,14 +2205,14 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (_trace) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("calling ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg ( with args ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (, ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (") Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (_trace) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("calling ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg ( with args ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (, ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (") Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 282.0236 cm +1 0 0 1 62.69291 306.0236 cm q q 1 0 0 1 0 0 cm @@ -2225,21 +2225,21 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (trace) Tj 0 0 0 rg (\() Tj (f) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (_trace) Tj (,) Tj ( ) Tj (f) Tj (\)) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (trace) Tj 0 0 0 rg (\() Tj (f) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (_trace) Tj (,) Tj ( ) Tj (f) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 262.0236 cm +1 0 0 1 62.69291 286.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET Q Q q -1 0 0 1 62.69291 204.8236 cm +1 0 0 1 62.69291 228.8236 cm q q 1 0 0 1 0 0 cm @@ -2252,20 +2252,20 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (x) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 184.8236 cm +1 0 0 1 62.69291 208.8236 cm q -BT 1 0 0 1 0 4.82 Tm 12 TL /F1 10 Tf 0 0 0 rg (It is immediate to verify that ) Tj /F5 10 Tf (f1 ) Tj /F1 10 Tf (works) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (It is immediate to verify that ) Tj /F4 10 Tf (f1 ) Tj /F1 10 Tf (works) Tj T* ET Q Q q -1 0 0 1 62.69291 139.6236 cm +1 0 0 1 62.69291 163.6236 cm q q 1 0 0 1 0 0 cm @@ -2278,31 +2278,21 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f1) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,\),) Tj ( ) Tj ({}) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f1) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,\),) Tj ( ) Tj ({}) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 119.6236 cm +1 0 0 1 62.69291 143.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (and it that it has the correct signature:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (and it that it has the correct signature:) Tj T* ET Q Q - -endstream - -endobj -% 'R85': class PDFStream -85 0 obj -% page stream -<< /Length 8309 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 727.8236 cm +1 0 0 1 62.69291 98.42362 cm q q 1 0 0 1 0 0 cm @@ -2315,21 +2305,30 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (f1) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (f1) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 707.8236 cm +1 0 0 1 62.69291 78.42362 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (The same decorator works with functions of any signature:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (The same decorator works with functions of any signature:) Tj T* ET Q Q + +endstream +endobj +% 'R84': class PDFStream +84 0 obj +% page stream +<< /Length 8633 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 579.978 cm +1 0 0 1 62.69291 645.178 cm q q .988825 0 0 .988825 0 0 cm @@ -2342,26 +2341,26 @@ q n -6 -6 474 120 re B* Q q -BT 1 0 0 1 0 101.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (x) Tj (,) Tj ( ) Tj (y) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (z) Tj .4 .4 .4 rg (=) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),) Tj ( ) Tj ({}) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (f) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('y') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('z') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)\)) Tj T* ET +BT 1 0 0 1 0 98 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (x) Tj (,) Tj ( ) Tj (y) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (z) Tj .4 .4 .4 rg (=) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj T* (calling) Tj ( ) Tj (f) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\() Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\),) Tj ( ) Tj ({}) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (getargspec) Tj (\() Tj (f) Tj (\)\)) Tj T* (ArgSpec) Tj (\() Tj (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('x') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('y') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('z') Tj 0 0 0 rg (],) Tj ( ) Tj (varargs) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('args') Tj 0 0 0 rg (,) Tj ( ) Tj (keywords) Tj .4 .4 .4 rg (=) Tj .729412 .129412 .129412 rg ('kw') Tj 0 0 0 rg (,) Tj ( ) Tj (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 546.978 cm +1 0 0 1 62.69291 612.178 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (decorator ) Tj /F2 17.5 Tf (is a decorator) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (decorator ) Tj /F2 17.5 Tf (is a decorator) Tj T* ET Q Q q -1 0 0 1 62.69291 444.978 cm +1 0 0 1 62.69291 510.178 cm q -BT 1 0 0 1 0 88.82 Tm .643876 Tw 12 TL /F1 10 Tf 0 0 0 rg (It may be annoying to write a caller function \(like the ) Tj /F5 10 Tf (_trace ) Tj /F1 10 Tf (function above\) and then a trivial wrapper) Tj T* 0 Tw 1.803615 Tw (\() Tj /F5 10 Tf (def trace\(f\): return decorator\(_trace, f\)) Tj /F1 10 Tf (\) every time. For this reason, the ) Tj /F5 10 Tf (decorator) Tj T* 0 Tw .334269 Tw /F1 10 Tf (module provides an easy shortcut to convert the caller function into a signature-preserving decorator: you) Tj T* 0 Tw 3.443735 Tw (can just call ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (with a single argument. In our example you can just write ) Tj /F5 10 Tf (trace =) Tj T* 0 Tw 1.056342 Tw (decorator\(_trace\)) Tj /F1 10 Tf (. The ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (function can also be used as a signature-changing decorator,) Tj T* 0 Tw 3.177752 Tw (just as ) Tj /F5 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (staticmethod) Tj /F1 10 Tf (. However, ) Tj /F5 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (staticmethod ) Tj /F1 10 Tf (return) Tj T* 0 Tw 1.693615 Tw (generic objects which are not callable, while ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (returns signature-preserving decorators, i.e.) Tj T* 0 Tw (functions of a single argument. For instance, you can write directly) Tj T* ET +BT 1 0 0 1 0 86 Tm .643876 Tw 12 TL /F1 10 Tf 0 0 0 rg (It may be annoying to write a caller function \(like the ) Tj /F4 10 Tf (_trace ) Tj /F1 10 Tf (function above\) and then a trivial wrapper) Tj T* 0 Tw 1.803615 Tw (\() Tj /F4 10 Tf (def trace\(f\): return decorator\(_trace, f\)) Tj /F1 10 Tf (\) every time. For this reason, the ) Tj /F4 10 Tf (decorator) Tj T* 0 Tw .334269 Tw /F1 10 Tf (module provides an easy shortcut to convert the caller function into a signature-preserving decorator: you) Tj T* 0 Tw 3.443735 Tw (can just call ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (with a single argument. In our example you can just write ) Tj /F4 10 Tf (trace =) Tj T* 0 Tw 1.056342 Tw (decorator\(_trace\)) Tj /F1 10 Tf (. The ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (function can also be used as a signature-changing decorator,) Tj T* 0 Tw 3.177752 Tw (just as ) Tj /F4 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (staticmethod) Tj /F1 10 Tf (. However, ) Tj /F4 10 Tf (classmethod ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (staticmethod ) Tj /F1 10 Tf (return) Tj T* 0 Tw 1.693615 Tw (generic objects which are not callable, while ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (returns signature-preserving decorators, i.e.) Tj T* 0 Tw (functions of a single argument. For instance, you can write directly) Tj T* ET Q Q q -1 0 0 1 62.69291 375.778 cm +1 0 0 1 62.69291 440.978 cm q q 1 0 0 1 0 0 cm @@ -2374,20 +2373,20 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@decorator) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (trace) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("calling ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg ( with args ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (, ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (") Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@decorator) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (trace) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("calling ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg ( with args ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (, ) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (") Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 343.778 cm +1 0 0 1 62.69291 408.978 cm q -BT 1 0 0 1 0 16.82 Tm 1.806654 Tw 12 TL /F1 10 Tf 0 0 0 rg (and now ) Tj /F5 10 Tf (trace ) Tj /F1 10 Tf (will be a decorator. Actually ) Tj /F5 10 Tf (trace ) Tj /F1 10 Tf (is a ) Tj /F5 10 Tf (partial ) Tj /F1 10 Tf (object which can be used as a) Tj T* 0 Tw (decorator:) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.806654 Tw 12 TL /F1 10 Tf 0 0 0 rg (and now ) Tj /F4 10 Tf (trace ) Tj /F1 10 Tf (will be a decorator. Actually ) Tj /F4 10 Tf (trace ) Tj /F1 10 Tf (is a ) Tj /F4 10 Tf (partial ) Tj /F1 10 Tf (object which can be used as a) Tj T* 0 Tw (decorator:) Tj T* ET Q Q q -1 0 0 1 62.69291 298.578 cm +1 0 0 1 62.69291 363.778 cm q q 1 0 0 1 0 0 cm @@ -2400,21 +2399,21 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (function) Tj ( ) Tj (trace) Tj ( ) Tj (at) Tj ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (x) Tj .4 .4 .4 rg (...) Tj (>) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (trace) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (function) Tj ( ) Tj (trace) Tj ( ) Tj (at) Tj ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (x) Tj .4 .4 .4 rg (...) Tj (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 278.578 cm +1 0 0 1 62.69291 343.778 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is an example of usage:) Tj T* ET Q Q q -1 0 0 1 62.69291 197.378 cm +1 0 0 1 62.69291 262.578 cm q q 1 0 0 1 0 0 cm @@ -2427,42 +2426,61 @@ q n -6 -6 468.6898 72 re B* Q q -BT 1 0 0 1 0 53.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (func) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (func) Tj (\(\)) Tj T* (calling) Tj ( ) Tj (func) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\(\),) Tj ( ) Tj ({}) Tj T* ET +BT 1 0 0 1 0 50 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (func) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (func) Tj (\(\)) Tj T* (calling) Tj ( ) Tj (func) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (args) Tj ( ) Tj (\(\),) Tj ( ) Tj ({}) Tj T* ET +Q Q Q Q Q +q +1 0 0 1 62.69291 230.578 cm +q +BT 1 0 0 1 0 14 Tm 2.44686 Tw 12 TL /F1 10 Tf 0 0 0 rg (If you are using an old Python version \(Python 2.4\) the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module provides a poor man) Tj T* 0 Tw (replacement for ) Tj /F4 10 Tf (functools.partial) Tj /F1 10 Tf (.) Tj T* ET +Q Q q -1 0 0 1 62.69291 165.378 cm +1 0 0 1 62.69291 197.578 cm q -BT 1 0 0 1 0 16.82 Tm 2.44686 Tw 12 TL /F1 10 Tf 0 0 0 rg (If you are using an old Python version \(Python 2.4\) the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module provides a poor man) Tj T* 0 Tw (replacement for ) Tj /F5 10 Tf (functools.partial) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (blocking) Tj T* ET Q Q q -1 0 0 1 62.69291 132.378 cm +1 0 0 1 62.69291 155.578 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (blocking) Tj T* ET +BT 1 0 0 1 0 26 Tm 1.224692 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes one has to deal with blocking resources, such as ) Tj /F4 10 Tf (stdin) Tj /F1 10 Tf (, and sometimes it is best to have) Tj T* 0 Tw .266235 Tw (back a "busy" message than to block everything. This behavior can be implemented with a suitable family) Tj T* 0 Tw (of decorators, where the parameter is the busy message:) Tj T* ET Q Q q -1 0 0 1 62.69291 90.378 cm +1 0 0 1 62.69291 86.378 cm +q +q +1 0 0 1 0 0 cm +q +1 0 0 1 6.6 6.6 cm q -BT 1 0 0 1 0 28.82 Tm 1.224692 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes one has to deal with blocking resources, such as ) Tj /F5 10 Tf (stdin) Tj /F1 10 Tf (, and sometimes it is best to have) Tj T* 0 Tw .266235 Tw (back a "busy" message than to block everything. This behavior can be implemented with a suitable family) Tj T* 0 Tw (of decorators, where the parameter is the busy message:) Tj T* ET +.662745 .662745 .662745 RG +.5 w +.960784 .960784 .862745 rg +n -6 -6 468.6898 60 re B* +Q +q +BT 1 0 0 1 0 38 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (blocking) Tj 0 0 0 rg (\() Tj (not_avail) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (blocking) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf .666667 .133333 1 rg (not) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (hasattr) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .729412 .129412 .129412 rg ("thread") Tj 0 0 0 rg (\):) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# no thread running) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (set_result) Tj 0 0 0 rg (\(\):) Tj ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ET +Q +Q +Q Q Q endstream - endobj -% 'R86': class PDFStream -86 0 obj +% 'R85': class PDFStream +85 0 obj % page stream -<< /Length 7602 >> +<< /Length 7125 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 595.8236 cm +1 0 0 1 62.69291 643.8236 cm q q 1 0 0 1 0 0 cm @@ -2472,23 +2490,23 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 168 re B* +n -6 -6 468.6898 120 re B* Q q -BT 1 0 0 1 0 149.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (blocking) Tj 0 0 0 rg (\() Tj (not_avail) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (blocking) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf .666667 .133333 1 rg (not) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (hasattr) Tj 0 0 0 rg (\() Tj (f) Tj (,) Tj ( ) Tj .729412 .129412 .129412 rg ("thread") Tj 0 0 0 rg (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# no thread running) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (set_result) Tj 0 0 0 rg (\(\):) Tj ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Thread) Tj (\() Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (set_result) Tj (\)) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (start) Tj (\(\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (not_avail) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (elif) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (isAlive) Tj (\(\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (not_avail) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the thread is ended, return the stored result) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (del) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (blocking) Tj (\)) Tj T* ET +BT 1 0 0 1 0 98 Tm 12 TL /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Thread) Tj (\() Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (set_result) Tj (\)) Tj T* ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (start) Tj (\(\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (not_avail) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (elif) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (isAlive) Tj (\(\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (not_avail) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the thread is ended, return the stored result) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (del) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (thread) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj (blocking) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 563.8236 cm +1 0 0 1 62.69291 611.8236 cm q -BT 1 0 0 1 0 16.82 Tm 1.010651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Functions decorated with ) Tj /F5 10 Tf (blocking ) Tj /F1 10 Tf (will return a busy message if the resource is unavailable, and the) Tj T* 0 Tw (intended result if the resource is available. For instance:) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.010651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Functions decorated with ) Tj /F4 10 Tf (blocking ) Tj /F1 10 Tf (will return a busy message if the resource is unavailable, and the) Tj T* 0 Tw (intended result if the resource is available. For instance:) Tj T* ET Q Q q -1 0 0 1 62.69291 314.6236 cm +1 0 0 1 62.69291 362.6236 cm q q 1 0 0 1 0 0 cm @@ -2501,32 +2519,32 @@ q n -6 -6 468.6898 240 re B* Q q -BT 1 0 0 1 0 221.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@blocking) Tj 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("Please wait ...") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (read_data) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# simulate a blocking resource) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("some data") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F5 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F5 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F5 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1.1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# after 3.1 seconds, data is available) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj T* (some) Tj ( ) Tj (data) Tj T* ET +BT 1 0 0 1 0 218 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@blocking) Tj 0 0 0 rg (\() Tj .729412 .129412 .129412 rg ("Please wait ...") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (read_data) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# simulate a blocking resource) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("some data") Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F4 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F4 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# data is not available yet) Tj /F4 10 Tf 0 0 0 rg T* (Please) Tj ( ) Tj (wait) Tj ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1.1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# after 3.1 seconds, data is available) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (read_data) Tj (\(\)\)) Tj T* (some) Tj ( ) Tj (data) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 281.6236 cm +1 0 0 1 62.69291 329.6236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (async) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F3 17.5 Tf 0 0 0 rg (async) Tj T* ET Q Q q -1 0 0 1 62.69291 215.6236 cm +1 0 0 1 62.69291 263.6236 cm q -BT 1 0 0 1 0 52.82 Tm 1.647485 Tw 12 TL /F1 10 Tf 0 0 0 rg (We have just seen an examples of a simple decorator factory, implemented as a function returning a) Tj T* 0 Tw .29784 Tw (decorator. For more complex situations, it is more convenient to implement decorator factories as classes) Tj T* 0 Tw .657674 Tw (returning callable objects that can be used as signature-preserving decorators. The suggested pattern to) Tj T* 0 Tw 2.109398 Tw (do that is to introduce a helper method ) Tj /F5 10 Tf (call\(self, func, *args, **kw\) ) Tj /F1 10 Tf (and to call it in the) Tj T* 0 Tw /F5 10 Tf (__call__\(self, func\) ) Tj /F1 10 Tf (method.) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.647485 Tw 12 TL /F1 10 Tf 0 0 0 rg (We have just seen an examples of a simple decorator factory, implemented as a function returning a) Tj T* 0 Tw .29784 Tw (decorator. For more complex situations, it is more convenient to implement decorator factories as classes) Tj T* 0 Tw .657674 Tw (returning callable objects that can be used as signature-preserving decorators. The suggested pattern to) Tj T* 0 Tw 2.109398 Tw (do that is to introduce a helper method ) Tj /F4 10 Tf (call\(self, func, *args, **kw\) ) Tj /F1 10 Tf (and to call it in the) Tj T* 0 Tw /F4 10 Tf (__call__\(self, func\) ) Tj /F1 10 Tf (method.) Tj T* ET Q Q q -1 0 0 1 62.69291 161.6236 cm +1 0 0 1 62.69291 209.6236 cm q -BT 1 0 0 1 0 40.82 Tm .166654 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an example, here I show a decorator which is able to convert a blocking function into an asynchronous) Tj T* 0 Tw .437633 Tw (function. The function, when called, is executed in a separate thread. Moreover, it is possible to set three) Tj T* 0 Tw .074597 Tw (callbacks ) Tj /F5 10 Tf (on_success) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (on_failure ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (on_closing) Tj /F1 10 Tf (, to specify how to manage the function call. The) Tj T* 0 Tw (implementation is the following:) Tj T* ET +BT 1 0 0 1 0 38 Tm .166654 Tw 12 TL /F1 10 Tf 0 0 0 rg (As an example, here I show a decorator which is able to convert a blocking function into an asynchronous) Tj T* 0 Tw .437633 Tw (function. The function, when called, is executed in a separate thread. Moreover, it is possible to set three) Tj T* 0 Tw .074597 Tw (callbacks ) Tj /F4 10 Tf (on_success) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (on_failure ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (on_closing) Tj /F1 10 Tf (, to specify how to manage the function call. The) Tj T* 0 Tw (implementation is the following:) Tj T* ET Q Q q -1 0 0 1 62.69291 104.4236 cm +1 0 0 1 62.69291 152.4236 cm q q 1 0 0 1 0 0 cm @@ -2539,24 +2557,14 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_success) Tj 0 0 0 rg (\() Tj (result) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called on the result of the function") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_success) Tj 0 0 0 rg (\() Tj (result) Tj (\):) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called on the result of the function") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ET Q Q Q Q Q - -endstream - -endobj -% 'R87': class PDFStream -87 0 obj -% page stream -<< /Length 7304 >> -stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 715.8236 cm +1 0 0 1 62.69291 95.22362 cm q q 1 0 0 1 0 0 cm @@ -2569,14 +2577,23 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_failure) Tj 0 0 0 rg (\() Tj (exc_info) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called if the function fails") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_failure) Tj 0 0 0 rg (\() Tj (exc_info) Tj (\):) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called if the function fails") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET Q Q Q Q Q + +endstream +endobj +% 'R86': class PDFStream +86 0 obj +% page stream +<< /Length 7309 >> +stream +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 658.6236 cm +1 0 0 1 62.69291 715.8236 cm q q 1 0 0 1 0 0 cm @@ -2589,14 +2606,14 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_closing) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called at the end, both in case of success and failure") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (on_closing) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# default implementation) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj .729412 .129412 .129412 rg ("Called at the end, both in case of success and failure") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 217.4236 cm +1 0 0 1 62.69291 274.6236 cm q q 1 0 0 1 0 0 cm @@ -2609,27 +2626,27 @@ q n -6 -6 468.6898 432 re B* Q q -BT 1 0 0 1 0 413.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (class) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (Async) Tj /F5 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* ( ) Tj /F7 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( A decorator converting blocking functions into asynchronous) Tj T* ( functions, by using threads or processes. Examples:) Tj T* T* ( async_with_threads = Async\(threading.Thread\)) Tj T* ( async_with_processes = Async\(multiprocessing.Process\)) Tj T* ( """) Tj /F5 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__init__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (threadfactory) Tj (\):) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (threadfactory) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (threadfactory) Tj T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__call__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (,) Tj ( ) Tj (on_success) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_success) Tj (,) Tj T* ( ) Tj (on_failure) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_failure) Tj (,) Tj ( ) Tj (on_closing) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_closing) Tj (\):) Tj T* ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# every decorated function has its own independent thread counter) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (counter) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (itertools) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (count) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_success) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_success) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_failure) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_failure) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_closing) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_closing) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (call) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (call) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (func_wrapper) Tj 0 0 0 rg (\(\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (try) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (except) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_failure) Tj (\() Tj (sys) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (exc_info) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_success) Tj (\() Tj (result) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (finally) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_closing) Tj (\(\)) Tj T* ( ) Tj (name) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (') Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (-) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F5 10 Tf .729412 .129412 .129412 rg (') Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj (next) Tj (\() Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (counter) Tj (\)\)) Tj T* ( ) Tj (thread) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (threadfactory) Tj (\() Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (func_wrapper) Tj (,) Tj ( ) Tj (name) Tj (\)) Tj T* ( ) Tj (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (start) Tj (\(\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (thread) Tj T* ET +BT 1 0 0 1 0 410 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (class) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (Async) Tj /F4 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* ( ) Tj /F6 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( A decorator converting blocking functions into asynchronous) Tj T* ( functions, by using threads or processes. Examples:) Tj T* T* ( async_with_threads = Async\(threading.Thread\)) Tj T* ( async_with_processes = Async\(multiprocessing.Process\)) Tj T* ( """) Tj /F4 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__init__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (threadfactory) Tj (\):) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (threadfactory) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (threadfactory) Tj T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__call__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (,) Tj ( ) Tj (on_success) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_success) Tj (,) Tj T* ( ) Tj (on_failure) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_failure) Tj (,) Tj ( ) Tj (on_closing) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (on_closing) Tj (\):) Tj T* ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# every decorated function has its own independent thread counter) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (counter) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (itertools) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (count) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_success) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_success) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_failure) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_failure) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_closing) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (on_closing) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (decorator) Tj (\() Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (call) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (call) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (func_wrapper) Tj 0 0 0 rg (\(\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (try) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (except) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_failure) Tj (\() Tj (sys) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (exc_info) Tj (\(\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_success) Tj (\() Tj (result) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (finally) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (on_closing) Tj (\(\)) Tj T* ( ) Tj (name) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (') Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (-) Tj /F3 10 Tf .733333 .4 .533333 rg (%s) Tj /F4 10 Tf .729412 .129412 .129412 rg (') Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (%) Tj 0 0 0 rg ( ) Tj (\() Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__name__) Tj (,) Tj ( ) Tj 0 .501961 0 rg (next) Tj 0 0 0 rg (\() Tj (func) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (counter) Tj (\)\)) Tj T* ( ) Tj (thread) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (threadfactory) Tj (\() Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj ( ) Tj (func_wrapper) Tj (,) Tj ( ) Tj (name) Tj (\)) Tj T* ( ) Tj (thread) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (start) Tj (\(\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (thread) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 185.4236 cm +1 0 0 1 62.69291 242.6236 cm q -BT 1 0 0 1 0 16.82 Tm .865984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The decorated function returns the current execution thread, which can be stored and checked later, for) Tj T* 0 Tw (instance to verify that the thread ) Tj /F5 10 Tf (.isAlive\(\)) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 14 Tm .865984 Tw 12 TL /F1 10 Tf 0 0 0 rg (The decorated function returns the current execution thread, which can be stored and checked later, for) Tj T* 0 Tw (instance to verify that the thread ) Tj /F4 10 Tf (.isAlive\(\)) Tj /F1 10 Tf (.) Tj T* ET Q Q q -1 0 0 1 62.69291 143.4236 cm +1 0 0 1 62.69291 200.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 28.82 Tm /F1 10 Tf 12 TL .691654 Tw (Here is an example of usage. Suppose one wants to write some data to an external resource which can) Tj T* 0 Tw .21683 Tw (be accessed by a single user at once \(for instance a printer\). Then the access to the writing function must) Tj T* 0 Tw (be locked. Here is a minimalistic example:) Tj T* ET +BT 1 0 0 1 0 26 Tm /F1 10 Tf 12 TL .691654 Tw (Here is an example of usage. Suppose one wants to write some data to an external resource which can) Tj T* 0 Tw .21683 Tw (be accessed by a single user at once \(for instance a printer\). Then the access to the writing function must) Tj T* 0 Tw (be locked. Here is a minimalistic example:) Tj T* ET Q Q q -1 0 0 1 62.69291 86.22362 cm +1 0 0 1 62.69291 83.42362 cm q q 1 0 0 1 0 0 cm @@ -2639,10 +2656,10 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 48 re B* +n -6 -6 468.6898 108 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (async) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (Async) Tj (\() Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Thread) Tj (\)) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (datalist) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ([]) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# for simplicity the written data are stored into a list.) Tj /F5 10 Tf 0 0 0 rg T* ET +BT 1 0 0 1 0 86 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (async) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (Async) Tj (\() Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Thread) Tj (\)) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (datalist) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj ([]) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# for simplicity the written data are stored into a list.) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@async) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (write) Tj 0 0 0 rg (\() Tj (data) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# append data to the datalist by locking) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Lock) Tj (\(\):) Tj T* ET Q Q Q @@ -2650,16 +2667,15 @@ Q Q endstream - endobj -% 'R88': class PDFStream -88 0 obj +% 'R87': class PDFStream +87 0 obj % page stream -<< /Length 7280 >> +<< /Length 7802 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 655.8236 cm +1 0 0 1 62.69291 715.8236 cm q q 1 0 0 1 0 0 cm @@ -2669,23 +2685,23 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 108 re B* +n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 89.71 Tm 12 TL /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@async) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (write) Tj 0 0 0 rg (\() Tj (data) Tj (\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# append data to the datalist by locking) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (with) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (threading) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (Lock) Tj (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# emulate some long running operation) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (datalist) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (append) Tj (\() Tj (data) Tj (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# other operations not requiring a lock here) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# emulate some long running operation) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj (datalist) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (append) Tj (\() Tj (data) Tj (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# other operations not requiring a lock here) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 623.8236 cm +1 0 0 1 62.69291 683.8236 cm q -BT 1 0 0 1 0 16.82 Tm .905868 Tw 12 TL /F1 10 Tf 0 0 0 rg (Each call to ) Tj /F5 10 Tf (write ) Tj /F1 10 Tf (will create a new writer thread, but there will be no synchronization problems since) Tj T* 0 Tw /F5 10 Tf (write ) Tj /F1 10 Tf (is locked.) Tj T* ET +BT 1 0 0 1 0 14 Tm .905868 Tw 12 TL /F1 10 Tf 0 0 0 rg (Each call to ) Tj /F4 10 Tf (write ) Tj /F1 10 Tf (will create a new writer thread, but there will be no synchronization problems since) Tj T* 0 Tw /F4 10 Tf (write ) Tj /F1 10 Tf (is locked.) Tj T* ET Q Q q -1 0 0 1 62.69291 458.6236 cm +1 0 0 1 62.69291 518.6236 cm q q 1 0 0 1 0 0 cm @@ -2698,32 +2714,32 @@ q n -6 -6 468.6898 156 re B* Q q -BT 1 0 0 1 0 137.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data1") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (.) Tj (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# wait a bit, so we are sure data2 is written after data1) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data2") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# wait for the writers to complete) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (datalist) Tj (\)) Tj T* ([) Tj .729412 .129412 .129412 rg ('data1') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('data2') Tj 0 0 0 rg (]) Tj T* ET +BT 1 0 0 1 0 134 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data1") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (.) Tj (1) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# wait a bit, so we are sure data2 is written after data1) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (write) Tj (\() Tj .729412 .129412 .129412 rg ("data2") Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (Thread) Tj (\() Tj (write) Tj .4 .4 .4 rg (-) Tj (2) Tj 0 0 0 rg (,) Tj ( ) Tj (started) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg (\)) Tj .4 .4 .4 rg (>) Tj 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (time) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (sleep) Tj (\() Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# wait for the writers to complete) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (datalist) Tj (\)) Tj T* ([) Tj .729412 .129412 .129412 rg ('data1') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('data2') Tj 0 0 0 rg (]) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 425.6236 cm +1 0 0 1 62.69291 485.6236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The ) Tj /F3 17.5 Tf (FunctionMaker ) Tj /F2 17.5 Tf (class) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (The ) Tj /F3 17.5 Tf (FunctionMaker ) Tj /F2 17.5 Tf (class) Tj T* ET Q Q q -1 0 0 1 62.69291 359.6236 cm +1 0 0 1 62.69291 419.6236 cm q -BT 1 0 0 1 0 52.82 Tm 2.241412 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may wonder about how the functionality of the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module is implemented. The basic) Tj T* 0 Tw 1.545868 Tw (building block is a ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class which is able to generate on the fly functions with a given) Tj T* 0 Tw .047485 Tw (name and signature from a function template passed as a string. Generally speaking, you should not need) Tj T* 0 Tw 1.164983 Tw (to resort to ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (when writing ordinary decorators, but it is handy in some circumstances.) Tj T* 0 Tw (You will see an example shortly, in the implementation of a cool decorator utility \() Tj /F5 10 Tf (decorator_apply) Tj /F1 10 Tf (\).) Tj T* ET +BT 1 0 0 1 0 50 Tm 2.241412 Tw 12 TL /F1 10 Tf 0 0 0 rg (You may wonder about how the functionality of the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module is implemented. The basic) Tj T* 0 Tw 1.545868 Tw (building block is a ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class which is able to generate on the fly functions with a given) Tj T* 0 Tw .047485 Tw (name and signature from a function template passed as a string. Generally speaking, you should not need) Tj T* 0 Tw 1.164983 Tw (to resort to ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (when writing ordinary decorators, but it is handy in some circumstances.) Tj T* 0 Tw (You will see an example shortly, in the implementation of a cool decorator utility \() Tj /F4 10 Tf (decorator_apply) Tj /F1 10 Tf (\).) Tj T* ET Q Q q -1 0 0 1 62.69291 317.6236 cm +1 0 0 1 62.69291 377.6236 cm q -BT 1 0 0 1 0 28.82 Tm .414597 Tw 12 TL /F5 10 Tf 0 0 0 rg (FunctionMaker ) Tj /F1 10 Tf (provides a ) Tj /F5 10 Tf (.create ) Tj /F1 10 Tf (classmethod which takes as input the name, signature, and body) Tj T* 0 Tw .632927 Tw (of the function we want to generate as well as the execution environment were the function is generated) Tj T* 0 Tw (by ) Tj /F5 10 Tf (exec) Tj /F1 10 Tf (. Here is an example:) Tj T* ET +BT 1 0 0 1 0 26 Tm .414597 Tw 12 TL /F4 10 Tf 0 0 0 rg (FunctionMaker ) Tj /F1 10 Tf (provides a ) Tj /F4 10 Tf (.create ) Tj /F1 10 Tf (classmethod which takes as input the name, signature, and body) Tj T* 0 Tw .632927 Tw (of the function we want to generate as well as the execution environment were the function is generated) Tj T* 0 Tw (by ) Tj /F4 10 Tf (exec) Tj /F1 10 Tf (. Here is an example:) Tj T* ET Q Q q -1 0 0 1 62.69291 224.4236 cm +1 0 0 1 62.69291 284.4236 cm q q 1 0 0 1 0 0 cm @@ -2736,42 +2752,61 @@ q n -6 -6 468.6898 84 re B* Q q -BT 1 0 0 1 0 65.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# a function with a generic signature) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\)\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj ({}) Tj T* ET +BT 1 0 0 1 0 62 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# a function with a generic signature) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (args) Tj (,) Tj ( ) Tj (kw) Tj (\)) Tj T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\)\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj T* (\() Tj .4 .4 .4 rg (1) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (\)) Tj ( ) Tj ({}) Tj T* ET +Q +Q Q Q Q +q +1 0 0 1 62.69291 252.4236 cm +q +BT 1 0 0 1 0 14 Tm .226654 Tw 12 TL /F1 10 Tf 0 0 0 rg (It is important to notice that the function body is interpolated before being executed, so be careful with the) Tj T* 0 Tw /F4 10 Tf (% ) Tj /F1 10 Tf (sign!) Tj T* ET Q Q q -1 0 0 1 62.69291 192.4236 cm +1 0 0 1 62.69291 210.4236 cm q -BT 1 0 0 1 0 16.82 Tm .226654 Tw 12 TL /F1 10 Tf 0 0 0 rg (It is important to notice that the function body is interpolated before being executed, so be careful with the) Tj T* 0 Tw /F5 10 Tf (% ) Tj /F1 10 Tf (sign!) Tj T* ET +BT 1 0 0 1 0 26 Tm 1.995433 Tw 12 TL /F4 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (also accepts keyword arguments and such arguments are attached to the) Tj T* 0 Tw 1.64686 Tw (resulting function. This is useful if you want to set some function attributes, for instance the docstring) Tj T* 0 Tw /F4 10 Tf (__doc__) Tj /F1 10 Tf (.) Tj T* ET Q Q q -1 0 0 1 62.69291 150.4236 cm +1 0 0 1 62.69291 168.4236 cm q -BT 1 0 0 1 0 28.82 Tm 1.995433 Tw 12 TL /F5 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (also accepts keyword arguments and such arguments are attached to the) Tj T* 0 Tw 1.64686 Tw (resulting function. This is useful if you want to set some function attributes, for instance the docstring) Tj T* 0 Tw /F5 10 Tf (__doc__) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 26 Tm .605318 Tw 12 TL /F1 10 Tf 0 0 0 rg (For debugging/introspection purposes it may be useful to see the source code of the generated function;) Tj T* 0 Tw 2.246235 Tw (to do that, just pass the flag ) Tj /F4 10 Tf (addsource=True ) Tj /F1 10 Tf (and a ) Tj /F4 10 Tf (__source__ ) Tj /F1 10 Tf (attribute will be added to the) Tj T* 0 Tw (generated function:) Tj T* ET Q Q q -1 0 0 1 62.69291 108.4236 cm +1 0 0 1 62.69291 87.22362 cm +q +q +1 0 0 1 0 0 cm +q +1 0 0 1 6.6 6.6 cm +q +.662745 .662745 .662745 RG +.5 w +.960784 .960784 .862745 rg +n -6 -6 468.6898 72 re B* +Q q -BT 1 0 0 1 0 28.82 Tm .605318 Tw 12 TL /F1 10 Tf 0 0 0 rg (For debugging/introspection purposes it may be useful to see the source code of the generated function;) Tj T* 0 Tw 2.246235 Tw (to do that, just pass the flag ) Tj /F5 10 Tf (addsource=True ) Tj /F1 10 Tf (and a ) Tj /F5 10 Tf (__source__ ) Tj /F1 10 Tf (attribute will be added to the) Tj T* 0 Tw (generated function:) Tj T* ET +BT 1 0 0 1 0 50 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\),) Tj ( ) Tj (addsource) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (f1) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__source__) Tj (\)) Tj T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\):) Tj T* ( ) Tj (f) Tj (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\)) Tj T* ET +Q +Q +Q Q Q endstream - endobj -% 'R89': class PDFStream -89 0 obj +% 'R88': class PDFStream +88 0 obj % page stream -<< /Length 7605 >> +<< /Length 7919 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 679.8236 cm +1 0 0 1 62.69291 739.8236 cm q q 1 0 0 1 0 0 cm @@ -2781,41 +2816,41 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 84 re B* +n -6 -6 468.6898 24 re B* Q q -BT 1 0 0 1 0 65.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj (\),) Tj ( ) Tj (addsource) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (\)) Tj T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (f1) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (__source__) Tj (\)) Tj T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f1) Tj 0 0 0 rg (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\):) Tj T* ( ) Tj (f) Tj (\() Tj (a) Tj (,) Tj ( ) Tj (b) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 539.8236 cm +1 0 0 1 62.69291 599.8236 cm q -BT 1 0 0 1 0 124.82 Tm .870651 Tw 12 TL /F5 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (can take as first argument a string, as in the examples before, or a function.) Tj T* 0 Tw .224985 Tw (This is the most common usage, since typically you want to decorate a pre-existing function. A framework) Tj T* 0 Tw 1.606136 Tw (author may want to use directly ) Tj /F5 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (instead of ) Tj /F5 10 Tf (decorator) Tj /F1 10 Tf (, since it gives you) Tj T* 0 Tw 1.36686 Tw (direct access to the body of the generated function. For instance, suppose you want to instrument the) Tj T* 0 Tw .372209 Tw /F5 10 Tf (__init__ ) Tj /F1 10 Tf (methods of a set of classes, by preserving their signature \(such use case is not made up; this) Tj T* 0 Tw .673828 Tw (is done in SQAlchemy and in other frameworks\). When the first argument of ) Tj /F5 10 Tf (FunctionMaker.create) Tj T* 0 Tw 3.405814 Tw /F1 10 Tf (is a function, a ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (object is instantiated internally, with attributes ) Tj /F5 10 Tf (args) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (varargs) Tj /F1 10 Tf (,) Tj T* 0 Tw 5.509982 Tw /F5 10 Tf (keywords ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (defaults ) Tj /F1 10 Tf (which are the the return values of the standard library function) Tj T* 0 Tw .561318 Tw /F5 10 Tf (inspect.getargspec) Tj /F1 10 Tf (. For each argument in the ) Tj /F5 10 Tf (args ) Tj /F1 10 Tf (\(which is a list of strings containing the names) Tj T* 0 Tw 1.599985 Tw (of the mandatory arguments\) an attribute ) Tj /F5 10 Tf (arg0) Tj /F1 10 Tf (, ) Tj /F5 10 Tf (arg1) Tj /F1 10 Tf (, ..., ) Tj /F5 10 Tf (argN ) Tj /F1 10 Tf (is also generated. Finally, there is a) Tj T* 0 Tw /F5 10 Tf (signature ) Tj /F1 10 Tf (attribute, a string with the signature of the original function.) Tj T* ET +BT 1 0 0 1 0 122 Tm .870651 Tw 12 TL /F4 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf (can take as first argument a string, as in the examples before, or a function.) Tj T* 0 Tw .224985 Tw (This is the most common usage, since typically you want to decorate a pre-existing function. A framework) Tj T* 0 Tw 1.606136 Tw (author may want to use directly ) Tj /F4 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (instead of ) Tj /F4 10 Tf (decorator) Tj /F1 10 Tf (, since it gives you) Tj T* 0 Tw 1.36686 Tw (direct access to the body of the generated function. For instance, suppose you want to instrument the) Tj T* 0 Tw .372209 Tw /F4 10 Tf (__init__ ) Tj /F1 10 Tf (methods of a set of classes, by preserving their signature \(such use case is not made up; this) Tj T* 0 Tw .673828 Tw (is done in SQAlchemy and in other frameworks\). When the first argument of ) Tj /F4 10 Tf (FunctionMaker.create) Tj T* 0 Tw 3.405814 Tw /F1 10 Tf (is a function, a ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (object is instantiated internally, with attributes ) Tj /F4 10 Tf (args) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (varargs) Tj /F1 10 Tf (,) Tj T* 0 Tw 5.509982 Tw /F4 10 Tf (keywords ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (defaults ) Tj /F1 10 Tf (which are the the return values of the standard library function) Tj T* 0 Tw .561318 Tw /F4 10 Tf (inspect.getargspec) Tj /F1 10 Tf (. For each argument in the ) Tj /F4 10 Tf (args ) Tj /F1 10 Tf (\(which is a list of strings containing the names) Tj T* 0 Tw 1.599985 Tw (of the mandatory arguments\) an attribute ) Tj /F4 10 Tf (arg0) Tj /F1 10 Tf (, ) Tj /F4 10 Tf (arg1) Tj /F1 10 Tf (, ..., ) Tj /F4 10 Tf (argN ) Tj /F1 10 Tf (is also generated. Finally, there is a) Tj T* 0 Tw /F4 10 Tf (signature ) Tj /F1 10 Tf (attribute, a string with the signature of the original function.) Tj T* ET Q Q q -1 0 0 1 62.69291 461.8236 cm +1 0 0 1 62.69291 521.8236 cm q -BT 1 0 0 1 0 64.82 Tm 4.63311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that while I do not have plans to change or remove the functionality provided in the) Tj T* 0 Tw 1.00936 Tw /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class, I do not guarantee that it will stay unchanged forever. For instance, right now I) Tj T* 0 Tw .791318 Tw (am using the traditional string interpolation syntax for function templates, but Python 2.6 and Python 3.0) Tj T* 0 Tw .712093 Tw (provide a newer interpolation syntax and I may use the new syntax in the future. On the other hand, the) Tj T* 0 Tw .639985 Tw (functionality provided by ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (has been there from version 0.1 and it is guaranteed to stay there) Tj T* 0 Tw (forever.) Tj T* ET +BT 1 0 0 1 0 62 Tm 4.63311 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that while I do not have plans to change or remove the functionality provided in the) Tj T* 0 Tw 1.00936 Tw /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (class, I do not guarantee that it will stay unchanged forever. For instance, right now I) Tj T* 0 Tw .791318 Tw (am using the traditional string interpolation syntax for function templates, but Python 2.6 and Python 3.0) Tj T* 0 Tw .712093 Tw (provide a newer interpolation syntax and I may use the new syntax in the future. On the other hand, the) Tj T* 0 Tw .639985 Tw (functionality provided by ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (has been there from version 0.1 and it is guaranteed to stay there) Tj T* 0 Tw (forever.) Tj T* ET Q Q q -1 0 0 1 62.69291 428.8236 cm +1 0 0 1 62.69291 488.8236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Getting the source code) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Getting the source code) Tj T* ET Q Q q -1 0 0 1 62.69291 350.8236 cm +1 0 0 1 62.69291 410.8236 cm q -BT 1 0 0 1 0 64.82 Tm 5.045529 Tw 12 TL /F1 10 Tf 0 0 0 rg (Internally ) Tj /F5 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (uses ) Tj /F5 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Therefore) Tj T* 0 Tw 2.542126 Tw /F5 10 Tf (inspect.getsource ) Tj /F1 10 Tf (will not work for decorated functions. That means that the usual '??' trick in) Tj T* 0 Tw 2.163059 Tw (IPython will give you the \(right on the spot\) message ) Tj /F5 10 Tf (Dynamically generated function. No) Tj T* 0 Tw .563314 Tw (source code available) Tj /F1 10 Tf (. In the past I have considered this acceptable, since ) Tj /F5 10 Tf (inspect.getsource) Tj T* 0 Tw 1.790697 Tw /F1 10 Tf (does not really work even with regular decorators. In that case ) Tj /F5 10 Tf (inspect.getsource ) Tj /F1 10 Tf (gives you the) Tj T* 0 Tw (wrapper source code which is probably not what you want:) Tj T* ET +BT 1 0 0 1 0 62 Tm 5.045529 Tw 12 TL /F1 10 Tf 0 0 0 rg (Internally ) Tj /F4 10 Tf (FunctionMaker.create ) Tj /F1 10 Tf (uses ) Tj /F4 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Therefore) Tj T* 0 Tw 2.542126 Tw /F4 10 Tf (inspect.getsource ) Tj /F1 10 Tf (will not work for decorated functions. That means that the usual '??' trick in) Tj T* 0 Tw 2.163059 Tw (IPython will give you the \(right on the spot\) message ) Tj /F4 10 Tf (Dynamically generated function. No) Tj T* 0 Tw .563314 Tw (source code available) Tj /F1 10 Tf (. In the past I have considered this acceptable, since ) Tj /F4 10 Tf (inspect.getsource) Tj T* 0 Tw 1.790697 Tw /F1 10 Tf (does not really work even with regular decorators. In that case ) Tj /F4 10 Tf (inspect.getsource ) Tj /F1 10 Tf (gives you the) Tj T* 0 Tw (wrapper source code which is probably not what you want:) Tj T* ET Q Q q -1 0 0 1 62.69291 281.6236 cm +1 0 0 1 62.69291 341.6236 cm q q 1 0 0 1 0 0 cm @@ -2828,14 +2863,14 @@ q n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 41.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (identity_dec) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (wrapper) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (wrapper) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (identity_dec) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (wrapper) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (wrapper) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 176.4236 cm +1 0 0 1 62.69291 236.4236 cm q q 1 0 0 1 0 0 cm @@ -2848,30 +2883,49 @@ q n -6 -6 468.6898 96 re B* Q q -BT 1 0 0 1 0 77.71 Tm 12 TL /F5 10 Tf .666667 .133333 1 rg (@identity_dec) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (example) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (example) Tj (\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (wrapper) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET +BT 1 0 0 1 0 74 Tm 12 TL /F4 10 Tf .666667 .133333 1 rg (@identity_dec) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (example) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (example) Tj (\)\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (wrapper) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET +Q Q Q Q Q +q +1 0 0 1 62.69291 180.4236 cm +q +BT 1 0 0 1 0 38 Tm 1.471235 Tw 12 TL /F1 10 Tf 0 0 0 rg (\(see bug report ) Tj 0 0 .501961 rg (1764286 ) Tj 0 0 0 rg (for an explanation of what is happening\). Unfortunately the bug is still there,) Tj T* 0 Tw 1.541235 Tw (even in Python 2.7 and 3.1. There is however a workaround. The decorator module adds an attribute) Tj T* 0 Tw .103984 Tw /F4 10 Tf (.undecorated ) Tj /F1 10 Tf (to the decorated function, containing a reference to the original function. The easy way to) Tj T* 0 Tw (get the source code is to call ) Tj /F4 10 Tf (inspect.getsource ) Tj /F1 10 Tf (on the undecorated function:) Tj T* ET +Q Q q -1 0 0 1 62.69291 120.4236 cm +1 0 0 1 62.69291 87.22362 cm +q +q +1 0 0 1 0 0 cm +q +1 0 0 1 6.6 6.6 cm q -BT 1 0 0 1 0 40.82 Tm 1.471235 Tw 12 TL /F1 10 Tf 0 0 0 rg (\(see bug report ) Tj 0 0 .501961 rg (1764286 ) Tj 0 0 0 rg (for an explanation of what is happening\). Unfortunately the bug is still there,) Tj T* 0 Tw 1.541235 Tw (even in Python 2.6 and 3.0. There is however a workaround. The decorator module adds an attribute) Tj T* 0 Tw .103984 Tw /F5 10 Tf (.undecorated ) Tj /F1 10 Tf (to the decorated function, containing a reference to the original function. The easy way to) Tj T* 0 Tw (get the source code is to call ) Tj /F5 10 Tf (inspect.getsource ) Tj /F1 10 Tf (on the undecorated function:) Tj T* ET +.662745 .662745 .662745 RG +.5 w +.960784 .960784 .862745 rg +n -6 -6 468.6898 84 re B* +Q +q +BT 1 0 0 1 0 62 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (factorial) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (undecorated) Tj (\)\)) Tj T* .666667 .133333 1 rg (@tail_recursive) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (factorial) Tj 0 0 0 rg (\() Tj (n) Tj (,) Tj ( ) Tj (acc) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (\):) Tj T* ( ) Tj .729412 .129412 .129412 rg ("The good old factorial") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (acc) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (n) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (acc) Tj (\)) Tj T* ET +Q +Q +Q Q Q endstream - endobj -% 'R90': class PDFStream -90 0 obj +% 'R89': class PDFStream +89 0 obj % page stream -<< /Length 7166 >> +<< /Length 7154 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 667.8236 cm +1 0 0 1 62.69291 739.8236 cm q q 1 0 0 1 0 0 cm @@ -2881,29 +2935,29 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 96 re B* +n -6 -6 468.6898 24 re B* Q q -BT 1 0 0 1 0 77.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj (\() Tj (factorial) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (undecorated) Tj (\)\)) Tj T* .666667 .133333 1 rg (@tail_recursive) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (factorial) Tj 0 0 0 rg (\() Tj (n) Tj (,) Tj ( ) Tj (acc) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (\):) Tj T* ( ) Tj .729412 .129412 .129412 rg ("The good old factorial") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (acc) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (n) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (acc) Tj (\)) Tj T* .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET +BT 1 0 0 1 0 2 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (<) Tj 0 0 0 rg (BLANKLINE) Tj .4 .4 .4 rg (>) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 634.8236 cm +1 0 0 1 62.69291 706.8236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Dealing with third party decorators) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Dealing with third party decorators) Tj T* ET Q Q q -1 0 0 1 62.69291 580.8236 cm +1 0 0 1 62.69291 652.8236 cm q -BT 1 0 0 1 0 40.82 Tm .321654 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes you find on the net some cool decorator that you would like to include in your code. However,) Tj T* 0 Tw .50061 Tw (more often than not the cool decorator is not signature-preserving. Therefore you may want an easy way) Tj T* 0 Tw 1.814597 Tw (to upgrade third party decorators to signature-preserving decorators without having to rewrite them in) Tj T* 0 Tw (terms of ) Tj /F5 10 Tf (decorator) Tj /F1 10 Tf (. You can use a ) Tj /F5 10 Tf (FunctionMaker ) Tj /F1 10 Tf (to implement that functionality as follows:) Tj T* ET +BT 1 0 0 1 0 38 Tm .321654 Tw 12 TL /F1 10 Tf 0 0 0 rg (Sometimes you find on the net some cool decorator that you would like to include in your code. However,) Tj T* 0 Tw .50061 Tw (more often than not the cool decorator is not signature-preserving. Therefore you may want an easy way) Tj T* 0 Tw 1.814597 Tw (to upgrade third party decorators to signature-preserving decorators without having to rewrite them in) Tj T* 0 Tw (terms of ) Tj /F4 10 Tf (decorator) Tj /F1 10 Tf (. You can use a ) Tj /F4 10 Tf (FunctionMaker ) Tj /F1 10 Tf (to implement that functionality as follows:) Tj T* ET Q Q q -1 0 0 1 62.69291 463.6236 cm +1 0 0 1 62.69291 535.6236 cm q q 1 0 0 1 0 0 cm @@ -2916,28 +2970,28 @@ q n -6 -6 468.6898 108 re B* Q q -BT 1 0 0 1 0 89.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (decorator_apply) Tj 0 0 0 rg (\() Tj (dec) Tj (,) Tj ( ) Tj (func) Tj (\):) Tj T* ( ) Tj /F7 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( Decorate a function by preserving the signature even if dec) Tj T* ( is not a signature-preserving decorator.) Tj T* ( """) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj T* ( ) Tj (func) Tj (,) Tj ( ) Tj .729412 .129412 .129412 rg ('return decorated\() Tj /F3 10 Tf .733333 .4 .533333 rg (%\(signature\)s) Tj /F5 10 Tf .729412 .129412 .129412 rg (\)') Tj 0 0 0 rg (,) Tj T* ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (decorated) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (dec) Tj (\() Tj (func) Tj (\)\),) Tj ( ) Tj (undecorated) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (func) Tj (\)) Tj T* ET +BT 1 0 0 1 0 86 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (decorator_apply) Tj 0 0 0 rg (\() Tj (dec) Tj (,) Tj ( ) Tj (func) Tj (\):) Tj T* ( ) Tj /F6 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( Decorate a function by preserving the signature even if dec) Tj T* ( is not a signature-preserving decorator.) Tj T* ( """) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj (\() Tj T* ( ) Tj (func) Tj (,) Tj ( ) Tj .729412 .129412 .129412 rg ('return decorated\() Tj /F3 10 Tf .733333 .4 .533333 rg (%\(signature\)s) Tj /F4 10 Tf .729412 .129412 .129412 rg (\)') Tj 0 0 0 rg (,) Tj T* ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj (decorated) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (dec) Tj (\() Tj (func) Tj (\)\),) Tj ( ) Tj (undecorated) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (func) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 431.6236 cm +1 0 0 1 62.69291 503.6236 cm q -BT 1 0 0 1 0 16.82 Tm .698314 Tw 12 TL /F5 10 Tf 0 0 0 rg (decorator_apply ) Tj /F1 10 Tf (sets the attribute ) Tj /F5 10 Tf (.undecorated ) Tj /F1 10 Tf (of the generated function to the original function,) Tj T* 0 Tw (so that you can get the right source code.) Tj T* ET +BT 1 0 0 1 0 14 Tm .698314 Tw 12 TL /F4 10 Tf 0 0 0 rg (decorator_apply ) Tj /F1 10 Tf (sets the attribute ) Tj /F4 10 Tf (.undecorated ) Tj /F1 10 Tf (of the generated function to the original function,) Tj T* 0 Tw (so that you can get the right source code.) Tj T* ET Q Q q -1 0 0 1 62.69291 389.6236 cm +1 0 0 1 62.69291 461.6236 cm q -BT 1 0 0 1 0 28.82 Tm .13104 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that I am not providing this functionality in the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module directly since I think it is best to) Tj T* 0 Tw 2.070751 Tw (rewrite the decorator rather than adding an additional level of indirection. However, practicality beats) Tj T* 0 Tw (purity, so you can add ) Tj /F5 10 Tf (decorator_apply ) Tj /F1 10 Tf (to your toolbox and use it if you need to.) Tj T* ET +BT 1 0 0 1 0 26 Tm .13104 Tw 12 TL /F1 10 Tf 0 0 0 rg (Notice that I am not providing this functionality in the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module directly since I think it is best to) Tj T* 0 Tw 2.070751 Tw (rewrite the decorator rather than adding an additional level of indirection. However, practicality beats) Tj T* 0 Tw (purity, so you can add ) Tj /F4 10 Tf (decorator_apply ) Tj /F1 10 Tf (to your toolbox and use it if you need to.) Tj T* ET Q Q q -1 0 0 1 62.69291 335.6236 cm +1 0 0 1 62.69291 407.6236 cm q -BT 1 0 0 1 0 40.82 Tm 1.74881 Tw 12 TL /F1 10 Tf 0 0 0 rg (In order to give an example of usage of ) Tj /F5 10 Tf (decorator_apply) Tj /F1 10 Tf (, I will show a pretty slick decorator that) Tj T* 0 Tw 1.276651 Tw (converts a tail-recursive function in an iterative function. I have shamelessly stolen the basic idea from) Tj T* 0 Tw 43.62829 Tw (Kay Schluehr's recipe in the Python Cookbook,) Tj T* 0 Tw 0 0 .501961 rg (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj 0 0 0 rg (.) Tj T* ET +BT 1 0 0 1 0 38 Tm 1.74881 Tw 12 TL /F1 10 Tf 0 0 0 rg (In order to give an example of usage of ) Tj /F4 10 Tf (decorator_apply) Tj /F1 10 Tf (, I will show a pretty slick decorator that) Tj T* 0 Tw 1.276651 Tw (converts a tail-recursive function in an iterative function. I have shamelessly stolen the basic idea from) Tj T* 0 Tw 43.62829 Tw (Kay Schluehr's recipe in the Python Cookbook,) Tj T* 0 Tw 0 0 .501961 rg (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj 0 0 0 rg (.) Tj T* ET Q Q q @@ -2951,10 +3005,10 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 240 re B* +n -6 -6 468.6898 312 re B* Q q -BT 1 0 0 1 0 221.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (class) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (TailRecursive) Tj /F5 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* ( ) Tj /F7 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( tail_recursive decorator based on Kay Schluehr's recipe) Tj T* ( http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj T* ( with improvements by me and George Sakkis.) Tj T* ( """) Tj /F5 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__init__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (\):) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (CONTINUE) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\(\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# sentinel) Tj /F5 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__call__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kwd) Tj (\):) Tj T* ( ) Tj (CONTINUE) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (CONTINUE) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj (:) Tj T* ( ) Tj (func) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (False) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (try) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (while) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (:) Tj T* ET +BT 1 0 0 1 0 290 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (class) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F3 10 Tf 0 0 1 rg (TailRecursive) Tj /F4 10 Tf 0 0 0 rg (\() Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\):) Tj T* ( ) Tj /F6 10 Tf .729412 .129412 .129412 rg (""") Tj T* ( tail_recursive decorator based on Kay Schluehr's recipe) Tj T* ( http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) Tj T* ( with improvements by me and George Sakkis.) Tj T* ( """) Tj /F4 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__init__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj (func) Tj (\):) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (CONTINUE) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (object) Tj 0 0 0 rg (\(\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# sentinel) Tj /F4 10 Tf 0 0 0 rg T* T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (__call__) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (self) Tj 0 0 0 rg (,) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kwd) Tj (\):) Tj T* ( ) Tj (CONTINUE) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (CONTINUE) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj (:) Tj T* ( ) Tj (func) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (func) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (False) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (try) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (while) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (:) Tj T* ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kwd) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (result) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (is) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (CONTINUE) Tj (:) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# update arguments) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj (args) Tj (,) Tj ( ) Tj (kwd) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (argskwd) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# last call) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (finally) Tj /F4 10 Tf 0 0 0 rg (:) Tj T* ET Q Q Q @@ -2962,16 +3016,15 @@ Q Q endstream - endobj -% 'R91': class PDFStream -91 0 obj +% 'R90': class PDFStream +90 0 obj % page stream -<< /Length 6779 >> +<< /Length 5831 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 631.8236 cm +1 0 0 1 62.69291 703.8236 cm q q 1 0 0 1 0 0 cm @@ -2981,24 +3034,24 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 132 re B* +n -6 -6 468.6898 60 re B* Q q -BT 1 0 0 1 0 113.71 Tm 12 TL /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (func) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kwd) Tj (\)) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (is) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (CONTINUE) Tj (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# update arguments) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj (args) Tj (,) Tj ( ) Tj (kwd) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (argskwd) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# last call) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (result) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (finally) Tj /F5 10 Tf 0 0 0 rg (:) Tj T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# return the arguments of the tail call) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (argskwd) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (kwd) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (CONTINUE) Tj T* ET +BT 1 0 0 1 0 38 Tm 12 TL /F4 10 Tf 0 0 0 rg ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (firstcall) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (else) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# return the arguments of the tail call) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj 0 .501961 0 rg (self) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (argskwd) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (args) Tj (,) Tj ( ) Tj (kwd) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (CONTINUE) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 611.8236 cm +1 0 0 1 62.69291 683.8236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here the decorator is implemented as a class returning callable objects.) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here the decorator is implemented as a class returning callable objects.) Tj T* ET Q Q q -1 0 0 1 62.69291 566.6236 cm +1 0 0 1 62.69291 638.6236 cm q q 1 0 0 1 0 0 cm @@ -3011,21 +3064,21 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (tail_recursive) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (decorator_apply) Tj (\() Tj (TailRecursive) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (tail_recursive) Tj 0 0 0 rg (\() Tj (func) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (decorator_apply) Tj (\() Tj (TailRecursive) Tj (,) Tj ( ) Tj (func) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 546.6236 cm +1 0 0 1 62.69291 618.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 4.82 Tm /F1 10 Tf 12 TL (Here is how you apply the upgraded decorator to the good old factorial:) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is how you apply the upgraded decorator to the good old factorial:) Tj T* ET Q Q q -1 0 0 1 62.69291 465.4236 cm +1 0 0 1 62.69291 537.4236 cm q q 1 0 0 1 0 0 cm @@ -3038,14 +3091,14 @@ q n -6 -6 468.6898 72 re B* Q q -BT 1 0 0 1 0 53.71 Tm 12 TL /F5 10 Tf .666667 .133333 1 rg (@tail_recursive) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (factorial) Tj 0 0 0 rg (\() Tj (n) Tj (,) Tj ( ) Tj (acc) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (\):) Tj T* ( ) Tj .729412 .129412 .129412 rg ("The good old factorial") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (acc) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (n) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (acc) Tj (\)) Tj T* ET +BT 1 0 0 1 0 50 Tm 12 TL /F4 10 Tf .666667 .133333 1 rg (@tail_recursive) Tj 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (factorial) Tj 0 0 0 rg (\() Tj (n) Tj (,) Tj ( ) Tj (acc) Tj .4 .4 .4 rg (=) Tj (1) Tj 0 0 0 rg (\):) Tj T* ( ) Tj .729412 .129412 .129412 rg ("The good old factorial") Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (acc) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (factorial) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (,) Tj ( ) Tj (n) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (acc) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 420.2236 cm +1 0 0 1 62.69291 492.2236 cm q q 1 0 0 1 0 0 cm @@ -3058,20 +3111,20 @@ q n -6 -6 468.6898 36 re B* Q q -BT 1 0 0 1 0 17.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (factorial) Tj (\() Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (\)\)) Tj T* .4 .4 .4 rg (24) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (factorial) Tj (\() Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (\)\)) Tj T* .4 .4 .4 rg (24) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 364.2236 cm +1 0 0 1 62.69291 436.2236 cm q -BT 1 0 0 1 0 40.82 Tm .188935 Tw 12 TL /F1 10 Tf 0 0 0 rg (This decorator is pretty impressive, and should give you some food for your mind ;\) Notice that there is no) Tj T* 0 Tw 1.339983 Tw (recursion limit now, and you can easily compute ) Tj /F5 10 Tf (factorial\(1001\) ) Tj /F1 10 Tf (or larger without filling the stack) Tj T* 0 Tw .909431 Tw (frame. Notice also that the decorator will not work on functions which are not tail recursive, such as the) Tj T* 0 Tw (following) Tj T* ET +BT 1 0 0 1 0 38 Tm .188935 Tw 12 TL /F1 10 Tf 0 0 0 rg (This decorator is pretty impressive, and should give you some food for your mind ;\) Notice that there is no) Tj T* 0 Tw 1.339983 Tw (recursion limit now, and you can easily compute ) Tj /F4 10 Tf (factorial\(1001\) ) Tj /F1 10 Tf (or larger without filling the stack) Tj T* 0 Tw .909431 Tw (frame. Notice also that the decorator will not work on functions which are not tail recursive, such as the) Tj T* 0 Tw (following) Tj T* ET Q Q q -1 0 0 1 62.69291 307.0236 cm +1 0 0 1 62.69291 379.0236 cm q q 1 0 0 1 0 0 cm @@ -3084,30 +3137,30 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (fact) Tj 0 0 0 rg (\() Tj (n) Tj (\):) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# this is not tail-recursive) Tj /F5 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg ( ) Tj (fact) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (\)) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (fact) Tj 0 0 0 rg (\() Tj (n) Tj (\):) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# this is not tail-recursive) Tj /F4 10 Tf 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (if) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (==) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg (:) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (n) Tj ( ) Tj .4 .4 .4 rg (*) Tj 0 0 0 rg ( ) Tj (fact) Tj (\() Tj (n) Tj .4 .4 .4 rg (-) Tj (1) Tj 0 0 0 rg (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 275.0236 cm +1 0 0 1 62.69291 347.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .541098 Tw (\(reminder: a function is tail recursive if it either returns a value without making a recursive call, or returns) Tj T* 0 Tw (directly the result of a recursive call\).) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .541098 Tw (\(reminder: a function is tail recursive if it either returns a value without making a recursive call, or returns) Tj T* 0 Tw (directly the result of a recursive call\).) Tj T* ET Q Q q -1 0 0 1 62.69291 242.0236 cm +1 0 0 1 62.69291 314.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Caveats and limitations) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Caveats and limitations) Tj T* ET Q Q q -1 0 0 1 62.69291 212.0236 cm +1 0 0 1 62.69291 284.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .474987 Tw (The first thing you should be aware of, it the fact that decorators have a performance penalty. The worse) Tj T* 0 Tw (case is shown by the following example:) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .474987 Tw (The first thing you should be aware of, it the fact that decorators have a performance penalty. The worse) Tj T* 0 Tw (case is shown by the following example:) Tj T* ET Q Q q @@ -3121,11 +3174,11 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 120 re B* +n -6 -6 468.6898 192 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 101.71 Tm /F5 10 Tf 12 TL ($ cat performance.sh) Tj T* (python3 -m timeit -s ") Tj T* (from decorator import decorator) Tj T* T* (@decorator) Tj T* (def do_nothing\(func, *args, **kw\):) Tj T* ( return func\(*args, **kw\)) Tj T* T* (@do_nothing) Tj T* ET +BT 1 0 0 1 0 170 Tm /F4 10 Tf 12 TL ($ cat performance.sh) Tj T* (python3 -m timeit -s ") Tj T* (from decorator import decorator) Tj T* T* (@decorator) Tj T* (def do_nothing\(func, *args, **kw\):) Tj T* ( return func\(*args, **kw\)) Tj T* T* (@do_nothing) Tj T* (def f\(\):) Tj T* ( pass) Tj T* (" "f\(\)") Tj T* T* (python3 -m timeit -s ") Tj T* (def f\(\):) Tj T* ET Q Q Q @@ -3133,16 +3186,15 @@ Q Q endstream - endobj -% 'R92': class PDFStream -92 0 obj +% 'R91': class PDFStream +91 0 obj % page stream -<< /Length 6628 >> +<< /Length 7401 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 655.8236 cm +1 0 0 1 62.69291 727.8236 cm q q 1 0 0 1 0 0 cm @@ -3152,24 +3204,24 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 108 re B* +n -6 -6 468.6898 36 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 89.71 Tm /F5 10 Tf 12 TL (def f\(\):) Tj T* ( pass) Tj T* (" "f\(\)") Tj T* T* (python3 -m timeit -s ") Tj T* (def f\(\):) Tj T* ( pass) Tj T* (" "f\(\)") Tj T* ET +BT 1 0 0 1 0 14 Tm /F4 10 Tf 12 TL ( pass) Tj T* (" "f\(\)") Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 623.8236 cm +1 0 0 1 62.69291 695.8236 cm q -BT 1 0 0 1 0 16.82 Tm .266235 Tw 12 TL /F1 10 Tf 0 0 0 rg (On my MacBook, using the ) Tj /F5 10 Tf (do_nothing ) Tj /F1 10 Tf (decorator instead of the plain function is more than three times) Tj T* 0 Tw (slower:) Tj T* ET +BT 1 0 0 1 0 14 Tm .266235 Tw 12 TL /F1 10 Tf 0 0 0 rg (On my MacBook, using the ) Tj /F4 10 Tf (do_nothing ) Tj /F1 10 Tf (decorator instead of the plain function is more than three times) Tj T* 0 Tw (slower:) Tj T* ET Q Q q -1 0 0 1 62.69291 566.6236 cm +1 0 0 1 62.69291 638.6236 cm q q 1 0 0 1 0 0 cm @@ -3183,27 +3235,27 @@ n -6 -6 468.6898 48 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 29.71 Tm /F5 10 Tf 12 TL ($ bash performance.sh) Tj T* (1000000 loops, best of 3: 0.669 usec per loop) Tj T* (1000000 loops, best of 3: 0.181 usec per loop) Tj T* ET +BT 1 0 0 1 0 26 Tm /F4 10 Tf 12 TL ($ bash performance.sh) Tj T* (1000000 loops, best of 3: 0.669 usec per loop) Tj T* (1000000 loops, best of 3: 0.181 usec per loop) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 522.6236 cm +1 0 0 1 62.69291 594.6236 cm q -BT 1 0 0 1 0 28.82 Tm 1.25832 Tw 12 TL /F1 10 Tf 0 0 0 rg (It should be noted that a real life function would probably do something more useful than ) Tj /F5 10 Tf (f ) Tj /F1 10 Tf (here, and) Tj T* 0 Tw .91811 Tw (therefore in real life the performance penalty could be completely negligible. As always, the only way to) Tj T* 0 Tw (know if there is a penalty in your specific use case is to measure it.) Tj T* ET +BT 1 0 0 1 0 26 Tm 1.25832 Tw 12 TL /F1 10 Tf 0 0 0 rg (It should be noted that a real life function would probably do something more useful than ) Tj /F4 10 Tf (f ) Tj /F1 10 Tf (here, and) Tj T* 0 Tw .91811 Tw (therefore in real life the performance penalty could be completely negligible. As always, the only way to) Tj T* 0 Tw (know if there is a penalty in your specific use case is to measure it.) Tj T* ET Q Q q -1 0 0 1 62.69291 492.6236 cm +1 0 0 1 62.69291 564.6236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .867984 Tw (You should be aware that decorators will make your tracebacks longer and more difficult to understand.) Tj T* 0 Tw (Consider this example:) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .867984 Tw (You should be aware that decorators will make your tracebacks longer and more difficult to understand.) Tj T* 0 Tw (Consider this example:) Tj T* ET Q Q q -1 0 0 1 62.69291 435.4236 cm +1 0 0 1 62.69291 507.4236 cm q q 1 0 0 1 0 0 cm @@ -3216,20 +3268,20 @@ q n -6 -6 468.6898 48 re B* Q q -BT 1 0 0 1 0 29.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj T* ET +BT 1 0 0 1 0 26 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 403.4236 cm +1 0 0 1 62.69291 475.4236 cm q -BT 1 0 0 1 0 16.82 Tm .583318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Calling ) Tj /F5 10 Tf (f\(\) ) Tj /F1 10 Tf (will give you a ) Tj /F5 10 Tf (ZeroDivisionError) Tj /F1 10 Tf (, but since the function is decorated the traceback will) Tj T* 0 Tw (be longer:) Tj T* ET +BT 1 0 0 1 0 14 Tm .583318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Calling ) Tj /F4 10 Tf (f\(\) ) Tj /F1 10 Tf (will give you a ) Tj /F4 10 Tf (ZeroDivisionError) Tj /F1 10 Tf (, but since the function is decorated the traceback will) Tj T* 0 Tw (be longer:) Tj T* ET Q Q q -1 0 0 1 62.69291 274.2236 cm +1 0 0 1 62.69291 346.2236 cm q q 1 0 0 1 0 0 cm @@ -3242,48 +3294,67 @@ q n -6 -6 468.6898 120 re B* Q q -BT 1 0 0 1 0 101.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\(\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (string) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[22]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (trace) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[51]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (ZeroDivisionError) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj 0 .501961 0 rg (int) Tj 0 0 0 rg ( ) Tj (division) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (or) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (modulo) Tj ( ) Tj (by) Tj ( ) Tj (zero) Tj T* ET +BT 1 0 0 1 0 98 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj (\(\)) Tj T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (string) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[22]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (trace) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj (,) Tj ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj (\)) Tj T* ( ) Tj (File) Tj ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[51]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj ( ) Tj (line) Tj ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (f) Tj T* ( ) Tj .4 .4 .4 rg (1) Tj (/) Tj (0) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (ZeroDivisionError) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj 0 .501961 0 rg (int) Tj 0 0 0 rg ( ) Tj (division) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (or) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (modulo) Tj ( ) Tj (by) Tj ( ) Tj (zero) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 206.2236 cm +1 0 0 1 62.69291 278.2236 cm q -BT 1 0 0 1 0 52.82 Tm 1.05528 Tw 12 TL /F1 10 Tf 0 0 0 rg (You see here the inner call to the decorator ) Tj /F5 10 Tf (trace) Tj /F1 10 Tf (, which calls ) Tj /F5 10 Tf (f\(*args, **kw\)) Tj /F1 10 Tf (, and a reference to) Tj T* 0 Tw .265868 Tw /F5 10 Tf (File ") Tj (<) Tj (string) Tj (>) Tj (", line 2, in f) Tj /F1 10 Tf (. This latter reference is due to the fact that internally the decorator) Tj T* 0 Tw 2.053318 Tw (module uses ) Tj /F5 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Notice that ) Tj /F5 10 Tf (exec ) Tj /F1 10 Tf (is ) Tj /F6 10 Tf (not ) Tj /F1 10 Tf (responsibile for the) Tj T* 0 Tw 1.507485 Tw (performance penalty, since is the called ) Tj /F6 10 Tf (only once ) Tj /F1 10 Tf (at function decoration time, and not every time the) Tj T* 0 Tw (decorated function is called.) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.05528 Tw 12 TL /F1 10 Tf 0 0 0 rg (You see here the inner call to the decorator ) Tj /F4 10 Tf (trace) Tj /F1 10 Tf (, which calls ) Tj /F4 10 Tf (f\(*args, **kw\)) Tj /F1 10 Tf (, and a reference to) Tj T* 0 Tw .265868 Tw /F4 10 Tf (File ") Tj (<) Tj (string) Tj (>) Tj (", line 2, in f) Tj /F1 10 Tf (. This latter reference is due to the fact that internally the decorator) Tj T* 0 Tw 2.053318 Tw (module uses ) Tj /F4 10 Tf (exec ) Tj /F1 10 Tf (to generate the decorated function. Notice that ) Tj /F4 10 Tf (exec ) Tj /F1 10 Tf (is ) Tj /F5 10 Tf (not ) Tj /F1 10 Tf (responsibile for the) Tj T* 0 Tw 1.507485 Tw (performance penalty, since is the called ) Tj /F5 10 Tf (only once ) Tj /F1 10 Tf (at function decoration time, and not every time the) Tj T* 0 Tw (decorated function is called.) Tj T* ET +Q +Q +q +1 0 0 1 62.69291 200.2236 cm +q +BT 1 0 0 1 0 62 Tm .932209 Tw 12 TL /F1 10 Tf 0 0 0 rg (At present, there is no clean way to avoid ) Tj /F4 10 Tf (exec) Tj /F1 10 Tf (. A clean solution would require to change the CPython) Tj T* 0 Tw .777485 Tw (implementation of functions and add an hook to make it possible to change their signature directly. That) Tj T* 0 Tw .74186 Tw (could happen in future versions of Python \(see PEP ) Tj 0 0 .501961 rg (362) Tj 0 0 0 rg (\) and then the decorator module would become) Tj T* 0 Tw 2.385318 Tw (obsolete. However, at present, even in Python 3.1 it is impossible to change the function signature) Tj T* 0 Tw .931751 Tw (directly, therefore the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module is still useful. Actually, this is one of the main reasons why I) Tj T* 0 Tw (keep maintaining the module and releasing new versions.) Tj T* ET +Q +Q +q +1 0 0 1 62.69291 158.2236 cm +q +BT 1 0 0 1 0 26 Tm 1.043828 Tw 12 TL /F1 10 Tf 0 0 0 rg (In the present implementation, decorators generated by ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (can only be used on user-defined) Tj T* 0 Tw .152485 Tw (Python functions or methods, not on generic callable objects, nor on built-in functions, due to limitations of) Tj T* 0 Tw (the ) Tj /F4 10 Tf (inspect ) Tj /F1 10 Tf (module in the standard library.) Tj T* ET Q Q q 1 0 0 1 62.69291 128.2236 cm q -BT 1 0 0 1 0 64.82 Tm .932209 Tw 12 TL /F1 10 Tf 0 0 0 rg (At present, there is no clean way to avoid ) Tj /F5 10 Tf (exec) Tj /F1 10 Tf (. A clean solution would require to change the CPython) Tj T* 0 Tw .777485 Tw (implementation of functions and add an hook to make it possible to change their signature directly. That) Tj T* 0 Tw .74186 Tw (could happen in future versions of Python \(see PEP ) Tj 0 0 .501961 rg (362) Tj 0 0 0 rg (\) and then the decorator module would become) Tj T* 0 Tw 2.385318 Tw (obsolete. However, at present, even in Python 3.1 it is impossible to change the function signature) Tj T* 0 Tw .931751 Tw (directly, therefore the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module is still useful. Actually, this is one of the main reasons why I) Tj T* 0 Tw (keep maintaining the module and releasing new versions.) Tj T* ET +BT 1 0 0 1 0 14 Tm .785777 Tw 12 TL /F1 10 Tf 0 0 0 rg (There is a restriction on the names of the arguments: for instance, if try to call an argument ) Tj /F4 10 Tf (_call_ ) Tj /F1 10 Tf (or) Tj T* 0 Tw /F4 10 Tf (_func_ ) Tj /F1 10 Tf (you will get a ) Tj /F4 10 Tf (NameError) Tj /F1 10 Tf (:) Tj T* ET Q Q q -1 0 0 1 62.69291 86.22362 cm +1 0 0 1 62.69291 83.02362 cm +q +q +1 0 0 1 0 0 cm +q +1 0 0 1 6.6 6.6 cm +q +.662745 .662745 .662745 RG +.5 w +.960784 .960784 .862745 rg +n -6 -6 468.6898 36 re B* +Q q -BT 1 0 0 1 0 28.82 Tm 1.043828 Tw 12 TL /F1 10 Tf 0 0 0 rg (In the present implementation, decorators generated by ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (can only be used on user-defined) Tj T* 0 Tw .152485 Tw (Python functions or methods, not on generic callable objects, nor on built-in functions, due to limitations of) Tj T* 0 Tw (the ) Tj /F5 10 Tf (inspect ) Tj /F1 10 Tf (module in the standard library.) Tj T* ET +BT 1 0 0 1 0 14 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F4 10 Tf 0 0 0 rg (\() Tj (f) Tj (\)) Tj T* ET +Q +Q +Q Q Q endstream - endobj -% 'R93': class PDFStream -93 0 obj +% 'R92': class PDFStream +92 0 obj % page stream -<< /Length 7968 >> +<< /Length 7501 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET -q -1 0 0 1 62.69291 741.0236 cm +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -BT 1 0 0 1 0 16.82 Tm .785777 Tw 12 TL /F1 10 Tf 0 0 0 rg (There is a restriction on the names of the arguments: for instance, if try to call an argument ) Tj /F5 10 Tf (_call_ ) Tj /F1 10 Tf (or) Tj T* 0 Tw /F5 10 Tf (_func_ ) Tj /F1 10 Tf (you will get a ) Tj /F5 10 Tf (NameError) Tj /F1 10 Tf (:) Tj T* ET -Q -Q -q -1 0 0 1 62.69291 623.8236 cm +1 0 0 1 62.69291 679.8236 cm q q 1 0 0 1 0 0 cm @@ -3293,23 +3364,23 @@ q .662745 .662745 .662745 RG .5 w .960784 .960784 .862745 rg -n -6 -6 468.6898 108 re B* +n -6 -6 468.6898 84 re B* Q q -BT 1 0 0 1 0 89.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj .666667 .133333 1 rg (@trace) Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (print) Tj /F5 10 Tf 0 0 0 rg (\() Tj (f) Tj (\)) Tj T* .4 .4 .4 rg (...) Tj 0 0 0 rg T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (NameError) Tj /F5 10 Tf 0 0 0 rg (:) Tj ( ) Tj (_func_) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (is) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (overridden) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F5 10 Tf 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F5 10 Tf 0 0 0 rg ( ) Tj (_call_) Tj (\() Tj (_func_) Tj (,) Tj ( ) Tj (_func_) Tj (\)) Tj T* ET +BT 1 0 0 1 0 62 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (...) Tj 0 0 0 rg T* (Traceback) Tj ( ) Tj (\() Tj (most) Tj ( ) Tj (recent) Tj ( ) Tj (call) Tj ( ) Tj (last) Tj (\):) Tj T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* /F3 10 Tf .823529 .254902 .227451 rg (NameError) Tj /F4 10 Tf 0 0 0 rg (:) Tj ( ) Tj (_func_) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (is) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (overridden) Tj ( ) Tj /F3 10 Tf .666667 .133333 1 rg (in) Tj /F4 10 Tf 0 0 0 rg T* /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\() Tj (_func_) Tj (\):) Tj T* ( ) Tj /F3 10 Tf 0 .501961 0 rg (return) Tj /F4 10 Tf 0 0 0 rg ( ) Tj (_call_) Tj (\() Tj (_func_) Tj (,) Tj ( ) Tj (_func_) Tj (\)) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 591.8236 cm +1 0 0 1 62.69291 647.8236 cm q -BT 1 0 0 1 0 16.82 Tm 1.533318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally, the implementation is such that the decorated function contains a ) Tj /F6 10 Tf (copy ) Tj /F1 10 Tf (of the original function) Tj T* 0 Tw (dictionary \() Tj /F5 10 Tf (vars\(decorated_f\) is not vars\(f\)) Tj /F1 10 Tf (\):) Tj T* ET +BT 1 0 0 1 0 14 Tm 1.533318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally, the implementation is such that the decorated function contains a ) Tj /F5 10 Tf (copy ) Tj /F1 10 Tf (of the original function) Tj T* 0 Tw (dictionary \() Tj /F4 10 Tf (vars\(decorated_f\) is not vars\(f\)) Tj /F1 10 Tf (\):) Tj T* ET Q Q q -1 0 0 1 62.69291 438.6236 cm +1 0 0 1 62.69291 494.6236 cm q q 1 0 0 1 0 0 cm @@ -3322,79 +3393,72 @@ q n -6 -6 468.6898 144 re B* Q q -BT 1 0 0 1 0 125.71 Tm 12 TL /F5 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F5 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F5 10 Tf 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the original function) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something") Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# setting an attribute) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something else") Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# setting another attribute) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (f) Tj (\)) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the decorated function) Tj /F5 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj T* .729412 .129412 .129412 rg ('something') Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something different") Tj 0 0 0 rg ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# setting attr) Tj /F5 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj /F7 10 Tf .25098 .501961 .501961 rg (# the original attribute did not change) Tj /F5 10 Tf 0 0 0 rg T* .729412 .129412 .129412 rg ('something else') Tj T* ET +BT 1 0 0 1 0 122 Tm 12 TL /F4 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F3 10 Tf 0 .501961 0 rg (def) Tj /F4 10 Tf 0 0 0 rg ( ) Tj 0 0 1 rg (f) Tj 0 0 0 rg (\(\):) Tj ( ) Tj /F3 10 Tf 0 .501961 0 rg (pass) Tj /F4 10 Tf 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the original function) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something") Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# setting an attribute) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something else") Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# setting another attribute) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj (trace) Tj (\() Tj (f) Tj (\)) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the decorated function) Tj /F4 10 Tf 0 0 0 rg T* T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr1) Tj T* .729412 .129412 .129412 rg ('something') Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (traced_f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ("something different") Tj 0 0 0 rg ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# setting attr) Tj /F4 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj (f) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (attr2) Tj ( ) Tj /F6 10 Tf .25098 .501961 .501961 rg (# the original attribute did not change) Tj /F4 10 Tf 0 0 0 rg T* .729412 .129412 .129412 rg ('something else') Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 405.6236 cm +1 0 0 1 62.69291 461.6236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Compatibility notes) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Compatibility notes) Tj T* ET Q Q q -1 0 0 1 62.69291 339.6236 cm +1 0 0 1 62.69291 395.6236 cm q -BT 1 0 0 1 0 52.82 Tm 1.71811 Tw 12 TL /F1 10 Tf 0 0 0 rg (Version 3.2 is the first version of the ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module to officially support Python 3. Actually, the) Tj T* 0 Tw .273516 Tw (module has supported Python 3 from the beginning, via the ) Tj /F5 10 Tf (2to3 ) Tj /F1 10 Tf (conversion tool, but this step has been) Tj T* 0 Tw .37284 Tw (now integrated in the build process, thanks to the ) Tj 0 0 .501961 rg (distribute ) Tj 0 0 0 rg (project, the Python 3-compatible replacement) Tj T* 0 Tw .11811 Tw (of easy_install. The hard work \(for me\) has been converting the documentation and the doctests. This has) Tj T* 0 Tw (been possible only now that ) Tj 0 0 .501961 rg (docutils ) Tj 0 0 0 rg (and ) Tj 0 0 .501961 rg (pygments ) Tj 0 0 0 rg (have been ported to Python 3.) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.71811 Tw 12 TL /F1 10 Tf 0 0 0 rg (Version 3.2 is the first version of the ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module to officially support Python 3. Actually, the) Tj T* 0 Tw .273516 Tw (module has supported Python 3 from the beginning, via the ) Tj /F4 10 Tf (2to3 ) Tj /F1 10 Tf (conversion tool, but this step has been) Tj T* 0 Tw .37284 Tw (now integrated in the build process, thanks to the ) Tj 0 0 .501961 rg (distribute ) Tj 0 0 0 rg (project, the Python 3-compatible replacement) Tj T* 0 Tw .11811 Tw (of easy_install. The hard work \(for me\) has been converting the documentation and the doctests. This has) Tj T* 0 Tw (been possible only now that ) Tj 0 0 .501961 rg (docutils ) Tj 0 0 0 rg (and ) Tj 0 0 .501961 rg (pygments ) Tj 0 0 0 rg (have been ported to Python 3.) Tj T* ET Q Q q -1 0 0 1 62.69291 261.6236 cm +1 0 0 1 62.69291 317.6236 cm q -BT 1 0 0 1 0 64.82 Tm 1.19561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (module ) Tj /F6 10 Tf (per se ) Tj /F1 10 Tf (does not contain any change, apart from the removal of the functions) Tj T* 0 Tw 1.348314 Tw /F5 10 Tf (get_info ) Tj /F1 10 Tf (and ) Tj /F5 10 Tf (new_wrapper) Tj /F1 10 Tf (, which have been deprecated for years. ) Tj /F5 10 Tf (get_info ) Tj /F1 10 Tf (has been removed) Tj T* 0 Tw .921654 Tw (since it was little used and since it had to be changed anyway to work with Python 3.0; ) Tj /F5 10 Tf (new_wrapper) Tj T* 0 Tw .609318 Tw /F1 10 Tf (has been removed since it was useless: its major use case \(converting signature changing decorators to) Tj T* 0 Tw .028443 Tw (signature preserving decorators\) has been subsumed by ) Tj /F5 10 Tf (decorator_apply ) Tj /F1 10 Tf (and the other use case can) Tj T* 0 Tw (be managed with the ) Tj /F5 10 Tf (FunctionMaker) Tj /F1 10 Tf (.) Tj T* ET +BT 1 0 0 1 0 62 Tm 1.19561 Tw 12 TL /F1 10 Tf 0 0 0 rg (The ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (module ) Tj /F5 10 Tf (per se ) Tj /F1 10 Tf (does not contain any change, apart from the removal of the functions) Tj T* 0 Tw 1.348314 Tw /F4 10 Tf (get_info ) Tj /F1 10 Tf (and ) Tj /F4 10 Tf (new_wrapper) Tj /F1 10 Tf (, which have been deprecated for years. ) Tj /F4 10 Tf (get_info ) Tj /F1 10 Tf (has been removed) Tj T* 0 Tw .921654 Tw (since it was little used and since it had to be changed anyway to work with Python 3.0; ) Tj /F4 10 Tf (new_wrapper) Tj T* 0 Tw .609318 Tw /F1 10 Tf (has been removed since it was useless: its major use case \(converting signature changing decorators to) Tj T* 0 Tw .028443 Tw (signature preserving decorators\) has been subsumed by ) Tj /F4 10 Tf (decorator_apply ) Tj /F1 10 Tf (and the other use case can) Tj T* 0 Tw (be managed with the ) Tj /F4 10 Tf (FunctionMaker) Tj /F1 10 Tf (.) Tj T* ET Q Q q -1 0 0 1 62.69291 195.6236 cm +1 0 0 1 62.69291 251.6236 cm q -BT 1 0 0 1 0 52.82 Tm 1.329213 Tw 12 TL /F1 10 Tf 0 0 0 rg (There are a few changes in the documentation: I removed the ) Tj /F5 10 Tf (decorator_factory ) Tj /F1 10 Tf (example, which) Tj T* 0 Tw 2.562927 Tw (was confusing some of my users, and I removed the part about exotic signatures in the Python 3) Tj T* 0 Tw 2.20061 Tw (documentation, since Python 3 does not support them. Notice that there is no support for Python 3) Tj T* 0 Tw 1.163984 Tw 0 0 .501961 rg (function annotations ) Tj 0 0 0 rg (since it seems premature at the moment, when most people are still using Python) Tj T* 0 Tw (2.X.) Tj T* ET +BT 1 0 0 1 0 50 Tm 1.329213 Tw 12 TL /F1 10 Tf 0 0 0 rg (There are a few changes in the documentation: I removed the ) Tj /F4 10 Tf (decorator_factory ) Tj /F1 10 Tf (example, which) Tj T* 0 Tw 2.562927 Tw (was confusing some of my users, and I removed the part about exotic signatures in the Python 3) Tj T* 0 Tw 2.20061 Tw (documentation, since Python 3 does not support them. Notice that there is no support for Python 3) Tj T* 0 Tw 1.163984 Tw 0 0 .501961 rg (function annotations ) Tj 0 0 0 rg (since it seems premature at the moment, when most people are still using Python) Tj T* 0 Tw (2.X.) Tj T* ET Q Q q -1 0 0 1 62.69291 129.6236 cm +1 0 0 1 62.69291 185.6236 cm q -BT 1 0 0 1 0 52.82 Tm .942651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally ) Tj /F5 10 Tf (decorator ) Tj /F1 10 Tf (cannot be used as a class decorator and the ) Tj 0 0 .501961 rg (functionality introduced in version 2.3) Tj T* 0 Tw .241163 Tw 0 0 0 rg (has been removed. That means that in order to define decorator factories with classes you need to define) Tj T* 0 Tw 1.122126 Tw (the ) Tj /F5 10 Tf (__call__ ) Tj /F1 10 Tf (method explicitly \(no magic anymore\). All these changes should not cause any trouble,) Tj T* 0 Tw .601163 Tw (since they were all rarely used features. Should you have any trouble, you can always downgrade to the) Tj T* 0 Tw (2.3 version.) Tj T* ET +BT 1 0 0 1 0 50 Tm .942651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally ) Tj /F4 10 Tf (decorator ) Tj /F1 10 Tf (cannot be used as a class decorator and the ) Tj 0 0 .501961 rg (functionality introduced in version 2.3) Tj T* 0 Tw .241163 Tw 0 0 0 rg (has been removed. That means that in order to define decorator factories with classes you need to define) Tj T* 0 Tw 1.122126 Tw (the ) Tj /F4 10 Tf (__call__ ) Tj /F1 10 Tf (method explicitly \(no magic anymore\). All these changes should not cause any trouble,) Tj T* 0 Tw .601163 Tw (since they were all rarely used features. Should you have any trouble, you can always downgrade to the) Tj T* 0 Tw (2.3 version.) Tj T* ET Q Q q -1 0 0 1 62.69291 87.62362 cm +1 0 0 1 62.69291 119.6236 cm q -BT 1 0 0 1 0 28.82 Tm .196098 Tw 12 TL /F1 10 Tf 0 0 0 rg (The examples shown here have been tested with Python 2.6. Python 2.4 is also supported - of course the ) Tj T* 0 Tw 1.649398 Tw (examples requiring the ) Tj /F5 10 Tf (with ) Tj /F1 10 Tf (statement will not work there. Python 2.5 works fine, but if you run the ) Tj T* 0 Tw 1.41784 Tw (examples in the interactive interpreter you will notice a few differences since ) Tj /F5 10 Tf (getargspec ) Tj /F1 10 Tf (returns an) Tj T* 0 Tw ET +BT 1 0 0 1 0 50 Tm .196098 Tw 12 TL /F1 10 Tf 0 0 0 rg (The examples shown here have been tested with Python 2.6. Python 2.4 is also supported - of course the) Tj T* 0 Tw 1.649398 Tw (examples requiring the ) Tj /F4 10 Tf (with ) Tj /F1 10 Tf (statement will not work there. Python 2.5 works fine, but if you run the) Tj T* 0 Tw 1.41784 Tw (examples in the interactive interpreter you will notice a few differences since ) Tj /F4 10 Tf (getargspec ) Tj /F1 10 Tf (returns an) Tj T* 0 Tw .909982 Tw /F4 10 Tf (ArgSpec ) Tj /F1 10 Tf (namedtuple instead of a regular tuple. That means that running the file ) Tj /F4 10 Tf (documentation.py) Tj T* 0 Tw /F1 10 Tf (under Python 2.5 will print a few errors, but they are not serious.) Tj T* ET Q Q endstream - endobj -% 'R94': class PDFStream -94 0 obj +% 'R93': class PDFStream +93 0 obj % page stream -<< /Length 2641 >> +<< /Length 2299 >> stream -1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET -q -1 0 0 1 62.69291 741.0236 cm -q -BT 1 0 0 1 0 16.82 Tm .909982 Tw 12 TL /F5 10 Tf 0 0 0 rg (ArgSpec ) Tj /F1 10 Tf (namedtuple instead of a regular tuple. That means that running the file ) Tj /F5 10 Tf (documentation.py) Tj T* 0 Tw /F1 10 Tf (under Python 2.5 will print a few errors, but they are not serious.) Tj T* ET -Q -Q +1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q -1 0 0 1 62.69291 708.0236 cm +1 0 0 1 62.69291 744.0236 cm q -BT 1 0 0 1 0 8.435 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (LICENCE) Tj T* ET +BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (LICENCE) Tj T* ET Q Q q -1 0 0 1 62.69291 678.0236 cm +1 0 0 1 62.69291 714.0236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL 1.328555 Tw (Redistribution and use in source and binary forms, with or without modification, are permitted provided) Tj T* 0 Tw (that the following conditions are met:) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL 1.328555 Tw (Redistribution and use in source and binary forms, with or without modification, are permitted provided) Tj T* 0 Tw (that the following conditions are met:) Tj T* ET Q Q q -1 0 0 1 62.69291 392.8236 cm +1 0 0 1 62.69291 428.8236 cm q q 1 0 0 1 0 0 cm @@ -3408,259 +3472,257 @@ n -6 -6 468.6898 276 re B* Q q 0 0 0 rg -BT 1 0 0 1 0 257.71 Tm /F5 10 Tf 12 TL (Copyright \(c\) 2005, Michele Simionato) Tj T* (All rights reserved.) Tj T* T* (Redistributions of source code must retain the above copyright) Tj T* (notice, this list of conditions and the following disclaimer.) Tj T* (Redistributions in bytecode form must reproduce the above copyright) Tj T* (notice, this list of conditions and the following disclaimer in) Tj T* (the documentation and/or other materials provided with the) Tj T* (distribution.) Tj T* T* (THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS) Tj T* ("AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT) Tj T* (LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR) Tj T* (A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT) Tj T* (HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,) Tj T* (INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING,) Tj T* (BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS) Tj T* (OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND) Tj T* (ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR) Tj T* (TORT \(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT OF THE) Tj T* (USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH) Tj T* (DAMAGE.) Tj T* ET +BT 1 0 0 1 0 254 Tm /F4 10 Tf 12 TL (Copyright \(c\) 2005, Michele Simionato) Tj T* (All rights reserved.) Tj T* T* (Redistributions of source code must retain the above copyright) Tj T* (notice, this list of conditions and the following disclaimer.) Tj T* (Redistributions in bytecode form must reproduce the above copyright) Tj T* (notice, this list of conditions and the following disclaimer in) Tj T* (the documentation and/or other materials provided with the) Tj T* (distribution.) Tj T* T* (THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS) Tj T* ("AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT) Tj T* (LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR) Tj T* (A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT) Tj T* (HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,) Tj T* (INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING,) Tj T* (BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS) Tj T* (OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND) Tj T* (ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR) Tj T* (TORT \(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT OF THE) Tj T* (USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH) Tj T* (DAMAGE.) Tj T* ET Q Q Q Q Q q -1 0 0 1 62.69291 360.8236 cm +1 0 0 1 62.69291 396.8236 cm q 0 0 0 rg -BT 1 0 0 1 0 16.82 Tm /F1 10 Tf 12 TL .407132 Tw (If you use this software and you are happy with it, consider sending me a note, just to gratify my ego. On) Tj T* 0 Tw (the other hand, if you use this software and you are unhappy with it, send me a patch!) Tj T* ET +BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .407132 Tw (If you use this software and you are happy with it, consider sending me a note, just to gratify my ego. On) Tj T* 0 Tw (the other hand, if you use this software and you are unhappy with it, send me a patch!) Tj T* ET Q Q endstream - endobj -% 'R95': class PDFPageLabels -95 0 obj +% 'R94': class PDFPageLabels +94 0 obj % Document Root << /Nums [ 0 - 96 0 R + 95 0 R 1 - 97 0 R + 96 0 R 2 - 98 0 R + 97 0 R 3 - 99 0 R + 98 0 R 4 - 100 0 R + 99 0 R 5 - 101 0 R + 100 0 R 6 - 102 0 R + 101 0 R 7 - 103 0 R + 102 0 R 8 - 104 0 R + 103 0 R 9 - 105 0 R + 104 0 R 10 - 106 0 R + 105 0 R 11 - 107 0 R + 106 0 R 12 - 108 0 R + 107 0 R 13 - 109 0 R ] >> + 108 0 R ] >> +endobj +% 'R95': class PDFPageLabel +95 0 obj +% None +<< /S /D + /St 1 >> endobj % 'R96': class PDFPageLabel 96 0 obj % None << /S /D - /St 1 >> + /St 2 >> endobj % 'R97': class PDFPageLabel 97 0 obj % None << /S /D - /St 2 >> + /St 3 >> endobj % 'R98': class PDFPageLabel 98 0 obj % None << /S /D - /St 3 >> + /St 4 >> endobj % 'R99': class PDFPageLabel 99 0 obj % None << /S /D - /St 4 >> + /St 5 >> endobj % 'R100': class PDFPageLabel 100 0 obj % None << /S /D - /St 5 >> + /St 6 >> endobj % 'R101': class PDFPageLabel 101 0 obj % None << /S /D - /St 6 >> + /St 7 >> endobj % 'R102': class PDFPageLabel 102 0 obj % None << /S /D - /St 7 >> + /St 8 >> endobj % 'R103': class PDFPageLabel 103 0 obj % None << /S /D - /St 8 >> + /St 9 >> endobj % 'R104': class PDFPageLabel 104 0 obj % None << /S /D - /St 9 >> + /St 10 >> endobj % 'R105': class PDFPageLabel 105 0 obj % None << /S /D - /St 10 >> + /St 11 >> endobj % 'R106': class PDFPageLabel 106 0 obj % None << /S /D - /St 11 >> + /St 12 >> endobj % 'R107': class PDFPageLabel 107 0 obj % None << /S /D - /St 12 >> + /St 13 >> endobj % 'R108': class PDFPageLabel 108 0 obj % None -<< /S /D - /St 13 >> -endobj -% 'R109': class PDFPageLabel -109 0 obj -% None << /S /D /St 14 >> endobj xref -0 110 +0 109 0000000000 65535 f 0000000113 00000 n -0000000283 00000 n -0000000448 00000 n -0000000623 00000 n +0000000271 00000 n +0000000436 00000 n +0000000611 00000 n 0000000794 00000 n -0000000975 00000 n -0000001227 00000 n -0000001476 00000 n -0000001650 00000 n -0000001891 00000 n -0000002133 00000 n -0000002375 00000 n -0000002617 00000 n -0000002859 00000 n -0000003101 00000 n -0000003344 00000 n -0000003587 00000 n -0000003830 00000 n -0000004073 00000 n -0000004315 00000 n -0000004557 00000 n -0000004799 00000 n -0000005041 00000 n -0000005284 00000 n -0000005527 00000 n -0000005770 00000 n -0000006013 00000 n -0000006256 00000 n -0000006499 00000 n -0000006742 00000 n -0000006985 00000 n -0000007228 00000 n -0000007471 00000 n -0000007714 00000 n -0000007957 00000 n -0000008200 00000 n -0000008427 00000 n -0000008988 00000 n -0000009183 00000 n -0000009439 00000 n -0000009630 00000 n -0000009890 00000 n -0000010200 00000 n -0000010480 00000 n -0000010760 00000 n -0000011040 00000 n -0000011320 00000 n -0000011600 00000 n -0000011895 00000 n -0000012135 00000 n -0000012451 00000 n -0000012719 00000 n -0000013021 00000 n -0000013316 00000 n -0000013561 00000 n -0000013877 00000 n -0000014135 00000 n -0000014387 00000 n -0000014627 00000 n -0000014887 00000 n -0000015194 00000 n -0000015532 00000 n -0000015813 00000 n -0000015972 00000 n -0000016221 00000 n -0000016347 00000 n -0000016520 00000 n -0000016707 00000 n -0000016907 00000 n -0000017095 00000 n -0000017288 00000 n -0000017487 00000 n -0000017670 00000 n -0000017851 00000 n -0000018050 00000 n -0000018250 00000 n -0000018462 00000 n -0000018662 00000 n -0000018858 00000 n -0000019010 00000 n -0000019236 00000 n -0000028440 00000 n -0000036177 00000 n -0000044258 00000 n -0000051529 00000 n -0000059939 00000 n -0000067642 00000 n -0000075047 00000 n -0000082428 00000 n -0000090134 00000 n -0000097401 00000 n -0000104281 00000 n -0000111010 00000 n -0000119079 00000 n -0000121825 00000 n -0000122101 00000 n -0000122178 00000 n -0000122255 00000 n -0000122332 00000 n -0000122410 00000 n -0000122489 00000 n -0000122568 00000 n -0000122647 00000 n -0000122726 00000 n -0000122805 00000 n -0000122885 00000 n -0000122965 00000 n -0000123045 00000 n -0000123125 00000 n +0000001046 00000 n +0000001295 00000 n +0000001469 00000 n +0000001710 00000 n +0000001951 00000 n +0000002193 00000 n +0000002435 00000 n +0000002677 00000 n +0000002919 00000 n +0000003162 00000 n +0000003405 00000 n +0000003648 00000 n +0000003891 00000 n +0000004133 00000 n +0000004375 00000 n +0000004617 00000 n +0000004859 00000 n +0000005102 00000 n +0000005345 00000 n +0000005588 00000 n +0000005831 00000 n +0000006074 00000 n +0000006317 00000 n +0000006560 00000 n +0000006803 00000 n +0000007046 00000 n +0000007289 00000 n +0000007532 00000 n +0000007775 00000 n +0000008018 00000 n +0000008245 00000 n +0000008805 00000 n +0000009000 00000 n +0000009256 00000 n +0000009447 00000 n +0000009707 00000 n +0000010017 00000 n +0000010297 00000 n +0000010577 00000 n +0000010857 00000 n +0000011137 00000 n +0000011417 00000 n +0000011712 00000 n +0000011952 00000 n +0000012268 00000 n +0000012536 00000 n +0000012838 00000 n +0000013133 00000 n +0000013378 00000 n +0000013694 00000 n +0000013952 00000 n +0000014204 00000 n +0000014444 00000 n +0000014704 00000 n +0000015011 00000 n +0000015349 00000 n +0000015630 00000 n +0000015789 00000 n +0000016074 00000 n +0000016200 00000 n +0000016373 00000 n +0000016560 00000 n +0000016760 00000 n +0000016948 00000 n +0000017141 00000 n +0000017340 00000 n +0000017523 00000 n +0000017704 00000 n +0000017903 00000 n +0000018103 00000 n +0000018315 00000 n +0000018515 00000 n +0000018711 00000 n +0000018863 00000 n +0000019089 00000 n +0000028348 00000 n +0000036087 00000 n +0000044317 00000 n +0000052241 00000 n +0000060973 00000 n +0000068197 00000 n +0000075605 00000 n +0000083506 00000 n +0000091524 00000 n +0000098777 00000 n +0000104707 00000 n +0000112207 00000 n +0000119807 00000 n +0000122209 00000 n +0000122484 00000 n +0000122561 00000 n +0000122638 00000 n +0000122715 00000 n +0000122792 00000 n +0000122870 00000 n +0000122949 00000 n +0000123028 00000 n +0000123107 00000 n +0000123186 00000 n +0000123266 00000 n +0000123346 00000 n +0000123426 00000 n +0000123506 00000 n trailer << /ID % ReportLab generated PDF document -- digest (http://www.reportlab.com) - [(\200\237\200\270\204\232\213\275\321-~/\272\325j]) (\200\237\200\270\204\232\213\275\321-~/\272\325j])] + [(z6\267c\320b\370\247d-\206p\336\364\267\004) (z6\267c\320b\370\247d-\206p\336\364\267\004)] - /Info 64 0 R - /Root 63 0 R - /Size 110 >> + /Info 63 0 R + /Root 62 0 R + /Size 109 >> startxref -123174 +123555 %%EOF -- cgit v1.2.1