performance fiddling

This commit is contained in:
Mark Pilgrim
2009-02-09 10:30:59 -05:00
parent 597f4dc0bb
commit acc7105cf6
6 changed files with 37 additions and 36 deletions
+2 -2
View File
@@ -4,8 +4,6 @@
<meta charset="utf-8">
<title>Case study: porting chardet to Python 3 - Dive into Python 3</title>
<link rel="stylesheet" type="text/css" href="dip3.css">
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="dip3.js"></script>
<link rel="shortcut icon" href="data:image/ico,">
<link rel="alternate" type="application/atom+xml" href="http://hg.diveintopython3.org/atom-log">
<style type="text/css">
@@ -720,5 +718,7 @@ for line in open(f, 'rb'):
TypeError: Can't convert 'bytes' object to str implicitly</samp></pre>
<p id="skipcantconvertbytesobject">...
<p class="c">&copy; 2001-4, 2009 <span>&#x2133;</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="dip3.js"></script>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
html{background:#fff;color:#000;}body{margin:28px;}body,.widgets a{font:normal medium 'Gill Sans','Gill Sans MT','Ikarius ADF',Candara,Jara,sans-serif;line-height:1.75;word-spacing:.1em;}a{background:transparent;text-decoration:none;border-bottom:1px dotted;}a:hover{border-bottom:1px solid;}a:link,.widgets a{color:#1b67c9;}a:visited{color:darkorchid;}.widgets a{text-decoration:underline;border:0;}.widgets,.widgets a,.download,.c{font-size:small;}blockquote .widgets{float:left;}blockquote .block{clear:left;}h1 a,h2 a,h3 a,#nav a{color:inherit!important;}abbr,acronym{letter-spacing:.1em;text-transform:lowercase;font-variant:small-caps;}h1,h2,h3,p,ul,ol{margin:1.75em 0;font-size:medium;}h1{background:papayawhip;width:100%;}h2,h3{clear:both;}form div{float:right;}pre{white-space:pre-wrap;padding-left:2.154em;line-height:1.75;border-left:1px dotted;}pre,kbd,code,samp{font-family:Consolas,Inconsolata,Monaco,monospace;font-size:medium;word-spacing:0;}pre a,.widgets a{padding:.4375em 0;border:0;}pre a:hover{border:0;}kbd{font-weight:bold;}.prompt{color:#667;}td pre{margin:0;padding:0;border:0;}li ol{margin:0;}.c{text-align:center;}p.fancy:first-letter{float:left;background:transparent;color:gainsboro;padding:.11em 4px 0 0;font:normal 4em/0.68 serif;}blockquote.q{margin:auto;text-align:right;font-style:oblique;}.skip a,.skip a:hover,.skip a:visited{position:absolute;left:0;top:-500px;width:1px;height:1px;overflow:hidden;}.skip a:active,.skip a:focus{position:static;width:auto;height:auto;}table{width:100%;border-collapse:collapse;}th{text-align:left;padding:0 .5em;vertical-align:baseline;border:1px dotted;}th,td{width:45%;vertical-align:top;}td{border:1px dotted;padding:0 .5em;}th:first-child{width:10%;text-align:center;}span,tr+tr th:first-child{font-family:'Arial Unicode MS',sans-serif;font-style:normal;}.q span{font-size:large;}.note{margin-left:4.94em;}.note span{display:block;float:left;font-size:xx-large;line-height:.875em;margin:0 .22em 0 -1.22em;}table.simple th{font-family:inherit!important;}.fr{width:100%;border:1px dotted;margin-top:3.5em;}.fr h4{margin-top:-1.2em;margin-left:-1em;width:8.5em;border:1px dotted;padding:3px 3px 3px 13px;background:#fff;color:inherit;position:relative;}.hover{background:#eee;color:inherit;cursor:default;}i.baa{font-family:Baskerville,Constantia,Palatino,'Palatino Linotype','URW Palladio L','URW Bookman L',serif;}body{counter-reset:h1;}h1:before{content:"Chapter " counter(h1) ". ";}h1{counter-reset:h2;}h2:before{counter-increment:h2;content:counter(h1) "." counter(h2) ". ";}h2{counter-reset:h3;}h3:before{counter-increment:h3;content:counter(h1) "." counter(h2) "." counter(h3) ". ";}
+2 -2
View File
@@ -134,9 +134,9 @@ body{counter-reset:h1 2}
<samp>5.5</samp>
<a><samp class="prompt">>>> </samp><kbd>11 // 2</kbd> <span>&#x2461;</span></a>
<samp>5</samp>
<a><samp class="prompt">>>> </samp><kbd>&minus;11 // 2</kbd> <span>&#x2463;</span></a>
<a><samp class="prompt">>>> </samp><kbd>&minus;11 // 2</kbd> <span>&#x2462;</span></a>
<samp>&minus;6</samp>
<a><samp class="prompt">>>> </samp><kbd>11.0 // 2</kbd> <span>&#x2462;</span></a>
<a><samp class="prompt">>>> </samp><kbd>11.0 // 2</kbd> <span>&#x2463;</span></a>
<samp>5.0</samp>
<a><samp class="prompt">>>> </samp><kbd>11 ** 2</kbd> <span>&#x2464;</span></a>
<samp>121</samp>
+2 -2
View File
@@ -4,8 +4,6 @@
<meta charset="utf-8">
<title>Porting code to Python 3 with 2to3 - Dive into Python 3</title>
<link rel="stylesheet" type="text/css" href="dip3.css">
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="dip3.js"></script>
<link rel="shortcut icon" href="data:image/ico,">
<link rel="alternate" type="application/atom+xml" href="http://hg.diveintopython3.org/atom-log">
<style type="text/css">
@@ -1274,5 +1272,7 @@ do_stuff(a_list)</code></pre></td></tr>
<p id="skipcompareidioms">
<p>FIXME: once the rest of the book is written, this appendix should contain copious links back to any chapter or section that touches on these features.
<p class="c">&copy; 2001-4, 2009 <span>&#x2133;</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="dip3.js"></script>
</body>
</html>
+28 -28
View File
@@ -235,34 +235,6 @@ ul li ol{margin:0;padding:0 0 0 2.5em}
<li>Optimizing string manipulation
<li>Summary
</ol>
<li><a href="case-study-porting-chardet-to-python-3.html">Case study: porting <code>chardet</code> to Python 3</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#divingin">Introducing <code class="filename">chardet</code>: a mini-FAQ</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.what">What is character encoding auto-detection?</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.impossible">Isn't that impossible?</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.who">Who wrote this detection algorithm?</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.yippie">Yippie! Screw the standards, I'll just auto-detect everything!</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.why">Why bother with auto-detection if it's slow, inaccurate, and non-standard?</a>
</ol>
<li><a href="case-study-porting-chardet-to-python-3.html#divingin2">Diving in</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#how.bom"><code>UTF-n</code> with a <abbr title="Byte Order Mark">BOM</abbr></a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.esc">Escaped encodings</a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.mb">Multi-byte encodings</a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.sb">Single-byte encodings</a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.windows1252"><code>windows-1252</code></a>
</ol>
<li><a href="case-study-porting-chardet-to-python-3.html#running2to3">Running <code class="filename">2to3</code></a>
<li><a href="case-study-porting-chardet-to-python-3.html#manual">Fixing what <code class="filename">2to3</code> can't</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#falseisinvalidsyntax"><code>False</code> is invalid syntax</a>
<li><a href="case-study-porting-chardet-to-python-3.html#nomodulenamedconstants">No module named <code class="filename">constants</code></a>
<li><a href="case-study-porting-chardet-to-python-3.html#namefileisnotdefined">Name '<var>file</var>' is not defined</a>
<li><a href="case-study-porting-chardet-to-python-3.html#cantuseastringpattern">Can't use a string pattern on a bytes-like object</a>
<li><a href="case-study-porting-chardet-to-python-3.html#cantconvertbytesobject">Can't convert '<code>bytes</code>' object to <code>str</code> implicitly</a>
</ol>
</ol>
<li>Packaging Python libraries
<!-- http://pypi.python.org/pypi -->
<ol>
@@ -293,6 +265,34 @@ ul li ol{margin:0;padding:0 0 0 2.5em}
<li>PyPy
<li>Stackless Python
</ol>
<li><a href="case-study-porting-chardet-to-python-3.html">Case study: porting <code>chardet</code> to Python 3</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#divingin">Introducing <code class="filename">chardet</code>: a mini-FAQ</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.what">What is character encoding auto-detection?</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.impossible">Isn't that impossible?</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.who">Who wrote this detection algorithm?</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.yippie">Yippie! Screw the standards, I'll just auto-detect everything!</a>
<li><a href="case-study-porting-chardet-to-python-3.html#faq.why">Why bother with auto-detection if it's slow, inaccurate, and non-standard?</a>
</ol>
<li><a href="case-study-porting-chardet-to-python-3.html#divingin2">Diving in</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#how.bom"><code>UTF-n</code> with a <abbr title="Byte Order Mark">BOM</abbr></a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.esc">Escaped encodings</a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.mb">Multi-byte encodings</a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.sb">Single-byte encodings</a>
<li><a href="case-study-porting-chardet-to-python-3.html#how.windows1252"><code>windows-1252</code></a>
</ol>
<li><a href="case-study-porting-chardet-to-python-3.html#running2to3">Running <code class="filename">2to3</code></a>
<li><a href="case-study-porting-chardet-to-python-3.html#manual">Fixing what <code class="filename">2to3</code> can't</a>
<ol>
<li><a href="case-study-porting-chardet-to-python-3.html#falseisinvalidsyntax"><code>False</code> is invalid syntax</a>
<li><a href="case-study-porting-chardet-to-python-3.html#nomodulenamedconstants">No module named <code class="filename">constants</code></a>
<li><a href="case-study-porting-chardet-to-python-3.html#namefileisnotdefined">Name '<var>file</var>' is not defined</a>
<li><a href="case-study-porting-chardet-to-python-3.html#cantuseastringpattern">Can't use a string pattern on a bytes-like object</a>
<li><a href="case-study-porting-chardet-to-python-3.html#cantconvertbytesobject">Can't convert '<code>bytes</code>' object to <code>str</code> implicitly</a>
</ol>
</ol>
</ol>
<ul>
<li><a href="porting-code-to-python-3-with-2to3.html">Appendix A. Porting code to Python 3 with <code class="filename">2to3</code></a>
+2 -2
View File
@@ -4,8 +4,6 @@
<meta charset="utf-8">
<title>Your first Python program - Dive into Python 3</title>
<link rel="stylesheet" type="text/css" href="dip3.css">
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="dip3.js"></script>
<link rel="shortcut icon" href="data:image/ico,">
<link rel="alternate" type="application/atom+xml" href="http://hg.diveintopython3.org/atom-log">
<style type="text/css">
@@ -240,5 +238,7 @@ if __name__ == "__main__":
</ul>
</div>
<p class="c">&copy; 2001-4, 2009 <span>&#x2133;</span>ark Pilgrim, <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="dip3.js"></script>
</body>
</html>