summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2015-07-22 13:55:56 +0200
committerMichele Simionato <michele.simionato@gmail.com>2015-07-22 13:55:56 +0200
commitc654f80ca9d4770c09aaa622844893a493cbc19f (patch)
tree18a8f224d7042905cd94c085439e24eba6b6645c
parentfb545895801ade0d17192d33460f7819ed97d358 (diff)
downloadpython-decorator-git-c654f80ca9d4770c09aaa622844893a493cbc19f.tar.gz
Added a note on FunctionMaker.create
-rw-r--r--documentation.pdf800
-rw-r--r--documentation.rst14
-rw-r--r--src/tests/documentation.py14
3 files changed, 495 insertions, 333 deletions
diff --git a/documentation.pdf b/documentation.pdf
index fe51902..d6787e7 100644
--- a/documentation.pdf
+++ b/documentation.pdf
@@ -109,40 +109,40 @@ endobj
<< /Border [ 0 0 0 ] /Contents () /Dest [ 64 0 R /XYZ 62.69291 669.0236 0 ] /Rect [ 521.4627 344.7736 532.5827 356.7736 ] /Subtype /Link /Type /Annot >>
endobj
37 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 765.0236 0 ] /Rect [ 62.69291 326.0236 177.1629 338.0236 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 647.8236 0 ] /Rect [ 62.69291 326.0236 177.1629 338.0236 ] /Subtype /Link /Type /Annot >>
endobj
38 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 765.0236 0 ] /Rect [ 521.4627 326.7736 532.5827 338.7736 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 647.8236 0 ] /Rect [ 521.4627 326.7736 532.5827 338.7736 ] /Subtype /Link /Type /Annot >>
endobj
39 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 285.2236 0 ] /Rect [ 62.69291 308.0236 228.2829 320.0236 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 180.0236 0 ] /Rect [ 62.69291 308.0236 228.2829 320.0236 ] /Subtype /Link /Type /Annot >>
endobj
40 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 285.2236 0 ] /Rect [ 521.4627 308.7736 532.5827 320.7736 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 66 0 R /XYZ 62.69291 180.0236 0 ] /Rect [ 521.4627 308.7736 532.5827 320.7736 ] /Subtype /Link /Type /Annot >>
endobj
41 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 69 0 R /XYZ 62.69291 558.6236 0 ] /Rect [ 62.69291 290.0236 144.3729 302.0236 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 69 0 R /XYZ 62.69291 445.4236 0 ] /Rect [ 62.69291 290.0236 144.3729 302.0236 ] /Subtype /Link /Type /Annot >>
endobj
42 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 69 0 R /XYZ 62.69291 558.6236 0 ] /Rect [ 521.4627 290.7736 532.5827 302.7736 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 69 0 R /XYZ 62.69291 445.4236 0 ] /Rect [ 521.4627 290.7736 532.5827 302.7736 ] /Subtype /Link /Type /Annot >>
endobj
43 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 71 0 R /XYZ 62.69291 607.8236 0 ] /Rect [ 62.69291 272.0236 251.0829 284.0236 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 71 0 R /XYZ 62.69291 503.8236 0 ] /Rect [ 62.69291 272.0236 251.0829 284.0236 ] /Subtype /Link /Type /Annot >>
endobj
44 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 71 0 R /XYZ 62.69291 607.8236 0 ] /Rect [ 521.4627 272.7736 532.5827 284.7736 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 71 0 R /XYZ 62.69291 503.8236 0 ] /Rect [ 521.4627 272.7736 532.5827 284.7736 ] /Subtype /Link /Type /Annot >>
endobj
45 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 72 0 R /XYZ 62.69291 129.0236 0 ] /Rect [ 62.69291 254.0236 174.3929 266.0236 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 73 0 R /XYZ 62.69291 675.0236 0 ] /Rect [ 62.69291 254.0236 174.3929 266.0236 ] /Subtype /Link /Type /Annot >>
endobj
46 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 72 0 R /XYZ 62.69291 129.0236 0 ] /Rect [ 521.4627 254.7736 532.5827 266.7736 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 73 0 R /XYZ 62.69291 675.0236 0 ] /Rect [ 521.4627 254.7736 532.5827 266.7736 ] /Subtype /Link /Type /Annot >>
endobj
47 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 75 0 R /XYZ 62.69291 270.6236 0 ] /Rect [ 62.69291 236.0236 106.0329 248.0236 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 76 0 R /XYZ 62.69291 765.0236 0 ] /Rect [ 62.69291 236.0236 106.0329 248.0236 ] /Subtype /Link /Type /Annot >>
endobj
48 0 obj
-<< /Border [ 0 0 0 ] /Contents () /Dest [ 75 0 R /XYZ 62.69291 270.6236 0 ] /Rect [ 521.4627 236.7736 532.5827 248.7736 ] /Subtype /Link /Type /Annot >>
+<< /Border [ 0 0 0 ] /Contents () /Dest [ 76 0 R /XYZ 62.69291 765.0236 0 ] /Rect [ 521.4627 236.7736 532.5827 248.7736 ] /Subtype /Link /Type /Annot >>
endobj
49 0 obj
<< /Annots [ 5 0 R 6 0 R 7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R
@@ -207,14 +207,14 @@ endobj
/Type /Page >>
endobj
65 0 obj
-<< /A << /S /URI /Type /Action /URI (http://bugs.python.org/issue1764286) >> /Border [ 0 0 0 ] /Rect [ 133.3162 450.4236 172.2473 462.4236 ] /Subtype /Link /Type /Annot >>
+<< /A << /S /URI /Type /Action /URI (http://bugs.python.org/issue1764286) >> /Border [ 0 0 0 ] /Rect [ 133.3162 345.2236 172.2473 357.2236 ] /Subtype /Link /Type /Annot >>
endobj
66 0 obj
<< /Annots [ 65 0 R ] /Contents 110 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 99 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >> /Rotate 0
/Trans << >> /Type /Page >>
endobj
67 0 obj
-<< /A << /S /URI /Type /Action /URI (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) >> /Border [ 0 0 0 ] /Rect [ 62.69291 633.0236 363.4029 645.0236 ] /Subtype /Link /Type /Annot >>
+<< /A << /S /URI /Type /Action /URI (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691) >> /Border [ 0 0 0 ] /Rect [ 62.69291 515.8236 363.4029 527.8236 ] /Subtype /Link /Type /Annot >>
endobj
68 0 obj
<< /Annots [ 67 0 R ] /Contents 111 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 99 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >> /Rotate 0
@@ -241,7 +241,7 @@ endobj
/Type /Page >>
endobj
74 0 obj
-<< /A << /S /URI /Type /Action /URI (http://www.python.org/dev/peps/pep-0362) >> /Border [ 0 0 0 ] /Rect [ 301.1597 753.0236 317.8397 765.0236 ] /Subtype /Link /Type /Annot >>
+<< /A << /S /URI /Type /Action /URI (http://www.python.org/dev/peps/pep-0362) >> /Border [ 0 0 0 ] /Rect [ 301.1597 593.8236 317.8397 605.8236 ] /Subtype /Link /Type /Annot >>
endobj
75 0 obj
<< /Annots [ 74 0 R ] /Contents 117 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 99 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >> /Rotate 0
@@ -255,7 +255,7 @@ endobj
<< /Outlines 79 0 R /PageLabels 119 0 R /PageMode /UseNone /Pages 99 0 R /Type /Catalog >>
endobj
78 0 obj
-<< /Author (Michele Simionato) /CreationDate (D:20150722095023-01'00') /Creator (\(unspecified\)) /Keywords () /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (\(unspecified\))
+<< /Author (Michele Simionato) /CreationDate (D:20150722135458-01'00') /Creator (\(unspecified\)) /Keywords () /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (\(unspecified\))
/Title (The decorator module) >>
endobj
79 0 obj
@@ -301,22 +301,22 @@ endobj
<< /Dest [ 64 0 R /XYZ 62.69291 669.0236 0 ] /Next 93 0 R /Parent 79 0 R /Prev 91 0 R /Title (The FunctionMaker class) >>
endobj
93 0 obj
-<< /Dest [ 66 0 R /XYZ 62.69291 765.0236 0 ] /Next 94 0 R /Parent 79 0 R /Prev 92 0 R /Title (Getting the source code) >>
+<< /Dest [ 66 0 R /XYZ 62.69291 647.8236 0 ] /Next 94 0 R /Parent 79 0 R /Prev 92 0 R /Title (Getting the source code) >>
endobj
94 0 obj
-<< /Dest [ 66 0 R /XYZ 62.69291 285.2236 0 ] /Next 95 0 R /Parent 79 0 R /Prev 93 0 R /Title (Dealing with third party decorators) >>
+<< /Dest [ 66 0 R /XYZ 62.69291 180.0236 0 ] /Next 95 0 R /Parent 79 0 R /Prev 93 0 R /Title (Dealing with third party decorators) >>
endobj
95 0 obj
-<< /Dest [ 69 0 R /XYZ 62.69291 558.6236 0 ] /Next 96 0 R /Parent 79 0 R /Prev 94 0 R /Title (Multiple dispatch) >>
+<< /Dest [ 69 0 R /XYZ 62.69291 445.4236 0 ] /Next 96 0 R /Parent 79 0 R /Prev 94 0 R /Title (Multiple dispatch) >>
endobj
96 0 obj
-<< /Dest [ 71 0 R /XYZ 62.69291 607.8236 0 ] /Next 97 0 R /Parent 79 0 R /Prev 95 0 R /Title (Generic functions and virtual ancestors) >>
+<< /Dest [ 71 0 R /XYZ 62.69291 503.8236 0 ] /Next 97 0 R /Parent 79 0 R /Prev 95 0 R /Title (Generic functions and virtual ancestors) >>
endobj
97 0 obj
-<< /Dest [ 72 0 R /XYZ 62.69291 129.0236 0 ] /Next 98 0 R /Parent 79 0 R /Prev 96 0 R /Title (Caveats and limitations) >>
+<< /Dest [ 73 0 R /XYZ 62.69291 675.0236 0 ] /Next 98 0 R /Parent 79 0 R /Prev 96 0 R /Title (Caveats and limitations) >>
endobj
98 0 obj
-<< /Dest [ 75 0 R /XYZ 62.69291 270.6236 0 ] /Parent 79 0 R /Prev 97 0 R /Title (LICENSE) >>
+<< /Dest [ 76 0 R /XYZ 62.69291 765.0236 0 ] /Parent 79 0 R /Prev 97 0 R /Title (LICENSE) >>
endobj
99 0 obj
<< /Count 19 /Kids [ 49 0 R 51 0 R 56 0 R 57 0 R 58 0 R 60 0 R 61 0 R 62 0 R 63 0 R 64 0 R
@@ -737,7 +737,7 @@ q
q
0 0 .501961 rg
0 0 .501961 RG
-BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (16) Tj T* -60.88 0 Td ET
+BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (17) Tj T* -60.88 0 Td ET
Q
Q
q
@@ -751,7 +751,7 @@ q
q
0 0 .501961 rg
0 0 .501961 RG
-BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (18) Tj T* -60.88 0 Td ET
+BT 1 0 0 1 0 2 Tm /F2 10 Tf 12 TL 60.88 0 Td (19) Tj T* -60.88 0 Td ET
Q
Q
q
@@ -4640,23 +4640,184 @@ Q
endstream
endobj
110 0 obj
-<< /Length 16266 >>
+<< /Length 18338 >>
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 741.0236 cm
+q
+0 0 0 rg
+BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .795697 Tw (Notice: you should not pass signature strings with default arguments, i.e. something like 'f1\(a, b=None\)'.) Tj T* 0 Tw (Just pass 'f1\(a, b\)' and then a tuple of defaults:) Tj T* ET
+Q
+Q
+q
+1 0 0 1 62.69291 659.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 72 re B*
+Q
+q
+.960784 .960784 .862745 rg
+n 0 48 6 12 re f*
+.960784 .960784 .862745 rg
+n 6 48 6 12 re f*
+.960784 .960784 .862745 rg
+n 12 48 6 12 re f*
+.960784 .960784 .862745 rg
+n 24 48 12 12 re f*
+.960784 .960784 .862745 rg
+n 42 48 6 12 re f*
+.960784 .960784 .862745 rg
+n 54 48 78 12 re f*
+.960784 .960784 .862745 rg
+n 132 48 6 12 re f*
+.960784 .960784 .862745 rg
+n 138 48 36 12 re f*
+.960784 .960784 .862745 rg
+n 174 48 6 12 re f*
+.960784 .960784 .862745 rg
+n 0 36 18 12 re f*
+.960784 .960784 .862745 rg
+n 48 36 60 12 re f*
+.960784 .960784 .862745 rg
+n 108 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 120 36 54 12 re f*
+.960784 .960784 .862745 rg
+n 174 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 186 36 24 12 re f*
+.960784 .960784 .862745 rg
+n 210 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 216 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 222 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 228 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 234 36 12 12 re f*
+.960784 .960784 .862745 rg
+n 252 36 54 12 re f*
+.960784 .960784 .862745 rg
+n 306 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 312 36 24 12 re f*
+.960784 .960784 .862745 rg
+n 336 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 348 36 48 12 re f*
+.960784 .960784 .862745 rg
+n 396 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 402 36 6 12 re f*
+.960784 .960784 .862745 rg
+n 408 36 24 12 re f*
+.960784 .960784 .862745 rg
+n 432 36 18 12 re f*
+.960784 .960784 .862745 rg
+n 0 24 6 12 re f*
+.960784 .960784 .862745 rg
+n 6 24 6 12 re f*
+.960784 .960784 .862745 rg
+n 12 24 6 12 re f*
+.960784 .960784 .862745 rg
+n 24 24 36 12 re f*
+.960784 .960784 .862745 rg
+n 66 24 42 12 re f*
+.960784 .960784 .862745 rg
+n 0 12 6 12 re f*
+.960784 .960784 .862745 rg
+n 6 12 6 12 re f*
+.960784 .960784 .862745 rg
+n 12 12 6 12 re f*
+.960784 .960784 .862745 rg
+n 24 12 30 12 re f*
+.960784 .960784 .862745 rg
+n 54 12 6 12 re f*
+.960784 .960784 .862745 rg
+n 60 12 42 12 re f*
+.960784 .960784 .862745 rg
+n 102 12 6 12 re f*
+.960784 .960784 .862745 rg
+n 108 12 60 12 re f*
+.960784 .960784 .862745 rg
+n 168 12 6 12 re f*
+.960784 .960784 .862745 rg
+n 174 12 12 12 re f*
+.960784 .960784 .862745 rg
+n 186 12 12 12 re f*
+.960784 .960784 .862745 rg
+n 0 0 42 12 re f*
+.960784 .960784 .862745 rg
+n 42 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 48 0 24 12 re f*
+.960784 .960784 .862745 rg
+n 72 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 78 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 84 0 18 12 re f*
+.960784 .960784 .862745 rg
+n 102 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 114 0 18 12 re f*
+.960784 .960784 .862745 rg
+n 132 0 12 12 re f*
+.960784 .960784 .862745 rg
+n 150 0 42 12 re f*
+.960784 .960784 .862745 rg
+n 192 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 198 0 24 12 re f*
+.960784 .960784 .862745 rg
+n 222 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 234 0 48 12 re f*
+.960784 .960784 .862745 rg
+n 282 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 288 0 24 12 re f*
+.960784 .960784 .862745 rg
+n 312 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 324 0 48 12 re f*
+.960784 .960784 .862745 rg
+n 372 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 378 0 6 12 re f*
+.960784 .960784 .862745 rg
+n 384 0 24 12 re f*
+.960784 .960784 .862745 rg
+n 408 0 18 12 re f*
+BT 1 0 0 1 0 50 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (f1) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (FunctionMaker) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (create) Tj 0 0 0 rg (\() Tj 0 0 0 rg T* .4 .4 .4 rg (...) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ('f1\(a, b\)') Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ('f\(a, b\)') Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 .501961 0 rg (dict) Tj 0 0 0 rg (\() Tj 0 0 0 rg (f) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (f) Tj 0 0 0 rg (\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (addsource) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (True) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg (\() Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F5 10 Tf 0 .501961 0 rg (import) Tj /F3 10 Tf 0 0 0 rg ( ) Tj /F5 10 Tf 0 0 1 rg (inspect) Tj /F3 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F5 10 Tf 0 .501961 0 rg (print) Tj /F3 10 Tf 0 0 0 rg (\() Tj 0 0 0 rg (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getargspec) Tj 0 0 0 rg (\() Tj 0 0 0 rg (f1) Tj 0 0 0 rg (\)\)) Tj 0 0 0 rg T* 0 0 0 rg (ArgSpec) Tj 0 0 0 rg (\() Tj 0 0 0 rg (args) Tj .4 .4 .4 rg (=) Tj 0 0 0 rg ([) Tj .729412 .129412 .129412 rg ('a') Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg ('b') Tj 0 0 0 rg (],) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (varargs) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (keywords) Tj .4 .4 .4 rg (=) Tj 0 .501961 0 rg (None) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (defaults) Tj .4 .4 .4 rg (=) Tj 0 0 0 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 626.8236 cm
q
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 666.0236 cm
+1 0 0 1 62.69291 548.8236 cm
q
BT 1 0 0 1 0 62 Tm 5.045529 Tw 12 TL /F1 10 Tf 0 0 0 rg (Internally ) Tj /F3 10 Tf 0 0 0 rg (FunctionMaker.create ) Tj /F1 10 Tf 0 0 0 rg (uses ) Tj /F3 10 Tf 0 0 0 rg (exec ) Tj /F1 10 Tf 0 0 0 rg (to generate the decorated function. Therefore) Tj T* 0 Tw 2.542126 Tw /F3 10 Tf 0 0 0 rg (inspect.getsource ) Tj /F1 10 Tf 0 0 0 rg (will not work for decorated functions. That means that the usual '??' trick in) Tj T* 0 Tw 26.45775 Tw (IPython will give you the \(right on the spot\) message) Tj T* 0 Tw .261647 Tw /F3 10 Tf 0 0 0 rg (Dynamically) Tj ( ) Tj (generated) Tj ( ) Tj (function.) Tj ( ) Tj (No) Tj ( ) Tj (source) Tj ( ) Tj (code available) Tj /F1 10 Tf 0 0 0 rg (. In the past I have considered) Tj T* 0 Tw .945366 Tw (this acceptable, since ) Tj /F3 10 Tf 0 0 0 rg (inspect.getsource ) Tj /F1 10 Tf 0 0 0 rg (does not really work even with regular decorators. In that) Tj T* 0 Tw (case ) Tj /F3 10 Tf 0 0 0 rg (inspect.getsource ) Tj /F1 10 Tf 0 0 0 rg (gives you the wrapper source code which is probably not what you want:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 596.8236 cm
+1 0 0 1 62.69291 479.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -4726,7 +4887,7 @@ Q
Q
Q
q
-1 0 0 1 62.69291 551.6236 cm
+1 0 0 1 62.69291 434.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -4782,7 +4943,7 @@ Q
Q
Q
q
-1 0 0 1 62.69291 470.4236 cm
+1 0 0 1 62.69291 365.2236 cm
q
q
1 0 0 1 0 0 cm
@@ -4792,20 +4953,10 @@ q
.662745 .662745 .662745 RG
.5 w
.960784 .960784 .862745 rg
-n -6 -6 468.6898 72 re B*
+n -6 -6 468.6898 60 re B*
Q
q
.960784 .960784 .862745 rg
-n 0 48 6 12 re f*
-.960784 .960784 .862745 rg
-n 6 48 6 12 re f*
-.960784 .960784 .862745 rg
-n 12 48 6 12 re f*
-.960784 .960784 .862745 rg
-n 24 48 36 12 re f*
-.960784 .960784 .862745 rg
-n 66 48 42 12 re f*
-.960784 .960784 .862745 rg
n 0 36 6 12 re f*
.960784 .960784 .862745 rg
n 6 36 6 12 re f*
@@ -4869,20 +5020,20 @@ n 0 0 6 12 re f*
n 6 0 54 12 re f*
.960784 .960784 .862745 rg
n 60 0 6 12 re f*
-BT 1 0 0 1 0 50 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F5 10 Tf 0 .501961 0 rg (import) Tj /F3 10 Tf 0 0 0 rg ( ) Tj /F5 10 Tf 0 0 1 rg (inspect) Tj /F3 10 Tf 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F5 10 Tf 0 .501961 0 rg (print) Tj /F3 10 Tf 0 0 0 rg (\() Tj 0 0 0 rg (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj 0 0 0 rg (\() Tj 0 0 0 rg (example) Tj 0 0 0 rg (\)\)) Tj 0 0 0 rg T* ( ) Tj /F5 10 Tf 0 .501961 0 rg (def) Tj /F3 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 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj 0 0 0 rg (\):) Tj 0 0 0 rg T* ( ) Tj /F5 10 Tf 0 .501961 0 rg (return) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (func) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj 0 0 0 rg (\)) Tj 0 0 0 rg 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 38 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj /F5 10 Tf 0 .501961 0 rg (print) Tj /F3 10 Tf 0 0 0 rg (\() Tj 0 0 0 rg (inspect) Tj .4 .4 .4 rg (.) Tj 0 0 0 rg (getsource) Tj 0 0 0 rg (\() Tj 0 0 0 rg (example) Tj 0 0 0 rg (\)\)) Tj 0 0 0 rg T* ( ) Tj /F5 10 Tf 0 .501961 0 rg (def) Tj /F3 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 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj 0 0 0 rg (\):) Tj 0 0 0 rg T* ( ) Tj /F5 10 Tf 0 .501961 0 rg (return) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (func) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj 0 0 0 rg (\)) Tj 0 0 0 rg 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 414.4236 cm
+1 0 0 1 62.69291 309.2236 cm
q
BT 1 0 0 1 0 38 Tm .011098 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, in all) Tj T* 0 Tw 1.33436 Tw (versions of Python except Python 3.5, which is not yet released. There is however a workaround. The) Tj T* 0 Tw .325984 Tw (decorated function has an attribute ) Tj /F3 10 Tf 0 0 0 rg (.__wrapped__) Tj /F1 10 Tf 0 0 0 rg (, pointing to the original function. The easy way to get) Tj T* 0 Tw (the source code is to call ) Tj /F3 10 Tf 0 0 0 rg (inspect.getsource ) Tj /F1 10 Tf 0 0 0 rg (on the undecorated function:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 297.2236 cm
+1 0 0 1 62.69291 192.0236 cm
q
q
1 0 0 1 0 0 cm
@@ -4992,19 +5143,26 @@ Q
Q
Q
q
-1 0 0 1 62.69291 264.2236 cm
+1 0 0 1 62.69291 159.0236 cm
q
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 210.2236 cm
+1 0 0 1 62.69291 105.0236 cm
q
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 /F3 10 Tf 0 0 0 rg (decorator) Tj /F1 10 Tf 0 0 0 rg (. You can use a ) Tj /F3 10 Tf 0 0 0 rg (FunctionMaker ) Tj /F1 10 Tf 0 0 0 rg (to implement that functionality as follows:) Tj T* ET
Q
Q
+
+endstream
+endobj
+111 0 obj
+<< /Length 16552 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 93.02362 cm
+1 0 0 1 62.69291 655.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -5091,33 +5249,26 @@ Q
Q
Q
Q
-
-endstream
-endobj
-111 0 obj
-<< /Length 16301 >>
-stream
-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 611.8236 cm
q
BT 1 0 0 1 0 26 Tm .079982 Tw 12 TL /F3 10 Tf 0 0 0 rg (decorator_apply ) Tj /F1 10 Tf 0 0 0 rg (sets the attribute ) Tj /F3 10 Tf 0 0 0 rg (__wrapped__ ) Tj /F1 10 Tf 0 0 0 rg (of the generated function to the original function, so) Tj T* 0 Tw .028935 Tw (that you can get the right source code. If you are using Python 3, you should also set the ) Tj /F3 10 Tf 0 0 0 rg (__qualname__) Tj T* 0 Tw /F1 10 Tf 0 0 0 rg (attribute to preserve the qualified name of the original function.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 687.0236 cm
+1 0 0 1 62.69291 569.8236 cm
q
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 /F3 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf 0 0 0 rg (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 /F3 10 Tf 0 0 0 rg (decorator_apply ) Tj /F1 10 Tf 0 0 0 rg (to your toolbox and use it if you need to.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 633.0236 cm
+1 0 0 1 62.69291 515.8236 cm
q
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 /F3 10 Tf 0 0 0 rg (decorator_apply) Tj /F1 10 Tf 0 0 0 rg (, 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 263.8236 cm
+1 0 0 1 62.69291 146.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -5371,14 +5522,14 @@ Q
Q
Q
q
-1 0 0 1 62.69291 243.8236 cm
+1 0 0 1 62.69291 126.6236 cm
q
0 0 0 rg
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 198.6236 cm
+1 0 0 1 62.69291 81.42362 cm
q
q
1 0 0 1 0 0 cm
@@ -5421,15 +5572,22 @@ Q
Q
Q
Q
+
+endstream
+endobj
+112 0 obj
+<< /Length 12371 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 178.6236 cm
+1 0 0 1 62.69291 753.0236 cm
q
0 0 0 rg
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 85.42362 cm
+1 0 0 1 62.69291 659.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -5506,15 +5664,8 @@ Q
Q
Q
Q
-
-endstream
-endobj
-112 0 obj
-<< /Length 13654 >>
-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 614.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -5554,13 +5705,13 @@ Q
Q
Q
q
-1 0 0 1 62.69291 671.8236 cm
+1 0 0 1 62.69291 558.6236 cm
q
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 /F3 10 Tf 0 0 0 rg (factorial\(1001\) ) Tj /F1 10 Tf 0 0 0 rg (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 602.6236 cm
+1 0 0 1 62.69291 489.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -5624,32 +5775,32 @@ Q
Q
Q
q
-1 0 0 1 62.69291 570.6236 cm
+1 0 0 1 62.69291 457.4236 cm
q
0 0 0 rg
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 537.6236 cm
+1 0 0 1 62.69291 424.4236 cm
q
BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Multiple dispatch) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 447.6236 cm
+1 0 0 1 62.69291 334.4236 cm
q
BT 1 0 0 1 0 74 Tm .11936 Tw 12 TL /F1 10 Tf 0 0 0 rg (There has been talk of implementing multiple dispatch \(i.e. generic\) functions in Python for over ten years.) Tj T* 0 Tw 3.96881 Tw (Last year for the first time something was done and now in Python 3.4 we have a decorator) Tj T* 0 Tw .294147 Tw /F3 10 Tf 0 0 0 rg (functools.singledispatch ) Tj /F1 10 Tf 0 0 0 rg (which can be used to implement generic functions. As the name implies,) Tj T* 0 Tw .063322 Tw (it has the restriction of being limited to single dispatch, i.e. it is able to dispatch on the first argument of the) Tj T* 0 Tw 1.423555 Tw (function only. The decorator module provide a decorator factory ) Tj /F3 10 Tf 0 0 0 rg (dispatch_on ) Tj /F1 10 Tf 0 0 0 rg (which can be used to) Tj T* 0 Tw .616905 Tw (implement generic functions dispatching on any argument; moreover it can manage dispatching on more) Tj T* 0 Tw (than one argument and, of course, it is signature-preserving.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 405.6236 cm
+1 0 0 1 62.69291 292.4236 cm
q
BT 1 0 0 1 0 26 Tm 1.551163 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here I will give a very concrete example where it is desiderable to dispatch on the second argument.) Tj T* 0 Tw .216412 Tw (Suppose you have an XMLWriter class, which is instantiated with some configuration parameters and has) Tj T* 0 Tw (a ) Tj /F3 10 Tf 0 0 0 rg (.write ) Tj /F1 10 Tf 0 0 0 rg (method which is able to serialize objects to XML:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 300.4236 cm
+1 0 0 1 62.69291 187.2236 cm
q
q
1 0 0 1 0 0 cm
@@ -5741,13 +5892,20 @@ Q
Q
Q
q
-1 0 0 1 62.69291 220.4236 cm
+1 0 0 1 62.69291 107.2236 cm
q
BT 1 0 0 1 0 62 Tm 3.34936 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here you want to dispatch on the second argument since the first, ) Tj /F3 10 Tf 0 0 0 rg (self ) Tj /F1 10 Tf 0 0 0 rg (is already taken. The) Tj T* 0 Tw 1.127485 Tw /F4 10 Tf 0 0 0 rg (dispatch_on ) Tj /F1 10 Tf 0 0 0 rg (facility allows you to specify the dispatch argument by simply passing its name as a string) Tj T* 0 Tw 1.583516 Tw (\(notice that if you mispell the name you will get an error\). The function decorated with ) Tj /F4 10 Tf 0 0 0 rg (dispatch_on ) Tj /F1 10 Tf 0 0 0 rg (is) Tj T* 0 Tw 3.223876 Tw (turned into a generic function and it is the one which is called if there are no more specialized) Tj T* 0 Tw 2.518976 Tw (implementations. Usually such default function should raise a ) Tj /F3 10 Tf 0 0 0 rg (NotImplementedError) Tj /F1 10 Tf 0 0 0 rg (, thus forcing) Tj T* 0 Tw (people to register some implementation. The registration can be done with a decorator:) Tj T* ET
Q
Q
+
+endstream
+endobj
+113 0 obj
+<< /Length 16993 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 163.2236 cm
+1 0 0 1 62.69291 715.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -5813,14 +5971,14 @@ Q
Q
Q
q
-1 0 0 1 62.69291 143.2236 cm
+1 0 0 1 62.69291 695.8236 cm
q
0 0 0 rg
BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Now the XMLWriter is able to serialize floats:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 86.02362 cm
+1 0 0 1 62.69291 638.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -5889,22 +6047,15 @@ Q
Q
Q
Q
-
-endstream
-endobj
-113 0 obj
-<< /Length 16068 >>
-stream
-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 582.6236 cm
q
0 0 0 rg
BT 1 0 0 1 0 38 Tm /F1 10 Tf 12 TL .352209 Tw (I could give a down-to-earth example of situations in which it is desiderable to dispatch on more than one) Tj T* 0 Tw 3.67998 Tw (argument \(for instance once I implemented a database-access library where the first dispatching) Tj T* 0 Tw .442765 Tw (argument was the the database driver and the second one was the database record\), but here I prefer to) Tj T* 0 Tw (follow the tradition and show the time-honored Rock-Paper-Scissor example:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 671.8236 cm
+1 0 0 1 62.69291 537.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -5940,7 +6091,7 @@ Q
Q
Q
q
-1 0 0 1 62.69291 626.6236 cm
+1 0 0 1 62.69291 492.2236 cm
q
q
1 0 0 1 0 0 cm
@@ -5976,7 +6127,7 @@ Q
Q
Q
q
-1 0 0 1 62.69291 581.4236 cm
+1 0 0 1 62.69291 447.0236 cm
q
q
1 0 0 1 0 0 cm
@@ -6012,13 +6163,13 @@ Q
Q
Q
q
-1 0 0 1 62.69291 489.4236 cm
+1 0 0 1 62.69291 355.0236 cm
q
BT 1 0 0 1 0 74 Tm .606235 Tw 12 TL /F1 10 Tf 0 0 0 rg (I have added an ordinal to the Rock-Paper-Scissor classes to simplify the implementation. The idea is to) Tj T* 0 Tw 1.821235 Tw (define a generic function ) Tj /F3 10 Tf 0 0 0 rg (win\(a, b\) ) Tj /F1 10 Tf 0 0 0 rg (of two arguments corresponding to the moves of the first and) Tj T* 0 Tw 1.487126 Tw (second player respectively. The moves are instances of the classes Rock, Paper and Scissors; Paper) Tj T* 0 Tw .00104 Tw (wins over Rock, Scissor wins over Paper and Rock wins over Scissor. The function will return +1 for a win,) Tj T* 0 Tw .415542 Tw (-1 for a loss and 0 for parity. There are 9 combinations, however combinations with the same ordinal \(i.e.) Tj T* 0 Tw 2.007633 Tw (the same class\) return 0; moreover by exchanging the order of the arguments the sign of the result) Tj T* 0 Tw (changes, so it is enough to specify directly only 3 implementations:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 384.2236 cm
+1 0 0 1 62.69291 249.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -6142,7 +6293,7 @@ Q
Q
Q
q
-1 0 0 1 62.69291 327.0236 cm
+1 0 0 1 62.69291 192.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -6194,7 +6345,7 @@ Q
Q
Q
q
-1 0 0 1 62.69291 269.8236 cm
+1 0 0 1 62.69291 135.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -6246,7 +6397,7 @@ Q
Q
Q
q
-1 0 0 1 62.69291 212.6236 cm
+1 0 0 1 62.69291 78.22362 cm
q
q
1 0 0 1 0 0 cm
@@ -6295,15 +6446,22 @@ Q
Q
Q
Q
+
+endstream
+endobj
+114 0 obj
+<< /Length 14159 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 192.6236 cm
+1 0 0 1 62.69291 753.0236 cm
q
0 0 0 rg
BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Here is the result:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 87.42362 cm
+1 0 0 1 62.69291 515.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -6313,114 +6471,87 @@ q
.662745 .662745 .662745 RG
.5 w
.960784 .960784 .862745 rg
-n -6 -6 468.6898 96 re B*
+n -6 -6 468.6898 228 re B*
Q
q
.960784 .960784 .862745 rg
-n 0 72 6 12 re f*
+n 0 204 6 12 re f*
.960784 .960784 .862745 rg
-n 6 72 6 12 re f*
+n 6 204 6 12 re f*
.960784 .960784 .862745 rg
-n 12 72 6 12 re f*
+n 12 204 6 12 re f*
.960784 .960784 .862745 rg
-n 24 72 18 12 re f*
+n 24 204 18 12 re f*
.960784 .960784 .862745 rg
-n 42 72 6 12 re f*
+n 42 204 6 12 re f*
.960784 .960784 .862745 rg
-n 48 72 30 12 re f*
+n 48 204 30 12 re f*
.960784 .960784 .862745 rg
-n 78 72 18 12 re f*
+n 78 204 18 12 re f*
.960784 .960784 .862745 rg
-n 102 72 24 12 re f*
+n 102 204 24 12 re f*
.960784 .960784 .862745 rg
-n 126 72 18 12 re f*
+n 126 204 18 12 re f*
.960784 .960784 .862745 rg
-n 0 60 6 12 re f*
+n 0 192 6 12 re f*
.960784 .960784 .862745 rg
-n 0 48 6 12 re f*
+n 0 180 6 12 re f*
.960784 .960784 .862745 rg
-n 6 48 6 12 re f*
+n 6 180 6 12 re f*
.960784 .960784 .862745 rg
-n 12 48 6 12 re f*
+n 12 180 6 12 re f*
.960784 .960784 .862745 rg
-n 24 48 18 12 re f*
+n 24 180 18 12 re f*
.960784 .960784 .862745 rg
-n 42 48 6 12 re f*
+n 42 180 6 12 re f*
.960784 .960784 .862745 rg
-n 48 48 42 12 re f*
+n 48 180 42 12 re f*
.960784 .960784 .862745 rg
-n 90 48 18 12 re f*
+n 90 180 18 12 re f*
.960784 .960784 .862745 rg
-n 114 48 30 12 re f*
+n 114 180 30 12 re f*
.960784 .960784 .862745 rg
-n 144 48 18 12 re f*
+n 144 180 18 12 re f*
.960784 .960784 .862745 rg
-n 0 36 6 12 re f*
+n 0 168 6 12 re f*
.960784 .960784 .862745 rg
-n 0 24 6 12 re f*
+n 0 156 6 12 re f*
.960784 .960784 .862745 rg
-n 6 24 6 12 re f*
+n 6 156 6 12 re f*
.960784 .960784 .862745 rg
-n 12 24 6 12 re f*
+n 12 156 6 12 re f*
.960784 .960784 .862745 rg
-n 24 24 18 12 re f*
+n 24 156 18 12 re f*
.960784 .960784 .862745 rg
-n 42 24 6 12 re f*
+n 42 156 6 12 re f*
.960784 .960784 .862745 rg
-n 48 24 24 12 re f*
+n 48 156 24 12 re f*
.960784 .960784 .862745 rg
-n 72 24 18 12 re f*
+n 72 156 18 12 re f*
.960784 .960784 .862745 rg
-n 96 24 42 12 re f*
+n 96 156 42 12 re f*
.960784 .960784 .862745 rg
-n 138 24 18 12 re f*
+n 138 156 18 12 re f*
.960784 .960784 .862745 rg
-n 0 12 6 12 re f*
+n 0 144 6 12 re f*
.960784 .960784 .862745 rg
-n 0 0 6 12 re f*
+n 0 132 6 12 re f*
.960784 .960784 .862745 rg
-n 6 0 6 12 re f*
+n 6 132 6 12 re f*
.960784 .960784 .862745 rg
-n 12 0 6 12 re f*
+n 12 132 6 12 re f*
.960784 .960784 .862745 rg
-n 24 0 18 12 re f*
+n 24 132 18 12 re f*
.960784 .960784 .862745 rg
-n 42 0 6 12 re f*
+n 42 132 6 12 re f*
.960784 .960784 .862745 rg
-n 48 0 30 12 re f*
+n 48 132 30 12 re f*
.960784 .960784 .862745 rg
-n 78 0 18 12 re f*
+n 78 132 18 12 re f*
.960784 .960784 .862745 rg
-n 102 0 30 12 re f*
+n 102 132 30 12 re f*
.960784 .960784 .862745 rg
-n 132 0 18 12 re f*
-BT 1 0 0 1 0 74 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* ET
-Q
-Q
-Q
-Q
-Q
-
-endstream
-endobj
-114 0 obj
-<< /Length 12873 >>
-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
-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 144 re B*
-Q
-q
+n 132 132 18 12 re f*
.960784 .960784 .862745 rg
n 0 120 6 12 re f*
.960784 .960784 .862745 rg
@@ -6529,27 +6660,27 @@ n 138 12 18 12 re f*
n 0 0 6 12 re f*
.960784 .960784 .862745 rg
n 6 0 6 12 re f*
-BT 1 0 0 1 0 122 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (0) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (0) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (0) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (-) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (-) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (-) Tj .4 .4 .4 rg (1) Tj T* ET
+BT 1 0 0 1 0 206 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (0) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (0) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (0) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (-) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Paper) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (-) Tj .4 .4 .4 rg (1) Tj 0 0 0 rg T* .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (win) Tj 0 0 0 rg (\() Tj 0 0 0 rg (Scissor) Tj 0 0 0 rg (\(\),) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (Rock) Tj 0 0 0 rg (\(\)\)) Tj 0 0 0 rg T* .4 .4 .4 rg (-) Tj .4 .4 .4 rg (1) Tj T* ET
Q
Q
Q
Q
Q
q
-1 0 0 1 62.69291 586.8236 cm
+1 0 0 1 62.69291 482.8236 cm
q
BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (Generic functions and virtual ancestors) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 556.8236 cm
+1 0 0 1 62.69291 452.8236 cm
q
0 0 0 rg
BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL 1.225366 Tw (Generic function implementations in Python are complicated by the existence of "virtual ancestors", i.e.) Tj T* 0 Tw (superclasses which are not in the class hierarchy. Consider for instance this class:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 499.6236 cm
+1 0 0 1 62.69291 395.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -6593,13 +6724,13 @@ Q
Q
Q
q
-1 0 0 1 62.69291 467.6236 cm
+1 0 0 1 62.69291 363.6236 cm
q
BT 1 0 0 1 0 14 Tm .772765 Tw 12 TL /F1 10 Tf 0 0 0 rg (This class defines a ) Tj /F3 10 Tf 0 0 0 rg (__len__ ) Tj /F1 10 Tf 0 0 0 rg (method and as such is considered to be a subclass of the abstract base) Tj T* 0 Tw (class ) Tj /F3 10 Tf 0 0 0 rg (collections.Sized) Tj /F1 10 Tf 0 0 0 rg (:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 422.4236 cm
+1 0 0 1 62.69291 318.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -6643,20 +6774,20 @@ Q
Q
Q
q
-1 0 0 1 62.69291 378.4236 cm
+1 0 0 1 62.69291 274.4236 cm
q
BT 1 0 0 1 0 26 Tm 2.180888 Tw 12 TL /F1 10 Tf 0 0 0 rg (However, ) Tj /F3 10 Tf 0 0 0 rg (collections.Sized ) Tj /F1 10 Tf 0 0 0 rg (is not an ancestor of ) Tj /F3 10 Tf 0 0 0 rg (WithLength) Tj /F1 10 Tf 0 0 0 rg (. Any implementation of generic) Tj T* 0 Tw 1.570651 Tw (functions, even with single dispatch, must go through some contorsion to take into account the virtual) Tj T* 0 Tw (ancestors.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 360.4236 cm
+1 0 0 1 62.69291 256.4236 cm
q
0 0 0 rg
BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (In particular if we define a generic function) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 303.2236 cm
+1 0 0 1 62.69291 199.2236 cm
q
q
1 0 0 1 0 0 cm
@@ -6708,14 +6839,14 @@ Q
Q
Q
q
-1 0 0 1 62.69291 283.2236 cm
+1 0 0 1 62.69291 179.2236 cm
q
0 0 0 rg
BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (implemented on all classes with a length) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 226.0236 cm
+1 0 0 1 62.69291 122.0236 cm
q
q
1 0 0 1 0 0 cm
@@ -6767,13 +6898,20 @@ Q
Q
Q
q
-1 0 0 1 62.69291 206.0236 cm
+1 0 0 1 62.69291 102.0236 cm
q
BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (then ) Tj /F3 10 Tf 0 0 0 rg (get_length ) Tj /F1 10 Tf 0 0 0 rg (must be defined on ) Tj /F3 10 Tf 0 0 0 rg (WithLength ) Tj /F1 10 Tf 0 0 0 rg (instances:) Tj T* ET
Q
Q
+
+endstream
+endobj
+115 0 obj
+<< /Length 14956 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 160.8236 cm
+1 0 0 1 62.69291 727.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -6809,26 +6947,19 @@ Q
Q
Q
q
-1 0 0 1 62.69291 140.8236 cm
+1 0 0 1 62.69291 707.8236 cm
q
BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (Of course this is a contrived example since you could just use the builtin ) Tj /F3 10 Tf 0 0 0 rg (len) Tj /F1 10 Tf 0 0 0 rg (, but you should get the idea.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 86.82362 cm
+1 0 0 1 62.69291 653.8236 cm
q
BT 1 0 0 1 0 38 Tm .646651 Tw 12 TL /F1 10 Tf 0 0 0 rg (The implementation of generic functions in the decorator module is still experimental. In this initial phase) Tj T* 0 Tw 2.659069 Tw (implicity was preferred over consistency with the way ) Tj /F3 10 Tf 0 0 0 rg (functools.singledispatch ) Tj /F1 10 Tf 0 0 0 rg (works in the) Tj T* 0 Tw .258735 Tw (standard library. So there some subtle differences in special cases. I will only show an example. Suppose) Tj T* 0 Tw (you are using a third party set-like class like the following:) Tj T* ET
Q
Q
-
-endstream
-endobj
-115 0 obj
-<< /Length 14773 >>
-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 572.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -6882,19 +7013,19 @@ Q
Q
Q
q
-1 0 0 1 62.69291 659.8236 cm
+1 0 0 1 62.69291 540.6236 cm
q
BT 1 0 0 1 0 14 Tm 1.042651 Tw 12 TL /F1 10 Tf 0 0 0 rg (Here the author of ) Tj /F3 10 Tf 0 0 0 rg (SomeSet ) Tj /F1 10 Tf 0 0 0 rg (made a mistake by not inheriting from ) Tj /F3 10 Tf 0 0 0 rg (collections.Set) Tj /F1 10 Tf 0 0 0 rg (, but only from) Tj T* 0 Tw /F3 10 Tf 0 0 0 rg (collections.Sized) Tj /F1 10 Tf 0 0 0 rg (.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 629.8236 cm
+1 0 0 1 62.69291 510.6236 cm
q
BT 1 0 0 1 0 14 Tm 1.797485 Tw 12 TL /F1 10 Tf 0 0 0 rg (This is not a problem since we can register ) Tj /F4 10 Tf (a posteriori) Tj /F1 10 Tf ( ) Tj /F3 10 Tf 0 0 0 rg (collections.Set ) Tj /F1 10 Tf 0 0 0 rg (as a virtual ancestor of) Tj T* 0 Tw /F3 10 Tf 0 0 0 rg (SomeSet ) Tj /F1 10 Tf 0 0 0 rg (\(in general any instance of ) Tj /F3 10 Tf 0 0 0 rg (abc.ABCMeta ) Tj /F1 10 Tf 0 0 0 rg (can be registered to work as a virtual ancestor\):) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 596.6236 cm
+1 0 0 1 62.69291 477.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -6942,13 +7073,13 @@ Q
Q
Q
q
-1 0 0 1 62.69291 576.6236 cm
+1 0 0 1 62.69291 457.4236 cm
q
BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (Now, let us define an implementation of ) Tj /F3 10 Tf 0 0 0 rg (get_length ) Tj /F1 10 Tf 0 0 0 rg (specific to set:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 519.4236 cm
+1 0 0 1 62.69291 400.2236 cm
q
q
1 0 0 1 0 0 cm
@@ -7004,13 +7135,13 @@ Q
Q
Q
q
-1 0 0 1 62.69291 487.4236 cm
+1 0 0 1 62.69291 368.2236 cm
q
BT 1 0 0 1 0 14 Tm 1.152651 Tw 12 TL /F1 10 Tf 0 0 0 rg (The current implementation first check in the MRO and then look for virtual ancestors; since ) Tj /F3 10 Tf 0 0 0 rg (SomeSet) Tj T* 0 Tw /F1 10 Tf 0 0 0 rg (inherits directly from ) Tj /F3 10 Tf 0 0 0 rg (collections.Sized ) Tj /F1 10 Tf 0 0 0 rg (that implementation is found first:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 442.2236 cm
+1 0 0 1 62.69291 323.0236 cm
q
q
1 0 0 1 0 0 cm
@@ -7046,19 +7177,19 @@ Q
Q
Q
q
-1 0 0 1 62.69291 386.2236 cm
+1 0 0 1 62.69291 267.0236 cm
q
BT 1 0 0 1 0 38 Tm 2.257752 Tw 12 TL /F1 10 Tf 0 0 0 rg (Generic functions implemented via ) Tj /F3 10 Tf 0 0 0 rg (functools.singledispatch ) Tj /F1 10 Tf 0 0 0 rg (use a more sophisticated lookup) Tj T* 0 Tw .632209 Tw (algorithm; in particular they are able to discern that a ) Tj /F3 10 Tf 0 0 0 rg (Set ) Tj /F1 10 Tf 0 0 0 rg (is a ) Tj /F3 10 Tf 0 0 0 rg (Sized ) Tj /F1 10 Tf 0 0 0 rg (object, so the implementation for) Tj T* 0 Tw 2.135777 Tw /F3 10 Tf 0 0 0 rg (Set ) Tj /F1 10 Tf 0 0 0 rg (is taken and the result is 1, not 0. Still, the implementation in the decorator module is easy to) Tj T* 0 Tw (undestand, once one declare that real ancestors take the precedence over virtual ancestors.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 344.2236 cm
+1 0 0 1 62.69291 225.0236 cm
q
BT 1 0 0 1 0 26 Tm 1.365976 Tw 12 TL /F1 10 Tf 0 0 0 rg (The functions implemented via ) Tj /F3 10 Tf 0 0 0 rg (functools.singledispatch ) Tj /F1 10 Tf 0 0 0 rg (are smarter when there are conflicting) Tj T* 0 Tw .691654 Tw (implementations and are able to solve more potential conflicts. Just to have an idea of what I am talking) Tj T* 0 Tw (about, here is a situation with a conflict:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 227.0236 cm
+1 0 0 1 62.69291 107.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -7199,40 +7330,40 @@ Q
Q
Q
Q
+
+endstream
+endobj
+116 0 obj
+<< /Length 8003 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 171.0236 cm
+1 0 0 1 62.69291 717.0236 cm
q
BT 1 0 0 1 0 38 Tm 9.280976 Tw 12 TL /F1 10 Tf 0 0 0 rg (Since ) Tj /F3 10 Tf 0 0 0 rg (WithLength ) Tj /F1 10 Tf 0 0 0 rg (is both a \(virtual\) subclass of ) Tj /F3 10 Tf 0 0 0 rg (collections.Iterable ) Tj /F1 10 Tf 0 0 0 rg (and of) Tj T* 0 Tw 4.906647 Tw /F3 10 Tf 0 0 0 rg (collections.Sized) Tj /F1 10 Tf 0 0 0 rg (, which are not related by subclassing, it is impossible to decide which) Tj T* 0 Tw .214269 Tw (implementation should be taken. Consistently with the ) Tj /F4 10 Tf (refuse the temptation to guess ) Tj /F1 10 Tf (philosophy, an error) Tj T* 0 Tw (is raised. ) Tj /F3 10 Tf 0 0 0 rg (functools.singledispatch ) Tj /F1 10 Tf 0 0 0 rg (would work exactly the same in this case.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 141.0236 cm
+1 0 0 1 62.69291 687.0236 cm
q
BT 1 0 0 1 0 14 Tm .39561 Tw 12 TL /F1 10 Tf 0 0 0 rg (Finally let me notice that the decorator module implementation does not use any cache, whereas the one) Tj T* 0 Tw (in ) Tj /F3 10 Tf 0 0 0 rg (singledispatch ) Tj /F1 10 Tf 0 0 0 rg (has a cache.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 108.0236 cm
+1 0 0 1 62.69291 654.0236 cm
q
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 78.02362 cm
+1 0 0 1 62.69291 624.0236 cm
q
0 0 0 rg
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
-
-endstream
-endobj
-116 0 obj
-<< /Length 10109 >>
-stream
-1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 547.8236 cm
+1 0 0 1 62.69291 398.8236 cm
q
q
1 0 0 1 0 0 cm
@@ -7253,13 +7384,13 @@ Q
Q
Q
q
-1 0 0 1 62.69291 527.8236 cm
+1 0 0 1 62.69291 378.8236 cm
q
BT 1 0 0 1 0 2 Tm 12 TL /F1 10 Tf 0 0 0 rg (On my laptop, using the ) Tj /F3 10 Tf 0 0 0 rg (do_nothing ) Tj /F1 10 Tf 0 0 0 rg (decorator instead of the plain function is five times slower:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 470.6236 cm
+1 0 0 1 62.69291 321.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -7280,20 +7411,20 @@ Q
Q
Q
q
-1 0 0 1 62.69291 426.6236 cm
+1 0 0 1 62.69291 277.6236 cm
q
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 /F3 10 Tf 0 0 0 rg (f ) Tj /F1 10 Tf 0 0 0 rg (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 396.6236 cm
+1 0 0 1 62.69291 247.6236 cm
q
0 0 0 rg
BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL .091984 Tw (More importantly, you should be aware that decorators will make your tracebacks longer and more difficult) Tj T* 0 Tw (to understand. Consider this example:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 339.4236 cm
+1 0 0 1 62.69291 190.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -7337,13 +7468,13 @@ Q
Q
Q
q
-1 0 0 1 62.69291 307.4236 cm
+1 0 0 1 62.69291 158.4236 cm
q
BT 1 0 0 1 0 14 Tm .583318 Tw 12 TL /F1 10 Tf 0 0 0 rg (Calling ) Tj /F3 10 Tf 0 0 0 rg (f\(\) ) Tj /F1 10 Tf 0 0 0 rg (will give you a ) Tj /F3 10 Tf 0 0 0 rg (ZeroDivisionError) Tj /F1 10 Tf 0 0 0 rg (, 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 178.2236 cm
+1 0 0 1 62.69291 77.22362 cm
q
q
1 0 0 1 0 0 cm
@@ -7353,83 +7484,110 @@ q
.662745 .662745 .662745 RG
.5 w
.960784 .960784 .862745 rg
-n -6 -6 468.6898 120 re B*
+n -6 -6 468.6898 72 re B*
Q
q
.960784 .960784 .862745 rg
-n 0 96 6 12 re f*
+n 0 48 6 12 re f*
.960784 .960784 .862745 rg
-n 6 96 6 12 re f*
+n 6 48 6 12 re f*
.960784 .960784 .862745 rg
-n 12 96 6 12 re f*
+n 12 48 6 12 re f*
.960784 .960784 .862745 rg
-n 24 96 6 12 re f*
+n 24 48 6 12 re f*
.960784 .960784 .862745 rg
-n 30 96 12 12 re f*
+n 30 48 12 12 re f*
.960784 .960784 .862745 rg
-n 0 84 54 12 re f*
+n 0 36 54 12 re f*
.960784 .960784 .862745 rg
-n 60 84 6 12 re f*
+n 60 36 6 12 re f*
.960784 .960784 .862745 rg
-n 66 84 24 12 re f*
+n 66 36 24 12 re f*
.960784 .960784 .862745 rg
-n 96 84 36 12 re f*
+n 96 36 36 12 re f*
.960784 .960784 .862745 rg
-n 138 84 24 12 re f*
+n 138 36 24 12 re f*
.960784 .960784 .862745 rg
-n 168 84 24 12 re f*
+n 168 36 24 12 re f*
.960784 .960784 .862745 rg
-n 192 84 12 12 re f*
+n 192 36 12 12 re f*
.960784 .960784 .862745 rg
-n 12 72 18 12 re f*
+n 12 24 18 12 re f*
.960784 .960784 .862745 rg
-n 30 60 24 12 re f*
+n 30 12 24 12 re f*
.960784 .960784 .862745 rg
-n 60 60 6 12 re f*
+n 60 12 6 12 re f*
.960784 .960784 .862745 rg
-n 66 60 6 12 re f*
+n 66 12 6 12 re f*
.960784 .960784 .862745 rg
-n 72 60 36 12 re f*
+n 72 12 36 12 re f*
.960784 .960784 .862745 rg
-n 108 60 6 12 re f*
+n 108 12 6 12 re f*
.960784 .960784 .862745 rg
-n 114 60 6 12 re f*
+n 114 12 6 12 re f*
.960784 .960784 .862745 rg
-n 120 60 6 12 re f*
+n 120 12 6 12 re f*
.960784 .960784 .862745 rg
-n 132 60 24 12 re f*
+n 132 12 24 12 re f*
.960784 .960784 .862745 rg
-n 162 60 6 12 re f*
+n 162 12 6 12 re f*
.960784 .960784 .862745 rg
-n 168 60 6 12 re f*
+n 168 12 6 12 re f*
.960784 .960784 .862745 rg
-n 180 60 12 12 re f*
+n 180 12 12 12 re f*
.960784 .960784 .862745 rg
-n 198 60 6 12 re f*
+n 198 12 6 12 re f*
.960784 .960784 .862745 rg
-n 30 48 24 12 re f*
+n 30 0 24 12 re f*
.960784 .960784 .862745 rg
-n 60 48 6 12 re f*
+n 60 0 6 12 re f*
.960784 .960784 .862745 rg
-n 66 48 6 12 re f*
+n 66 0 6 12 re f*
.960784 .960784 .862745 rg
-n 72 48 120 12 re f*
+n 72 0 120 12 re f*
.960784 .960784 .862745 rg
-n 192 48 6 12 re f*
+n 192 0 6 12 re f*
.960784 .960784 .862745 rg
-n 198 48 6 12 re f*
+n 198 0 6 12 re f*
.960784 .960784 .862745 rg
-n 204 48 6 12 re f*
+n 204 0 6 12 re f*
.960784 .960784 .862745 rg
-n 216 48 24 12 re f*
+n 216 0 24 12 re f*
.960784 .960784 .862745 rg
-n 246 48 6 12 re f*
+n 246 0 6 12 re f*
.960784 .960784 .862745 rg
-n 252 48 6 12 re f*
+n 252 0 6 12 re f*
.960784 .960784 .862745 rg
-n 264 48 12 12 re f*
+n 264 0 12 12 re f*
.960784 .960784 .862745 rg
-n 282 48 30 12 re f*
+n 282 0 30 12 re f*
+BT 1 0 0 1 0 50 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg (\(\)) Tj 0 0 0 rg T* 0 0 0 rg (Traceback) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (\() Tj 0 0 0 rg (most) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (recent) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (call) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (last) Tj 0 0 0 rg (\):) Tj 0 0 0 rg T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* ( ) Tj 0 0 0 rg (File) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (string) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (line) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj /F5 10 Tf .666667 .133333 1 rg (in) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg T* ( ) Tj 0 0 0 rg (File) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[22]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (line) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj /F5 10 Tf .666667 .133333 1 rg (in) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (trace) Tj 0 0 0 rg T* ET
+Q
+Q
+Q
+Q
+Q
+
+endstream
+endobj
+117 0 obj
+<< /Length 14983 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
+q
+1 0 0 1 62.69291 703.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 60 re B*
+Q
+q
.960784 .960784 .862745 rg
n 42 36 36 12 re f*
.960784 .960784 .862745 rg
@@ -7484,51 +7642,38 @@ n 0 0 102 12 re f*
n 102 0 6 12 re f*
.960784 .960784 .862745 rg
n 114 0 18 12 re f*
-BT 1 0 0 1 0 98 Tm 12 TL /F3 10 Tf .4 .4 .4 rg (>) Tj (>) Tj (>) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg (\(\)) Tj 0 0 0 rg T* 0 0 0 rg (Traceback) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (\() Tj 0 0 0 rg (most) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (recent) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (call) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (last) Tj 0 0 0 rg (\):) Tj 0 0 0 rg T* ( ) Tj .4 .4 .4 rg (...) Tj 0 0 0 rg T* ( ) Tj 0 0 0 rg (File) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (string) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (line) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (2) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj /F5 10 Tf .666667 .133333 1 rg (in) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg T* ( ) Tj 0 0 0 rg (File) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[22]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (line) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (4) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj /F5 10 Tf .666667 .133333 1 rg (in) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (trace) Tj 0 0 0 rg T* ( ) Tj /F5 10 Tf 0 .501961 0 rg (return) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj 0 0 0 rg (\)) Tj 0 0 0 rg T* ( ) Tj 0 0 0 rg (File) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[51]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (line) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj /F5 10 Tf .666667 .133333 1 rg (in) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg T* ( ) Tj .4 .4 .4 rg (1) Tj .4 .4 .4 rg (/) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg T* /F5 10 Tf .823529 .254902 .227451 rg (ZeroDivisionError) Tj /F3 10 Tf 0 0 0 rg (:) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (...) Tj T* ET
+BT 1 0 0 1 0 38 Tm 12 TL /F3 10 Tf 0 0 0 rg ( ) Tj /F5 10 Tf 0 .501961 0 rg (return) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg (\() Tj .4 .4 .4 rg (*) Tj 0 0 0 rg (args) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (**) Tj 0 0 0 rg (kw) Tj 0 0 0 rg (\)) Tj 0 0 0 rg T* ( ) Tj 0 0 0 rg (File) Tj 0 0 0 rg ( ) Tj .729412 .129412 .129412 rg (") Tj (<) Tj (doctest __main__[51]) Tj (>) Tj (") Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj 0 0 0 rg (line) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (3) Tj 0 0 0 rg (,) Tj 0 0 0 rg ( ) Tj /F5 10 Tf .666667 .133333 1 rg (in) Tj /F3 10 Tf 0 0 0 rg ( ) Tj 0 0 0 rg (f) Tj 0 0 0 rg T* ( ) Tj .4 .4 .4 rg (1) Tj .4 .4 .4 rg (/) Tj .4 .4 .4 rg (0) Tj 0 0 0 rg T* /F5 10 Tf .823529 .254902 .227451 rg (ZeroDivisionError) Tj /F3 10 Tf 0 0 0 rg (:) Tj 0 0 0 rg ( ) Tj .4 .4 .4 rg (...) Tj T* ET
Q
Q
Q
Q
Q
q
-1 0 0 1 62.69291 110.2236 cm
+1 0 0 1 62.69291 635.8236 cm
q
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 /F3 10 Tf 0 0 0 rg (trace) Tj /F1 10 Tf 0 0 0 rg (, which calls ) Tj /F3 10 Tf 0 0 0 rg (f\(*args,) Tj ( ) Tj (**kw\)) Tj /F1 10 Tf 0 0 0 rg (, and a reference to) Tj T* 0 Tw .076457 Tw /F3 10 Tf 0 0 0 rg (File) Tj ( ) Tj (") Tj (<) Tj (string) Tj (>) Tj (",) Tj ( ) Tj (line) Tj ( ) Tj (2,) Tj ( ) Tj (in) Tj ( ) Tj (f) Tj /F1 10 Tf 0 0 0 rg (. This latter reference is due to the fact that internally the decorator) Tj T* 0 Tw 2.053318 Tw (module uses ) Tj /F3 10 Tf 0 0 0 rg (exec ) Tj /F1 10 Tf 0 0 0 rg (to generate the decorated function. Notice that ) Tj /F3 10 Tf 0 0 0 rg (exec ) Tj /F1 10 Tf 0 0 0 rg (is ) Tj /F4 10 Tf (not ) Tj /F1 10 Tf (responsibile for the) Tj T* 0 Tw 1.507485 Tw (performance penalty, since is the called ) Tj /F4 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 80.22362 cm
+1 0 0 1 62.69291 509.8236 cm
q
-BT 1 0 0 1 0 14 Tm .932209 Tw 12 TL /F1 10 Tf 0 0 0 rg (At present, there is no clean way to avoid ) Tj /F3 10 Tf 0 0 0 rg (exec) Tj /F1 10 Tf 0 0 0 rg (. 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 ET
+BT 1 0 0 1 0 110 Tm .932209 Tw 12 TL /F1 10 Tf 0 0 0 rg (At present, there is no clean way to avoid ) Tj /F3 10 Tf 0 0 0 rg (exec) Tj /F1 10 Tf 0 0 0 rg (. 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.4 it is impossible to change the function signature) Tj T* 0 Tw 1.372485 Tw (directly, therefore the ) Tj /F3 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf 0 0 0 rg (module is still useful. Actually, this is the main reasons why I keep) Tj T* 0 Tw 2.169398 Tw (maintaining the module and releasing new versions. It should be noticed that in Python 3.5 a lot of) Tj T* 0 Tw 9.189147 Tw (improvements have been made: in that version you can decorated a function with) Tj T* 0 Tw .084147 Tw /F3 10 Tf 0 0 0 rg (func_tools.update_wrapper ) Tj /F1 10 Tf 0 0 0 rg (and ) Tj /F3 10 Tf 0 0 0 rg (pydoc ) Tj /F1 10 Tf 0 0 0 rg (will see the correct signature; still internally the function will) Tj T* 0 Tw 1.47748 Tw (have an incorrect signature, as you can see by using ) Tj /F3 10 Tf 0 0 0 rg (inspect.getfullargspec) Tj /F1 10 Tf 0 0 0 rg (: all documentation) Tj T* 0 Tw (tools using such function \(which has been correctly deprecated\) will see the wrong signature.) Tj T* ET
Q
Q
-
-endstream
-endobj
-117 0 obj
-<< /Length 13088 >>
-stream
-1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 669.0236 cm
-q
-BT 1 0 0 1 0 86 Tm .74186 Tw 12 TL /F1 10 Tf 0 0 0 rg (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.4 it is impossible to change the function signature) Tj T* 0 Tw 1.372485 Tw (directly, therefore the ) Tj /F3 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf 0 0 0 rg (module is still useful. Actually, this is the main reasons why I keep) Tj T* 0 Tw 2.169398 Tw (maintaining the module and releasing new versions. It should be noticed that in Python 3.5 a lot of) Tj T* 0 Tw 9.189147 Tw (improvements have been made: in that version you can decorated a function with) Tj T* 0 Tw .084147 Tw /F3 10 Tf 0 0 0 rg (func_tools.update_wrapper ) Tj /F1 10 Tf 0 0 0 rg (and ) Tj /F3 10 Tf 0 0 0 rg (pydoc ) Tj /F1 10 Tf 0 0 0 rg (will see the correct signature; still internally the function will) Tj T* 0 Tw 1.47748 Tw (have an incorrect signature, as you can see by using ) Tj /F3 10 Tf 0 0 0 rg (inspect.getfullargspec) Tj /F1 10 Tf 0 0 0 rg (: all documentation) Tj T* 0 Tw (tools using such function \(which has been correctly deprecated\) will see the wrong signature.) Tj T* ET
-Q
-Q
-q
-1 0 0 1 62.69291 615.0236 cm
+1 0 0 1 62.69291 455.8236 cm
q
BT 1 0 0 1 0 38 Tm 1.043828 Tw 12 TL /F1 10 Tf 0 0 0 rg (In the present implementation, decorators generated by ) Tj /F3 10 Tf 0 0 0 rg (decorator ) Tj /F1 10 Tf 0 0 0 rg (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 2.15881 Tw (the ) Tj /F3 10 Tf 0 0 0 rg (inspect ) Tj /F1 10 Tf 0 0 0 rg (module in the standard library, especially for Python 2.X \(in Python 3.5 a lot of such) Tj T* 0 Tw (limitations have been removed\).) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 585.0236 cm
+1 0 0 1 62.69291 425.8236 cm
q
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 /F3 10 Tf 0 0 0 rg (_call_ ) Tj /F1 10 Tf 0 0 0 rg (or) Tj T* 0 Tw /F3 10 Tf 0 0 0 rg (_func_ ) Tj /F1 10 Tf 0 0 0 rg (you will get a ) Tj /F3 10 Tf 0 0 0 rg (NameError) Tj /F1 10 Tf 0 0 0 rg (:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 467.8236 cm
+1 0 0 1 62.69291 308.6236 cm
q
q
1 0 0 1 0 0 cm
@@ -7630,14 +7775,14 @@ Q
Q
Q
q
-1 0 0 1 62.69291 435.8236 cm
+1 0 0 1 62.69291 276.6236 cm
q
0 0 0 rg
BT 1 0 0 1 0 14 Tm /F1 10 Tf 12 TL 1.720651 Tw (Finally, the implementation is such that the decorated function makes a \(shallow\) copy of the original) Tj T* 0 Tw (function dictionary:) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 282.6236 cm
+1 0 0 1 62.69291 123.4236 cm
q
q
1 0 0 1 0 0 cm
@@ -7776,31 +7921,38 @@ Q
Q
Q
Q
+
+endstream
+endobj
+118 0 obj
+<< /Length 2646 >>
+stream
+1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET
q
-1 0 0 1 62.69291 249.6236 cm
+1 0 0 1 62.69291 744.0236 cm
q
BT 1 0 0 1 0 3.5 Tm 21 TL /F2 17.5 Tf 0 0 0 rg (LICENSE) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 231.6236 cm
+1 0 0 1 62.69291 726.0236 cm
q
0 0 0 rg
BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (Copyright \(c\) 2005-2015, Michele Simionato All rights reserved.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 201.6236 cm
+1 0 0 1 62.69291 696.0236 cm
q
0 0 0 rg
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 195.6236 cm
+1 0 0 1 62.69291 690.0236 cm
Q
q
-1 0 0 1 62.69291 147.6236 cm
+1 0 0 1 62.69291 642.0236 cm
0 0 0 rg
BT /F1 10 Tf 12 TL ET
BT 1 0 0 1 0 2 Tm T* ET
@@ -7815,31 +7967,17 @@ q
Q
Q
q
-1 0 0 1 62.69291 147.6236 cm
-Q
-q
-1 0 0 1 62.69291 81.62362 cm
-q
-0 0 0 rg
-BT 1 0 0 1 0 50 Tm /F1 10 Tf 12 TL .17998 Tw (THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND) Tj T* 0 Tw 2.911797 Tw (ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED) Tj T* 0 Tw 5.165529 Tw (WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE) Tj T* 0 Tw 1.395433 Tw (DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE) Tj T* 0 Tw 5.53122 Tw (FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL) Tj T* 0 Tw ET
-Q
+1 0 0 1 62.69291 642.0236 cm
Q
-
-endstream
-endobj
-118 0 obj
-<< /Length 939 >>
-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 516.0236 cm
q
0 0 0 rg
-BT 1 0 0 1 0 50 Tm /F1 10 Tf 12 TL 2.705976 Tw (DAMAGES \(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR) Tj T* 0 Tw 3.868976 Tw (SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION\) HOWEVER) Tj T* 0 Tw 1.326647 Tw (CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR) Tj T* 0 Tw 1.525366 Tw (TORT \(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE OF) Tj T* 0 Tw (THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.) Tj T* ET
+BT 1 0 0 1 0 110 Tm /F1 10 Tf 12 TL .17998 Tw (THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND) Tj T* 0 Tw 2.911797 Tw (ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED) Tj T* 0 Tw 5.165529 Tw (WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE) Tj T* 0 Tw 1.395433 Tw (DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE) Tj T* 0 Tw 5.53122 Tw (FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL) Tj T* 0 Tw 2.705976 Tw (DAMAGES \(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR) Tj T* 0 Tw 3.868976 Tw (SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION\) HOWEVER) Tj T* 0 Tw 1.326647 Tw (CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR) Tj T* 0 Tw 1.525366 Tw (TORT \(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE OF) Tj T* 0 Tw (THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.) Tj T* ET
Q
Q
q
-1 0 0 1 62.69291 675.0236 cm
+1 0 0 1 62.69291 486.0236 cm
q
0 0 0 rg
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
@@ -8024,39 +8162,39 @@ xref
0000137047 00000 n
0000151757 00000 n
0000166038 00000 n
-0000182363 00000 n
-0000198723 00000 n
-0000212436 00000 n
-0000228563 00000 n
-0000241495 00000 n
-0000256327 00000 n
-0000266495 00000 n
-0000279642 00000 n
-0000280638 00000 n
-0000280885 00000 n
-0000280923 00000 n
-0000280961 00000 n
-0000280999 00000 n
-0000281037 00000 n
-0000281075 00000 n
-0000281113 00000 n
-0000281151 00000 n
-0000281189 00000 n
-0000281227 00000 n
-0000281266 00000 n
-0000281305 00000 n
-0000281344 00000 n
-0000281383 00000 n
-0000281422 00000 n
-0000281461 00000 n
-0000281500 00000 n
-0000281539 00000 n
-0000281578 00000 n
+0000184435 00000 n
+0000201046 00000 n
+0000213476 00000 n
+0000230528 00000 n
+0000244746 00000 n
+0000259761 00000 n
+0000267822 00000 n
+0000282864 00000 n
+0000285568 00000 n
+0000285815 00000 n
+0000285853 00000 n
+0000285891 00000 n
+0000285929 00000 n
+0000285967 00000 n
+0000286005 00000 n
+0000286043 00000 n
+0000286081 00000 n
+0000286119 00000 n
+0000286157 00000 n
+0000286196 00000 n
+0000286235 00000 n
+0000286274 00000 n
+0000286313 00000 n
+0000286352 00000 n
+0000286391 00000 n
+0000286430 00000 n
+0000286469 00000 n
+0000286508 00000 n
trailer
<< /ID
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
- [(\001\010J\2132\347\243Gc\3166\201E\377M\224) (\001\010J\2132\347\243Gc\3166\201E\377M\224)]
+ [(\241\3655\207R\273B\314\2276\253\347\311\271\004\)) (\241\3655\207R\273B\314\2276\253\347\311\271\004\))]
/Info 78 0 R /Root 77 0 R /Size 139 >>
startxref
-281617
+286547
%%EOF
diff --git a/documentation.rst b/documentation.rst
index 947c707..92a27d4 100644
--- a/documentation.rst
+++ b/documentation.rst
@@ -666,6 +666,19 @@ the names of the mandatory arguments) an attribute ``arg0``, ``arg1``,
..., ``argN`` is also generated. Finally, there is a ``signature``
attribute, a string with the signature of the original function.
+Notice: you should not pass signature strings with default arguments,
+i.e. something like 'f1(a, b=None)'. Just pass 'f1(a, b)' and then
+a tuple of defaults:
+
+.. code-block:: python
+
+ >>> f1 = FunctionMaker.create(
+ ... 'f1(a, b)', 'f(a, b)', dict(f=f), addsource=True, defaults=(None,))
+ >>> import inspect
+ >>> print(inspect.getargspec(f1))
+ ArgSpec(args=['a', 'b'], varargs=None, keywords=None, defaults=(None,))
+
+
Getting the source code
---------------------------------------------------
@@ -694,7 +707,6 @@ source code which is probably not what you want:
.. code-block:: python
- >>> import inspect
>>> print(inspect.getsource(example))
def wrapper(*args, **kw):
return func(*args, **kw)
diff --git a/src/tests/documentation.py b/src/tests/documentation.py
index 8282063..cdee30f 100644
--- a/src/tests/documentation.py
+++ b/src/tests/documentation.py
@@ -535,6 +535,19 @@ the names of the mandatory arguments) an attribute ``arg0``, ``arg1``,
..., ``argN`` is also generated. Finally, there is a ``signature``
attribute, a string with the signature of the original function.
+Notice: you should not pass signature strings with default arguments,
+i.e. something like 'f1(a, b=None)'. Just pass 'f1(a, b)' and then
+a tuple of defaults:
+
+.. code-block:: python
+
+ >>> f1 = FunctionMaker.create(
+ ... 'f1(a, b)', 'f(a, b)', dict(f=f), addsource=True, defaults=(None,))
+ >>> import inspect
+ >>> print(inspect.getargspec(f1))
+ ArgSpec(args=['a', 'b'], varargs=None, keywords=None, defaults=(None,))
+
+
Getting the source code
---------------------------------------------------
@@ -553,7 +566,6 @@ $$example
.. code-block:: python
- >>> import inspect
>>> print(inspect.getsource(example))
def wrapper(*args, **kw):
return func(*args, **kw)