| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
%deffont "standard" xfont "helvetica-medium-r" |
| 3 |
%deffont "thick" xfont "helvetica-bold-r" |
| 4 |
%deffont "typewriter" xfont "courier-medium-r" |
| 5 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6 |
%% |
| 7 |
%% Default settings per each line numbers. |
| 8 |
%% |
| 9 |
%default 1 area 90 90, leftfill, size 2, fore "gray20", back "white", font "standard", hgap 0 |
| 10 |
%default 2 size 7, vgap 10, prefix " ", ccolor "blue" |
| 11 |
%default 3 size 2, bar "gray70", vgap 10 |
| 12 |
%default 4 size 5, fore "gray20", vgap 30, prefix " ", font "standard" |
| 13 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 14 |
%% |
| 15 |
%% Default settings that are applied to TAB-indented lines. |
| 16 |
%% |
| 17 |
%tab 1 size 5, vgap 40, prefix " ", icon box "red" 50 |
| 18 |
%tab 2 size 4, vgap 40, prefix " ", icon arc "yellow" 50 |
| 19 |
%tab 3 size 3, vgap 40, prefix " ", icon delta3 "white" 40 |
| 20 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 21 |
%page |
| 22 |
|
| 23 |
lxml - a sane Python wrapper for libxml |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
%center |
| 28 |
Martijn Faassen, Infrae |
| 29 |
[email protected] |
| 30 |
|
| 31 |
%page |
| 32 |
|
| 33 |
The C library libxml has huge benefits |
| 34 |
|
| 35 |
|
| 36 |
Standards-compliant XML support |
| 37 |
|
| 38 |
full-featured |
| 39 |
|
| 40 |
actively maintained by XML exports |
| 41 |
|
| 42 |
fast. fast! FAST! |
| 43 |
|
| 44 |
%page |
| 45 |
|
| 46 |
Features of libxml |
| 47 |
|
| 48 |
|
| 49 |
Parsing |
| 50 |
|
| 51 |
Tree based (DOM-ish) XML structure |
| 52 |
|
| 53 |
XPath support |
| 54 |
|
| 55 |
XSLT support (libxslt) |
| 56 |
|
| 57 |
Relax NG (schema) support |
| 58 |
|
| 59 |
And more |
| 60 |
|
| 61 |
%page |
| 62 |
|
| 63 |
But libxml already has Python bindings! |
| 64 |
|
| 65 |
|
| 66 |
very low level and C-ish (not Pythonic) |
| 67 |
|
| 68 |
underdocumented. huge, you get lost in them |
| 69 |
|
| 70 |
works with UTF-8, not native Python unicode |
| 71 |
|
| 72 |
can cause segfaults from Python |
| 73 |
|
| 74 |
have to do manual memory management! |
| 75 |
|
| 76 |
%page |
| 77 |
|
| 78 |
lxml is a new Python binding for libxml |
| 79 |
|
| 80 |
Aims (read: TODOS) |
| 81 |
|
| 82 |
Pythonic API |
| 83 |
|
| 84 |
Documented |
| 85 |
|
| 86 |
Use Python unicode strings in API |
| 87 |
|
| 88 |
Safe (no segfaults) |
| 89 |
|
| 90 |
No manual memory management! |
| 91 |
|
| 92 |
%page |
| 93 |
|
| 94 |
Tradeoffs |
| 95 |
|
| 96 |
|
| 97 |
Slower because of better wrapping. |
| 98 |
|
| 99 |
But libxml is so fast this likely doesn't matter much. |
| 100 |
|
| 101 |
Not all features of libxml exposed (unless you help) |
| 102 |
|
| 103 |
%page |
| 104 |
|
| 105 |
What is there now - Proof of concept |
| 106 |
|
| 107 |
|
| 108 |
Automatic destruction of documents (refcounted) |
| 109 |
|
| 110 |
Start of ElementTree style API for tree |
| 111 |
|
| 112 |
%page |
| 113 |
|
| 114 |
Future |
| 115 |
|
| 116 |
|
| 117 |
Fix bugs, add features |
| 118 |
|
| 119 |
Moving into svn repository on codespeak.net |
| 120 |
|
| 121 |
Help! |
| 122 |
|