tag:blogger.com,1999:blog-197306832024-03-07T00:57:20.482-05:00Jeremy Hylton: InconceivableJeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.comBlogger82125tag:blogger.com,1999:blog-19730683.post-65018888593924614412010-04-21T22:40:00.001-04:002010-04-21T22:40:59.185-04:00Easton School District BudgetThe Easton school district is in a financial mess. The school board is considering terrible options like a tax increase of more than 10 percent or layoffs totaling more than 10 percent of the teaching staff. This post collects a few sources of information about the budget. (Let me know if you have more links.)<br />
The Morning Call wrote a good summary of the last school board meeting: <a href="http://www.mcall.com/all-a1_3easd.7241633apr16,0,1127518.story">Ax falls on Easton schools.</a><br />
<br />
The <a href="http://www.eastonsd.org/business/Public.html">school district public finance page</a> includes the <a href="http://www.eastonsd.org/bizforms/DOCproposed2010-2011budget.PDF">proposed budget for 2010-2011</a> and the budgets from the last two years. The <a href="http://www.eastonsd.org/bizforms/DOCafryrend63009.pdf">auditor's report from 2009</a> is also posted there. (All documents there are pdfs.) I'm not sure how useful the auditor's report is. There is this gem from the financial highlights on page 4:<br />
<blockquote>The District's overall financial position as of June 30, 2009 continued to be very strong.</blockquote>As of June 30, 2010, not so much.<br />
<br />
The <a href="http://php.app.com/PAteachers09/search.php">salaries of all Pennsylvania public school employees in 2009</a> are available. I took a quick look at the numbers. It seems like Easton and Nazareth have similar salaries. Parkland clearly pays better.<br />
<br />
<a href="http://www.schoolmatters.com/schools.aspx/q/page=sr/txt=easton/ust=PA/fp=1/p=1/adts=PA?ctxt=894&adt=Easton%20Area%20School%20District">School Matters (Easton)</a> has some basic data about the schools, like enrollment and students per teacher. Overall, the numbers seem to add up to 9,160 students. Students per teacher ranges from 12.6 at March Elementary to 20.6 at Tracy Elementary. Unfortunately, the data here is from 2006. It's <a href="http://www.schoolmatters.com/schools.aspx/q/page=sl/sid=14983/midx=DistrictFinancialInfo">district financial summary</a> says the district instructional expenses are a bit under the state average, but capital expenditures are more than five times the state average. (Where can we find more recent numbers?)Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com2tag:blogger.com,1999:blog-19730683.post-84036228260698983242009-03-31T22:04:00.000-04:002009-03-31T22:04:38.890-04:00Python strings and bytesAt the <a href="http://us.pycon.org/2009/sprints/projects/python-core/">PyCon sprints</a>, we looked into a lot of bugs in the standard library caused by interactions between strings and bytes. (A string holds a sequence of characters. A bytes object holds a sequence of bytes, e.g. 0-255.) I help maintain <a href="http://docs.python.org/3.0/library/http.client.html">httplib</a> and <a href="http://docs.python.org/3.0/library/urllib.request.html">urllib</a>, which read raw bytes from a socket and often convert them into strings. The details of those conversions are sometimes tricky. The<a href="http://docs.python.org/3.0/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit"> rules for strings and bytes changed drastically in Python 3.0</a>. Most of the standard library was converted from old to new automatically (by <a href="http://docs.python.org/library/2to3.html">2to3</a>), and many of the times those conversions were incorrect.<br />
<br />
A harmless example comes from httplib where an if / elif statement had tests from strings and for unicode strings. They were both converted to test for strings by the conversion tool. The code looked like this:<br />
<span style="font-family: "Courier New",Courier,monospace;"><br />
if isinstance(buf, str): # regular strings<br />
</span><br />
<div style="font-family: "Courier New",Courier,monospace;"> # do something</div><div style="font-family: "Courier New",Courier,monospace;"> elif isinstance(buf, str): # unicode strings</div><div style="font-family: "Courier New",Courier,monospace;"> # do something else</div><br />
In this case, the second branch could be deleted. In other cases, the effects were harmful. If you passed a bytes object as the body argument in an HTTP request--passing form params for a POST reply is a common case--the bytes object would be converted via str() to a string.<br />
<br />
>>> body = b"key=value"<br />
>>> str(body)<br />
"b'key=value'"<br />
<br />
That is, str() uses repr() to convert bytes to a string. That's simplfy incorrect.<br />
<br />
It will take a long time to sort out all of these problems. We don't have a lot of experience from application developers who are using Python 3.0, so we have to invent solutions as we go along. We're likely to make mistakes or at least make sub-optimal API decisions.<br />
<br />
I can of think of two things that would help us make progress. <br />
<br />
First, we ought to organize a systematic effort to review the standard library. How many of the libraries have plausible tests that exercise strings and bytes? For example, the json library was carefully tested with strings and unicode in Python 2.x. Those have all been converted to strings, so now we have a thorough set of tests for strings and none at all for bytes.<br />
<br />
Second, we need to collect a set of best practices for writing libraries that support bytes and unicode. A typical pattern is that bytes get sent on the wire. (Wires, almost by definition, send bytes.) The applications that use the wire usually want to deal with strings, which means they need to have some way to specify an encoding to use when send to or read from the wire. We could start by collecting all the patches and bug fixes that have gone into Python 3.1 to fix string and bytes problems with 3.0.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com1tag:blogger.com,1999:blog-19730683.post-22729238674629052532009-03-30T12:45:00.000-04:002009-03-30T12:45:08.697-04:00Coroutines in Python<a href="http://www.dabeaz.com/">David Beazley</a> gave a<a href="http://www.dabeaz.com/coroutines/index.html"> tutorial at coroutines at PyCon 2009</a>. The <a href="http://www.dabeaz.com/coroutines/Coroutines.pdf">slides</a> and <a href="http://www.dabeaz.com/coroutines/coroutines.zip">code</a> are available for download. I took them home with me on the plane. I had a fun time reading the slides and studying the code. It's a remarkably clear explanation of how generators can be used as coroutines, starting with Python 2.5. He runs through a good collection of examples, winding up with a simple OS-style task scheduler for cooperative multi-tasking coroutines.<br />
<br />
One of his concluding points was really helpful for me. I found it hard to pay a lot of attention to the evolution of <a href="http://www.python.org/dev/peps/pep-0342/">PEP 342</a>, which added coroutine support for generators. I found it confusing that yield / generators were being extended to handle different use cases. David clarifies it in a helpful way: <br />
<blockquote>There are three main uses of yield <br />
<ul><li>Iteration (a producer of data) </li>
<li>Receiving messages (a consumer) </li>
<li>A trap (cooperative multitasking) </li>
</ul>Do NOT write generator functions that try to do more than one of these at once </blockquote>Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-10182824639537213402009-03-03T08:42:00.000-05:002009-03-03T08:42:55.117-05:00Pressing the PoliceDavid Simon, of Homicide, The Wire, and long ago the Baltimore Sun, wrote about the increasing secrecy of the Baltimore police in Sunday's Washington Post: <a href="http://www.washingtonpost.com/wp-dyn/content/article/2009/02/27/AR2009022703591_pf.html%20%20%20">In Baltimore, No One Left to Press the Police.</a> He was making a large point about the role of newspapers.<br />
<blockquote>"In an American city, a police officer with the authority to take human life can now do so in the shadows, while his higher-ups can claim that this is necessary not to avoid public accountability, but to mitigate against a nonexistent wave of threats. And the last remaining daily newspaper in town no longer has the manpower, the expertise or the institutional memory to challenge any of it."</blockquote>Simon argues that there aren't any bloggers fighting to keep the city government honest. The laws provide access to many police records, but an individual is left with little practical recourse if the police don't obey them. (They hassle <a href="http://thomashawk.com/2008/12/port-of-long-beach-responds-to-incident.html">photographers taking pictures on bridges</a>, too.) I'm sympathetic to Simon's argument, but the primary problem is public accountability not the lack of a newspaper to provide it.<br />
<br />
It reminded me of my own experience getting access to campus police records in college. (Neither the crimes, nor the institutions were as threatening as they are in Baltimore.) The M.I.T. campus police refused to show reporters its police log, a simple record of incidents and arrests. It took us a year or more of effort to get access to them.<br />
<br />
What was involved in getting access to those records? The <a href="http://www.splc.org/">Student Press Law Center</a> provided resources for student journalists. I knew the basic outlines of the law, that other papers had similar problems, and that many of them prevailed in the end. The issues were clear cut at public universities, but Massachusetts law seemed fairly clear for police at private colleges. We asked to see the records several times--just walked into the police station and asked to see it. We also did this a few times with the local Cambridge police, who never gave us a hard time.<br />
<br />
I also had the help of a lawyer, a former editor-in-chief of <a href="http://tech.mit.edu/">The Tech</a>, who helped us negotiate with the Institute. I recall a letter he wrote to Thomas Henneberry, M.I.T.'s lawyer, requesting access to the police log: "We believe that this is an appropriate matter for injunctive relief and hope seeking such relief does not become necessary." I delivered the letter in person to various administrators--the president, the chairman of the corporation, etc.<br />
<br />
I certainly had instiutional support from my fellow students at the newspaper. I think it's easier to feel confident in pressing the case when you have an organization behind you, but it's hard to quantify the effect.<br />
<br />
Henneberry wrote a letter back to us, explaining that everything we argued was nonsense. I don't recall exactly how we responded, but several months later the police log was opened. We did not get any official response, but the log was available to reporters. The <a href="http://tech.mit.edu/V129/N2/polog.html">police log</a> is still published reguarly.<br />
<br />
What's the lesson for bloggers in this? You probably need an umbrella organization to help coordinate a campaign for open records and a lawyer willing to help you in specific cases. You need to make a sustained effort to get access to records. The first few times you show up, you'll simply be turned away. It's not inconceivable that bloggers could achieve as much as the local paper in this regard.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com2tag:blogger.com,1999:blog-19730683.post-51696442806775681882008-12-03T14:54:00.004-05:002008-12-03T21:41:40.532-05:00Python 3000<a href="http://www.python.org/download/releases/3.0/">Python 3000</a> is ready! The official release may not come until tomorrow, but <a href="http://mail.python.org/pipermail/python-committers/2008-December/000277.html">Barry has tagged the source</a> and is preparing the release. We've been waiting for this release for almost nine years. The <a href="http://mail.python.org/pipermail/python-dev/2000-January/001812.html">earliest reference</a> I can find is a message from Guido to python-dev in Jan. 2000.<br /><br />In the previous century, we had been thinking about Python 2 as the Python version that would break backwards compatibility to make real language improvements. Python 2 ended up being a big deal, but without too many compatibility issues. All the major changes were deferred to "Python 3000," a mythical creature. I'm eager to see what programmers make of this creature.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com7tag:blogger.com,1999:blog-19730683.post-23406747289017806722008-11-23T12:49:00.003-05:002008-11-23T13:06:15.302-05:00John DingellI remember John Dingell from my days writing for <a href="http://tech.mit.edu">The Tech</a>, the campus newspaper at M.I.T. He had a reputation as a bully, who liked to hold hearings and conduct investigations on fraud and waste in science to grandstand. The two I remember best ended up being busts as far as actually uncovering waste or fraud--audits of funding by research universities and a fraud case involving a researcher in David Baltimore's lab where the all charges were eventually dismissed.<br /><br /><a href="http://tech.mit.edu/V112/N3/edit.03o.txt.html">The Tech, Feb. 7, 1992</a><br /><blockquote>The government -- particularly Rep. John D. Dingell (D-Mich.), chairman of the Oversight andInvestigations Subcommittee -- tried to publicly embarrass MIT and other universities for alleged misuses of funds, even before formal evidence was presented before the committee.</blockquote><br /><a href="http://tech.mit.edu/V117/N27/baltimore.27n.html">The Tech, June 6, 1997</a><br /><blockquote>What had originally been a matter of Imanishi-Kari's questionable research data quickly swelled into a thorny and divisive debate over the validity of scientific research.<br /><br />Baltimore derided the controversy as a witch hunt and believed that some people, like U.S. Representative John Dingell (D-Mich.), were using it unreasonably to call into question government money spent on funding research.</blockquote>Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-20567005214524315782008-11-23T10:07:00.001-05:002008-11-23T10:07:49.595-05:00<a href="http://www.oneplusyou.com/bb/view2/countries" style="display: block; background: #333 url('http://www.oneplusyou.com/bb/img/countries/badge.jpg') no-repeat; width: 320px; height: 90px; font-family: Arial, sans-serif; font-size: 35px; color: #fff; text-decoration: none; text-align: center; padding-top: 110px; ">75</a><div>Created by OnePlusYou - <a rel="nofollow" href="http://www.oneplusyou.com">Free Dating Site</a></div>Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-26310452936178080852008-11-05T10:09:00.016-05:002008-12-11T12:20:28.852-05:00Election Day RecapI spent a long, busy day running the polling station for Forks Western District #1 at the Forks Community Center. It was my first presidential election as a poll worker and an interesting day. I learned a lot and continue to be dismayed about how fragile the voting process is. It's easy for individual votes to be irrevocably lost despite the best efforts of the election board. The lines and registration process make it hard for people who want to vote to actually vote, regardless of whether there votes are recorded.<br />
<br />
Depsite all the problems, I think we had a good day. Voter turnout was about 65%, more than 1,200 people voted either in person or by absentee ballot. We had long lines, ranging from 45 minutes first thing in the morning to an hour and fifteen minutes at midday. We had no serious problems, the vast majority of people were patient and friendly.<br />
<br />
My location was two different polling stations in the same building. This causes lots of confusion for voters, since there are two different lines and they need to be in the right line to vote. The line for our precinct was much shorter than the other line. (Some people waited almost two hours in the other line.) The two election boards worked out a deal where someone who waited in the wrong line would be taken to the front of the other line. This minimized the actual harm and kept people happy, but meant I spent a lot of the day walking back and forth between the two lines.<br />
<br />
We had two poll watchers / observes who were form the Obama campaign. They never identified themselves as Obama supporters, but I knew one of them from the neighborhood. The other came from New York. They were incredibly helpful and were essential to keeping the lines moving smoothly. They spent the day answering questions and helping people find the right line. The staff at the community center also helped out a lot.<br />
<br />
My biggest concern was the lost votes. The tally of voters who signed in didn't match the tally of votes recorded on the electronic voting machines. Our precinct lost 26 votes out of 1186 cast, a 2.2% loss rate. The other polling station lost 19 out of 1746 votes, a 1.1% loss rate. I didn't think to check the counters on the machine until late in the day, so I don't know what went wrong early. After we started paying extra attention, we cut the error rate to less than one percent. It was probably a combination of human factors and usability issues that caused the problems, but I can't rule out some early glitch with the machine itself. I've got more data about lost votes at the end of the post.<br />
<br />
A <a href="http://citp.princeton.edu/voting/advantage/">Princeton report</a> concluded that the voting machines we use were too insecure to be used in New Jersey. My experience is consistent with their complaint that: "Design flaws in the user interface of the AVC Advantage disenfranchise voters."<br />
<br />
We had seven provisional ballots cast. In two or three of those cases, I think the people simply weren't registered correctly and the ballot with not be counted. A few others will probably work out fine. I wish there were a way for me to check.<br />
<br />
<a href="http://www.forkstownship.org/">Forks Township</a> might need to make big changes.<br />
<ul><li>The boundaries among the four precincts are very hard to understand. We seem to have cases where neighbors vote in different precincts without being on obvious bounaries.</li>
<li>The precincts are vastly different in size. West #2 has at least 50% more people than West #1.</li>
<li>The precincts are too big. Several smaller precincts would mean shorter lines for voting.</li>
<li>We have to produce a single numbered list of voters, which seems like a central bottleneck, and we have two books that contain the entries for voters to sign. These physical lists need to be sharded more aggressively if we the precincts stay the way they are.</li>
<li>I'm not sure whether it's a good idea to have two precincts vote in one location, because people get confused about which precinct to vote in. I'd estimate we had 100 people wait in our line when they were registered in the other precinct.</li>
</ul>My choice would be to have twice as many polling stations. There are about 10,000 people registered in Forks Township. It seems reasonable to have five to ten polling stations for them instead of just four<br />
<br />
Here is the raw data on missing votes. I didn't think to check the machine counts until late in the day, by then 23 votes were missing. One possibility is that the machine suffered some software error early in the day that caused it to drop or not record some votes. I think that's unlikely, but I can't rule it out. I'm surprised that the operators missed so many failures. Once we started checking the counters regularly, the error rate dropped substantially (3% to less than 1%). That probably means that increased vigilance caught problems while they could still be corrected. We were also much less busy late in the day.<br />
<br />
I recorded the total number of voters signed in and the counters on the two voting machines several times starting around 4pm. The number of missing votes goes up and down slightly, because I didn't keep careful track of people in the voting booth or waiting to get in a booth when I checked the counters. If a person was in the voting booth, they'd counted as missing according to my procedure.<br />
<br />
<span style="font-family: courier new;">4:15pm, 860 voters, 428 + 409 = 837, 23 missing</span><br />
<span style="font-family: courier new;">4:40pm, 903 voters, 448 + 431 = 879, 24 missing</span><br />
<span style="font-family: courier new;">5:08pm, 943 voters, 448 + 470 = 918, 25 missing</span><br />
<span style="font-family: courier new;">5:45pm, 1,012 voters, 481 + 505 = 986, 26 missing</span><br />
<span style="font-family: courier new;">6:05pm, 1,037 voters, 494 + 515 = 1,009, 26 missing</span><br />
<span style="font-family: courier new;">6:45pm, 1,097 voters, 523 + 546 = 1,069, 28 missing</span><br />
<span style="font-family: courier new;">7:22pm, 1,146 voters, 548 + 570 = 1,118, 28 missing</span><br />
<span style="font-family: courier new;">7:32pm, 1,157 voters, 553 + 575 = 1,128, 29 missing</span><br />
<span style="font-family: courier new;">8:30pm, 1,186 voters, 569 + 591 = 1,160, 26 missing</span><br />
<br />
In the final four hours of voting, we lost three more votes, an error rate of less than 1%.<br />
<br />
There are several possible sources of error. The least likely case is a voter who signed the book, but never actually entered the voting booth. I think this case is the least likely. Why would someone wait in line for almost an hour and then leave without trying to vote?<br />
<br />
It's possible that the voting machine did not properly record a vote. We use <a href="http://www.sequoiavote.com/advantage.html">Sequoia AVC Advantage voting machines</a>. They update a counter after each recorded vote. The counter is displayed on the operator panel. The machine operator could check that the counter goes up after each vote. Perhaps the machine logs more information that might catch cases where the counter fails to behave correctly.<br />
<br />
The most likely cause of problems is a combination of usability issues and operator errors. A user unfamiliar with the machine might leave the voting booth without pressing the right combination of buttons needed to record a vote. If the operator doesn't notice, then the intended vote is lost. We had one operator for two machines used by almost 1,200 people. It would be easy to miss a few cases where people left thinking they had voted but without actually recording a vote. Here's the process in a nusthell, along with a bunch of failure modes.<br />
<ol><li>The operator activates the machine for a specific voter. The machine makes a chirping noise.<br />
</li>
<li>The voter touchs the square to the right of the candidate's name. A lighted arrow appears next to the square.</li>
<li>After at least one candidate is selected, a red vote button in the lower right of the voting booth is enabled. It lights up when it is enabled.<br />
</li>
<li>The voter presses the red vote button to record his or her vote. The machines makes another chirping noise.<br />
</li>
<li>The voting machine returns to inactive mode.</li>
</ol>There are many failure cases:<br />
<ul><li>If the voting machine isn't activated, the touch screen still responds by turning on the lighted arrow for a second or two. The red vote button is never activated. A voter could believe that they are voting because the touch screen provides some feedback. Since the vote button never lights up, they'd never see it. In this failure mode, the voter presses a bunch of names and thinks a vote has been cast. The machine stays in the inactive state through the whole process. Since the machine ends up back in the inactive state after a successful vote, the operator can't distinguish between a succesful vote and this failure mode after the voter leaves the booth. The chirping noises should help catch this failure, but voters probably don't know to listen for it. In a busy polling station with several machines, it's easy to get confused about whether you heard something or didn't.<br />
</li>
<li>A voter can entered an activated machine and fail to touch the right parts of the screen. If you touch the candidate's name instead of the box to the right of the name, nothing happens. Again, the red vote button doesn't light up. So a voter could touch each of the candidates names and then walk out. They don't know they're supposed to see lighted green arrows to the right of the name, so they don't realize they've done something wrong. The operator could catch this case, because the machine stays in active mode after the voter leaves. But if the operator is busy and doesn't check the machine after a voter leaves, the next voter could enter the booth and vote before anyone notices.</li>
<li>The voter could press some of the squares and get some of the lights to turn on, but not press the red vote button. If they walk away before anyone notices, their vote can't be cast. We noticed this happening a couple of times. If another voter entered before we noticed, they might be surprised that some of the lights are on. Then again, the new voter might overlook it entirely. The lighted arrow is a small indicator, so they might not notice it. Or they might think it normal for some arrows to be lighted before a vote is cast.</li>
</ul>I think the key usability problem with the Sequoia machine is that it's not clear enough what has to be done to record a vote. The old, mechanical lever machines had a strong feedback system. You had to pull the lever to close the curtain, and pull it again to open it. It was actually hard to get out of the voting booth without pulling the lever. You'd get tangled in the curtain. There's no multi-level system like that here. It's physically easy to leave without recording your vote. The cues are some small lights and a high pitched chirp. These are cues easy for an elderly voter to miss entirely.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com2Forks, Pennsylvania, USA40.717517632263778 -75.22615671157836940.715484632263781 -75.229804711578367 40.719550632263775 -75.222508711578371tag:blogger.com,1999:blog-19730683.post-6902143823155265922008-10-27T15:05:00.007-04:002008-12-05T10:10:41.065-05:00Pennsylvania Ballot InitiativesMy friends in California have so many ballot initiatives to chose from. On any conceivable issue, you can probably find a ballot measure to oppose. There are two on the ballot for Northampton County Pa. Short summary of this post: Vote yes on both questions.<br /><div><br /></div><div>The first is a $400 million bond issue to support clean water initiatives in the state. See the details at <a href="http://ballotpedia.org/wiki/index.php/Pennsylvania_Sewer_Bond_Question_%282008%29">Ballotopedia</a>. The Commonwealth Foundation has some helpful details about other <a href="http://www.commonwealthfoundation.org/policy-points/water-and-sewer-ballot-question">borrowing by Pennsylvania</a>, a total of $3 billion in July 2008 that brings the state government's outstanding debt to $8.5 billion. That's roughly comparable to <a href="http://www.obm.ohio.gov/debt/dmburden.asp">Ohio's state debt</a>, $8.6 billion. (Individual state authorities and local governments have the vast majority of state of local obligations, though.) It doesn't sound like a huge debt problem.<br /><br /></div><div>I found two endorsements of the proposal.<br /></div><div><ul><li><a href="http://www.philly.com/inquirer/opinion/20081025_Editorial___quot_Yes_quot__on_Pa__Ballot_Question.html">Philadelphia Inquirer: "Yes" on Pa. Ballot Question</a><br /></li><li><a href="http://www.pecpa.org/node/522">PEC Supports Pennsylvania Clean Water Ballot Initiative</a></li></ul>I'll be voting in favor of this measure. Investment in infrastructure for water and sewage is good spending for the state. It will have good long term benefits for communities. In the short-term, it will mean increased public spending and more jobs at a time when the economy needs that kind of stimulus.<br /><br /><div>The second ballot measure is to hire a full-time, paid country controller. I have my absentee ballot, so I know the question is on the ballot. I can't find any one who discusses it. I can't find anything from the Morning Call or the League for Women Voters. In principle, it makes sense to me to have full-time, paid officials for some key county offices. <a href="http://www.lwvlv.org/govdir_lehigh.htm">Lehigh County's controller </a>is paid significantly more than <a href="http://blog.pennlive.com/northamptoncounty/2008/01/council_mulls_salary_hikes_for.html">Northampton County's controller</a>, so I will assume that Lehigh County has a full-time controller ($62,500 vs. $39,000).<br /><br />I'll be voting for this measure, too. It makes sense to pay for competent, qualified professionals to run the local goverment.<br /><br /></div></div>Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-21020558087927120592008-10-27T10:05:00.005-04:002008-11-03T23:49:25.285-05:00Poll Worker TrainingI went for my semi-annual poll worker training session on Sunday. The normal focus of the training session is on operating the voting machines: How to prepare them in the morning, operate them, and record the votes on the flash memory to be delivered for the county count. This year there was an added emphasis on the complications of a presidential election. The most obvious difference with the typical election is that more people come. There will be lines most of the day, primarily because of the time it takes to sign people in.<br /><br />We were encouraged to be patient. It will be a long day. With long lines, we were asked to keep an eye out for people campaigning inside the polling place or doing anything else inappropriate. The first line of defense here is the election board, but we were encouraged to call the Register with any questions.<br /><br />Common Cause has a good summary of <a href="http://www.commoncause.org/site/pp.asp?c=dkLNK1MQIwG&b=4649873">Pennsylvania election procedures</a>. We were told that the county would provide lots of provisional ballots for polling places and encouraged us to use them. I was happy to hear that Pennsylvania will count a provisional ballot cast at any polling place in the county. If you show up at the wrong polling place 10 minutes before the end of voting, you can cast a provisional ballot and it will still count. My only reservation is that it's more work to cast a provisional ballot. There's more paperwork for the voter and the poll worker. If we have a lot of votes cast this way, it will slow us down.<br /><br />Provisional ballots sound like a mixed bag. The county collects the provisional ballots, decides whether each one is valid, and counts the valid ones. It will probably take two or three days to count them. The obvious advantage is that anyone not allowed to vote using the regular voting machines can still cast a ballot. If there's a problem and you don't cast a ballot, you can't fix that later. I've read a lot of <a href="http://uncountedthemovie.com/blog/2008/10/21/steal-back-your-vote/">warnings about provisional ballots</a>. At some level, the warnings make sense. If you can vote on the official machine, that's better. Your vote will definitely be counted--at least to the extent you can trust the machines--but I don't have any idea how they decide which provisional ballots to count and which to toss. I do have some trust in the process:<br />Howard Erney is the acting chief registrar for this election. I don't know him well, but he runs voter training and often visits polling stations on election day. He seems fair, honest, and conscientious.<br /><br />I asked about poll watchers and about challenges to voters. The answers here were pretty thin. We had two poll watchers during the primary. One woman was tracking Republication voters--making sure people who said they would vote really came to vote. The other poll watcher came and went. They both stayed while we counted the votes at the end of the day. I did find a <a href="http://www.dos.state.pa.us/elections/lib/elections/090_election_administration_tools/watcher_candidate_rights.pdf">summary of the Pennsylvania code on poll</a> watchers that explains things in a fair amount of detail. They can challenge someone's right to vote, but that doesn't automatically disqualify someone from voting. It just makes more paperwork for all involved.<br /><br />The Pa. League of Women Voters has some more useful information for poll workers. There's a <a href="http://palwv.org/lwv/pubs/CitizenPollWatcher.pdf">checklist for poll watchers</a> that will work just as well as a checklist for poll workers. I found a really <a href="http://palwv.org/voting/Pennsylvania-Nutshell-2008v2%20to%20Local%20Leagues%2003-06-08.pdf">detailed FAQ for Pennsylvania voters</a> on their site, but I don't know if it's current.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-19014799509737853932008-10-04T21:46:00.003-04:002008-10-04T21:55:09.641-04:00Thai Pumpkin PizzaI had a pumpkin and some Thai basil from my neighbor Tina. I found a recipe for Thai pumpkin soup and that formed the basis for a Thai pumpkin pizza that I made tonight. It turned out well. We'll definitely make it again, so I'm recording the recipe here. I made enough for a small 8" round pizza. All the proportions are approximate.<br /><ul><li>Cut pumpkin into small cubes, less than an inch on a side. 1-2 cups total.<br /></li><li>Puree an inch of ginger, two pieces of lemongrass, and some Thai basil in a blender with a 1 cup of water.</li><li>Strain the ginger / lemongrass paste and save the liquid.</li><li>Dice 3 shallots and saute in oil for about five minutes over medium heat.</li><li>Add the paste and pumpkin to the shallots and saute for a few more minutes.</li><li>Add the reserve liquid, a half cup of vegetable broth, and some nam pla to the pumpkin. Lower the heat and saute until the pumpkin is soft, perhaps adding a little more liquid. Cook off all the liquid until there is just a thick paste remaining.</li><li>Spread the pumpkin / shallot paste on the pizza crust. Add some vegetables. We had slivered snow peas. Carrots would be good, too.</li><li>Add a thin layer of cheese. We used three parts fontina and one part mozzarella.<br /></li></ul>Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-1812525981795093032008-09-19T10:26:00.004-04:002008-09-19T21:13:18.980-04:00Photo Meme<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKosCDxEGisVgz_PerNatWCw1QpVL7FWFFmWXoWphz4enQ-AzorXUGMM_-styYeZf9AbefZ5BZFwzmf9r6F9nWkYtMtxdaY2DZm6omx4AmX8vDtJyM9E2cpj-cNlU-tLKAbhnX/s1600-h/Photo+2.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKosCDxEGisVgz_PerNatWCw1QpVL7FWFFmWXoWphz4enQ-AzorXUGMM_-styYeZf9AbefZ5BZFwzmf9r6F9nWkYtMtxdaY2DZm6omx4AmX8vDtJyM9E2cpj-cNlU-tLKAbhnX/s320/Photo+2.jpg" alt="" id="BLOGGER_PHOTO_ID_5247739239520755346" border="0" /></a>Instructions: Take a picture of yourself right now. Don't change your clothes, don't fix your hair - just take a picture. Post that picture with NO editing. Post these instructions with the picture.<br /><br />Via: <a href="http://beta.friendfeed.com/e/55d15156-1fae-4b56-ae2a-1d414d987310/Photo-Meme/">Betz</a>, <a href="http://beta.friendfeed.com/e/7e972fc5-a3d8-4790-9c4e-8b1ae4e357e3/damn-egnor-photo-meme-for-a-limited-time/">Kang</a>, <a href="http://beta.friendfeed.com/e/3fdee29a-5a50-408c-affb-7575c71380f0/Photo-meme/">Egnor</a>. Also:<a href="http://beta.friendfeed.com/e/bde49519-c329-4972-8c7a-4cdda3db0ce9/Photo-Meme/"> Haahr</a>.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-46707920752983836122008-07-30T14:49:00.009-04:002008-07-31T14:20:31.193-04:00An Album for Each YearThe exercise has been going on for a few weeks in the blogosphere. See <a href="http://www.roughtype.com/archives/2008/07/albums_going_st.php">Albums Going Steady</a> or <a href="http://blogcritics.org/archives/2008/07/30/110649.php">My Favorite Album.</a> I was born in 1972, so it wasn't until sometime in the mid 1980s that I had favorite albums that were actually released that year.<br /><ul><li>2007 Spoon <span style="font-style: italic;">Ga Ga Ga Ga Ga</span></li><li>2006 Ben Kweller <span style="font-style: italic;">Ben Kweller</span></li><li>2005 Fiona Apple <span style="font-style: italic;">Extraordinary Machine</span></li><li>2004 Modest Mouse <span style="font-style: italic;">Good News for People who Love Bad News</span></li><li>2003 Joe Strummer<span style="font-style: italic;"> Streetcore</span></li><li>2002 The Flaming Lips <span style="font-style: italic;">Yoshimi Battles the Pink Robots</span></li><li>2001 <b> </b>Björk, <i>Vespertine</i></li><li>2000 The Delgados <span style="font-style: italic;">Great Eastern</span></li><li>1999 Fiona Apple <span style="font-style: italic;">When the Pawn</span></li><li>1998 Billy Bragg & Wilco <span style="font-style: italic;">Mermaid Avenue</span></li><li>1997 Sleater-Kinney <span style="font-style: italic;">Dig Me Out</span></li><li>1996 Tommy Flanagan <span style="font-style: italic;">Sea Changes</span></li><li>1995 Bjork <span style="font-style: italic;">Post</span><br /></li><li>1994 Hole <span style="font-style: italic;">Live Through This</span></li><li>1993 Liz Phair <span style="font-style: italic;">Exile in Guyville</span></li><li>1992 k.d. lang <span style="font-style: italic;">Ingenue</span></li><li>1991 U2 <span style="font-style: italic;">Achtung Baby</span></li><li>1990 Replacements (Paul Westerberg) <span style="font-style: italic;">All Shook Down</span></li><li>1989 Pixies <span style="font-style: italic;">Doolittle</span></li><li>1988 Sonic Youth <span style="font-style: italic;">Daydream Nation</span></li><li>1987 U2 <span style="font-style: italic;">Joshua Tree</span></li><li>1986 R.E.M. <span style="font-style: italic;">Life's Rich Pageant</span></li><li>1985 The Smiths <span style="font-style: italic;">Meat is Murder</span><br /></li><li>1984 Replacements<span style="font-style: italic;"> Let It Be</span></li><li>1983 R.E.M. <span style="font-style: italic;">Murmur</span></li><li>1982 Violent Femmes <span style="font-style: italic;">Violent Femmes</span></li><li>1981 Bauhaus <span style="font-style: italic;">Mask</span></li><li>1980 Dead Kennedys <span style="font-style: italic;">Fresh Fruit for Rotting Vegetables</span></li><li>1979 The Clash <span style="font-style: italic;">London Calling</span></li><li>1978 Elvis Costello <span style="font-style: italic;">This Year's Model</span></li><li>1977 Talking Heads <span style="font-style: italic;">Talking Heads 77</span><br /></li><li>1976 Sex Pistols <i>Never Mind the Bollocks, Here's the Sex Pistols</i></li><li>1975<br /></li><li>1974</li><li>1973</li><li>1972 Rolling Stones <span style="font-style: italic;">Exile on Main Street</span></li></ul>There's a bit of skew caused by which albums I own. And I don't have a great sense for what I listen to from the early 1970s. If I had to pick some runners up, they would be Hüsker Dü<span style="font-style: italic;"> Zen Arcade</span> (1984) , Cowboy Junkies <span style="font-style: italic;">Trinity Session</span> (1988), the Minutemen <span style="font-style: italic;">Double Nickels on the Dime</span> (also 1984), and Matthew Sweet <span style="font-style: italic;">Girlfriend</span> (1991).Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-4438878130715376002008-06-18T16:58:00.004-04:002008-06-18T17:04:56.444-04:00Python 3000 urllib packageI made an svn commit on the py3k branch today--my first commit in a long while.<br /><blockquote>Make a new urllib package .<br /><br />It consists of code from urllib, urllib2, urlparse, and robotparser.<br />The old modules have all been removed. The new package has five<br />submodules: urllib.parse, urllib.request, urllib.response,<br />urllib.error, and urllib.robotparser. The urllib.request.urlopen()<br />function uses the url opener from urllib2.<br /><br />Note that the unittests have not been renamed for the<br />beta, but they will be renamed in the future.<br /><br />Joint work with Senthil Kumaran.<br /></blockquote><br />I started urllib2 at CNRI sometime around 1999, based on some experience working Grail (a Python+Tk web browser). I had intended to polish it much more and replace urllib, but I ran out of time. When the PythonLabs team moved from CNRI to BeOpen, we needed to put that code in a Python release or negotiate with CNRI to take the code anyway. So it went into Python 1.6 in its rough form, and I moved on to other projects.<br /><br />A mere ten years later, we've made some progress. urllib and urllib2 have merged together into a urllib package. The urllib2 code has become the default implementation in the new package. If you call urllib.request.urlopen(), you get urllib2 code.<br /><br />Senthil is working on a <a href="http://urllib-gsoc.blogspot.com/">urllib summer of code project</a> to improve the code and documentation further. I'm looking forward to it.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com3tag:blogger.com,1999:blog-19730683.post-85809175304660927492008-04-06T21:24:00.004-04:002008-12-12T03:35:13.058-05:00Election Certificate<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5bWTZ5CZPww2b92GDP_37dxV4BDuAcEMBUE1mkT_ETfBw3faOVCIOJ0y64pjOe61KPc7yQOWSnHumBW293xiNEQ4a9K5YooG81g94aU8h5Cf5mNmBC0HLKuctAXs1HVUnBOIg/s1600-h/certificate.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5bWTZ5CZPww2b92GDP_37dxV4BDuAcEMBUE1mkT_ETfBw3faOVCIOJ0y64pjOe61KPc7yQOWSnHumBW293xiNEQ4a9K5YooG81g94aU8h5Cf5mNmBC0HLKuctAXs1HVUnBOIg/s320/certificate.png" alt="" id="BLOGGER_PHOTO_ID_5186309326382109058" border="0" /></a><br /> I won a local election a few years ago by a single vote--my own. It was fun to receive the official certification, which has a form to fill out with name and vote total. The form includes the word "votes" rather than "vote(s)," which would have been more appropriate in my case.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com2tag:blogger.com,1999:blog-19730683.post-4998224853475156702008-03-21T20:15:00.011-04:002008-03-22T11:54:07.921-04:00Lightning TalksI missed PyCon this year. It was the first time I skipped a Python conference since I started going in 1997. I've been reading reports from bloggers eagerly. One of the larger discussions is about the sponsor lightning talks, which weren't well received. <a href="http://www.sauria.com/blog/bio/">Ted Leung</a> commented that we should thank the Perl folks for the <a href="http://www.sauria.com/blog/2008/03/20/on-conferences/">lightning talks</a>, but I think they have a long history at Python conferences.<br /><br />I ran the first session of <a href="http://www.python.org/workshops/1997-10/shorties.html">short talks</a> at the Python conference in 1997: "Content-wise, anything goes, as long as it is deemed interesting for a room full of Python users and developers, and as long as the content is technical, not marketing material."<br /><br />I have a distinct recollection of seeing a short talk by <a href="http://www.dogfish.org/chris/">Christopher Small</a> at a Usenix conference that inspired our short talks session. He had just a few minutes for the talk and something like 17 slides. He had someone turn the slides for him at regular intervals and he tried to keep up. It was really entertaining. (I would have guessed it was at the <a href="http://www.usenix.org/publications/library/proceedings/osdi96/wip.html">1996 OSDI WIP session</a>, but he's not on the list of speakers.)<br /><br />The first speaker at our short talks session with <a href="http://en.wikipedia.org/wiki/Scott_Deerwester">Scott Deerwester</a>, and he agreed to use the same presentation style as Small. I turned his slides for him, whether he was ready or not. He was a good sport and I think it set a light tone for the rest of the session.<br /><br />We didn't have short talks the following year and didn't have a Python conference at all in 1999. <a href="http://www.dabeaz.com/">David Beazley</a> ran the short talks session in 2000. (<a href="http://www.amk.ca/">Andrew Kuchling</a> noted the short talks in his<a href="http://www.amk.ca/python/writing/ipc8"> conference summary</a>.) The Python folks started calling them <a href="http://mail.python.org/pipermail/python-list/2001-February/071830.html">lightning talks in 2001 </a>at the 9th Python conference. David Ascher ran a session called lightning talks at OSCON in 2003, too.<br /><br />I think the name lightning talk is due to <a href="http://perl.plover.com/">Mark-Jason Dominus</a>. We exchanged some email about the Python short talks long ago, when he was planning the first<a href="http://perl.plover.com/lightning-talks.html"> lightning talks session</a> at a Perl conference. I've never seen a Perl lightning talk session, so I don't know how they compare to the Python short talks / lightning talks. I think they deserve a lot of credit for popularizing the idea.<br /><br />We've always tried to have fun with the lightning talks. It's a good place for outrageous opinions or quick demos. We've gotten less and less formal about it, too. The first few session required you to sign up in advance and had a full schedule. Later, we let people sign up on the spot and made up the schedule as we went along.<br /><br />The lightning talks have become one of the most popular sessions at the recent PyCons. They've been scheduled with nothing opposite them (like keynotes, unlike regular talks), and there have been several sessions of them.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com2tag:blogger.com,1999:blog-19730683.post-85921008983465165862008-01-24T14:50:00.000-05:002008-01-24T23:05:23.407-05:00Dave Weissman needs a haircutHe may argue the point, but I think he is wrong.<br /><br />Update: <a href="http://mreid.livejournal.com/2202.html">mreid agrees.</a> <a href="http://nina.kang.googlepages.com/dave-weissman-hair-bandwagon">kang agrees.</a>Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com9tag:blogger.com,1999:blog-19730683.post-91510478323631167392007-09-18T14:13:00.000-04:002007-09-18T14:30:18.898-04:00Beautiful librariesI found this <a href="http://www.curiousexpeditions.org/2007/09/a_librophiliacs_love_letter_1.html">love letter to libraries</a> via <a href="http://www.researchbuzz.org/wp/2007/09/18/researchbuzz-roundup-091807/">ResearchBuzz</a>. I've only been to a few of these libraries myself:<br /><ul><li>The <a href="http://www.curiousexpeditions.org/Peabody%20Library.jpg">Peabody Library</a> in Baltimore. I lived a few blocks away.</li><li>The <a href="http://www.curiousexpeditions.org/TRINITY-COLLEGE-LIBRARY-DUB%20%28%29.jpg">Long Room</a> at Trinity College Dublin. I lived more than a few blocks away, but not too far.</li><li>The public libraries in Boston and New York</li><li>Not on the list, but others I've enjoyed: The <a href="http://www.hno.harvard.edu/gazette/2004/09.30/photos/15-widener2-225.jpg">Widener Library</a>. The Hayden science library at MIT is not pretty; it looks like a cheap motel. It does have a <a href="http://web.mit.edu/cai/www/photo/MITlibrary/k001012.jpg">wonderful view of Boston and the Charles River</a>.<br /></li></ul>Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-71053900902180067632007-05-09T22:32:00.000-04:002007-05-10T10:44:06.020-04:00McNamara, Unions, and Labor CostsPaul Graham recently posted <a href="http://www.paulgraham.com/unions.html">An Alternative Theory of Unions</a> that compares union workers with servers--in particular with the notion that Internt Bubble companies overpaid for servers the way manufacturing companies overpaid works in the 1950s. He picks car manufacturers as a specific example:<br /><blockquote>If you looked in the head of a 1950s auto executive, the attitude must have been: sure, give 'em whatever they ask for, so long as the new model isn't delayed.</blockquote>I don't agree with the argument in general, and I think this particular suggestion is just plain wrong. <a href="http://web.worldbank.org/WBSITE/EXTERNAL/EXTABOUTUS/EXTARCHIVES/0,,contentMDK:20502974%7EpagePK:36726%7EpiPK:437378%7EtheSitePK:29506,00.html">Robert McNamara</a> who was responsible for financial controls and planning for the Ford Motor Company in the 1950s, ultimately becoming president in 1960. McNamara was well aware of the cost of every part of producing a car and worked hard to keep costs down at Ford.<br /><br />I've been reading David Halberstam's brilliant book on Vietnam, <a href="http://www.amazon.com/Best-Brightest-David-Halberstam/dp/0449908704"><span style="font-style: italic;">The Best and the Brightest</span></a>. He has an interesting discussion of McNamara's relationship with labor unions at Ford. He suggests that McNamara, a liberal former Harvard professor, was sympathetic to union concerns but more concerned about cutting costs.<br /><br />McNamara was one of the people behind the Ford Falcon, a smaller, cheaper Ford car that was a big success. The Wikipedia article on the <a href="http://en.wikipedia.org/wiki/Ford_Falcon_%28North_American%29">Ford Falcon</a> observes that towards the end of the 1950s American cars were becoming increasingly expensive because of wage inflation.<br /><br />I don't know much about manufacturing in general, but the analogy does not seem to apply in cars. Labor was expensive for carmakers in the 1950s. They seemed to be aware of the costs and tried to control them.<br /><br />If anything, the earlier generation of Ford leadership liked unions even less. Halberstam writes,<br /><blockquote>Under Henry [Ford] senior and Harry Bennett the policies of the company were singularly primitive. The public was a problem, the unions were a problem, the bankers were a problem.</blockquote>Update: Some of the <a href="http://www.marginalrevolution.com/marginalrevolution/2007/05/paul_graham_on_.html">comments on Paul's article at Marginal Revolution</a> make similar points.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-43653318684987760312007-04-12T11:27:00.000-04:002007-04-12T11:37:42.621-04:00Armadillo MigrationThere's no reason to post about armadillos today. Many years ago, I read an entertaining article in the <a href="http://pqasb.pqarchiver.com/washingtonpost/access/32376699.html?dids=32376699:32376699&FMT=ABS&FMTS=ABS:FT&date=JUL+27%2C+1998&author=Jennifer+8.+Lee&pub=The+Washington+Post&desc=At+4+to+6+Miles+a+Year%2C+%60Little+Armored+Ones%27+Advance+North&pqatl=google">Washington Post about armadillos</a>. I remembered that the armadillos could be expected to survive in Maryland and Pennsylvania, but I didn't remember how slow the northward migration was. I foolishly hoped to see an armadillo in my backyard one day.<br /><br />Tara and I found the original article in Google's news archive last night. It says<br /><blockquote>In another century or so, they could reach the White House as they continue their northward migration.</blockquote>It will be a long time until we see them in Easton.<br /><br />The article quotes <a href="http://biology.missouristate.edu/faculty_pages/Robbins/bats/index.htm">Lynn Robbins</a> on the subject. His co-author Joshua Nixon has a short overview page on <a href="http://www.msu.edu/%7Enixonjos/armadillo/expansion.html">armadillo expansion</a>.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-72120682572554069262007-02-27T13:35:00.000-05:002007-02-27T13:40:24.852-05:00Flight delayed, bugs fixedMy original flight from Dallas back to Newark was cancelled because of mechanical problems with the plane. I got bumped from a 10:30 flight to a 2:45 flight, which left me a few hours for hacking and socializing at the <a href="http://us.pycon.org/TX2007/Sprinting">PyCon sprints</a> this morning. I had breakfast with Jeff Elkner and caught up on his software and teaching projects, and I got to finish some <a href="http://svn.python.org/view?rev=53997&view=rev">bug fixes in typeobject.c</a> that I had worked on yesterday. I find it very satisfying to fix an Armin Rigo crash bug. It's usually an accomplishment just to understand it.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-37854572183102813342007-02-27T01:52:00.000-05:002007-02-27T02:04:50.194-05:00nonlocal implementedI'm going to love <a href="http://www.python.org/dev/peps/pep-3000/">Python 3000</a>! Thomas Wouters and I implemented <a href="http://www.python.org/dev/peps/pep-3104/">PEP 3104</a> tonight. It fixes a wart in the original nested scopes implementation that I did in 2001. In that version of nested scopes, we did not allow names defined in one function to be rebound in an enclosing function. It was impossible for the compiler to distinguish between an assignment that creates a local and an assignment that rebinds. Python 3000 will fix this using the nonlocal statement. I hate the name nonlocal, but no one has thought of a better name. <a href="http://zesty.ca/">Ka-Ping Yee</a> wrote PEP 3104 and provided an exhaustive list of alternate names,<br /><br />The <a href="http://svn.python.org/view?rev=53986&view=rev">code itself </a>was quite simple. The only changes in compile.c were trivial. The symbol table needed more changes, because it had to recognize a new kind of declaration and propagate that information to the compiler. The symbol table uses a bit-field where a handful of the bits are used to represent the scope. I spent a lot of time scratching my head until I remember that I needed to increase the width of mask used to extract the scope-related bits. I think I'm not happy with the bit-field representation.<br /><br /><a href="http://us.imdb.com/name/nm0793968/">Pete Shinners</a> and Neal Norwitz reviewed code and helped think of tests cases.<br /><br />That wraps up a fun day of sprinting for me. I also closed several bugs and spent a few hours pouring over typeobject.c to fix some crasher bugs that Armin Rigo reported. I have a fix for one of them, but I want to do a little refactoring before I check it in. Next week, perhaps. I'm flying home first thing in the morning.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com3tag:blogger.com,1999:blog-19730683.post-10244489671128247112007-02-26T19:18:00.000-05:002007-02-26T19:39:23.494-05:00Bug of the day<a href="http://mike.verdone.ca/blog/">Mike Verdone</a> found a great Python bug today. It's an interaction between two features.<br /><ul><li><a href="http://docs.python.org/ref/atom-identifiers.html">Name mangling</a>. If you use an identifier with two leading underscores in a class, the name is mangled to include the name of the class as a prefix, except if the name also ends with two trailing underscores. In the class Spam, the identifier __eggs becomes _Spam__eggs. Note that the language reference says that mangling applies to any identified<br /></li><li><a href="http://www.python.org/doc/essays/packages.html">Packages</a>. You can import a name like A.B.C. This name describes a module C in package B inside package A. Note that A, B, and C are identifiers, so if one of them has two leading underscores they should be mangled. import __A.B.C should technically be turned into import _Spam__A.B.C if it occurs inside class Spam.</li></ul>One detail of the implementation is that the compiler represents the sequence of identifiers in a package name as a single string. The compiled code represents the dotted name as a single string argument to a bytecode instruction. The implementation of name mangling checks for strings that start and end with double underscores. Therein lies the problem. The string "__A__.B.C" starts with two underscores, but does not end with two underscores. It is mangled to "_Spam__A__.B.C."<br /><br />How old is this bug? It is present in Python 1.5.2 and was probably present in the original release of Python 1.5. The bug is about nine years old.<br /><br />We're going to do a quick fix: Change name mangling so that it does not mangle names with dots in them. This will fix the __A__.B.C case, break the __A.B.C case, and leave broken the A.__B.C case. It is likely that we will change the language spec and say identifiers in import statements are not mangled.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com0tag:blogger.com,1999:blog-19730683.post-56161502172855400762007-02-26T12:17:00.000-05:002007-02-26T13:29:23.474-05:00locals() and free variablesI've been struggling with some odd corner cases of free variables and <span class="blsp-spelling-error" id="SPELLING_ERROR_0">eval</span>/exec in Python.<br /><br />There is a long-standing bug report that you can't access free variables when you created a nested code block with <span class="blsp-spelling-error" id="SPELLING_ERROR_1">eval</span> or exec--for example, putting a lambda in an expression passed to <span class="blsp-spelling-error" id="SPELLING_ERROR_2">eval</span>. It works if the variable happens to be free in the text of the function containing the <span class="blsp-spelling-error" id="SPELLING_ERROR_3">eval</span>, but only then. The bug report claimed that Scheme worked differently, but I don't think Scheme provides a way to capture an arbitrary environment to pass to <span class="blsp-spelling-error" id="SPELLING_ERROR_4">eval</span>; it only provides access to top-level environments.<br /><br />The name locals() is misleading. It returns free variables as well as local variables. The name suggests that this behavior is wrong, but it is necessary to make exec and <span class="blsp-spelling-error" id="SPELLING_ERROR_5">eval</span> work with free variables. The function returns the names visible in the current scope.<br /><br />The discussion here is actually about much more than locals(). The same basic issues arise when you use exec or import * in a block or when you use the debugger or some other trace function installed via <span class="blsp-spelling-error" id="SPELLING_ERROR_6">sys</span>.<span class="blsp-spelling-error" id="SPELLING_ERROR_7">settrace</span>(). In all these cases, we extract variables in a dictionary to support introspection.<br /><br />There is still a problem with locals(), which results from the use of locals() in debugging. The implementation makes sure that changes made to the locals dict are reflected in the running program in many cases. In old versions of Python, local variables were stored in a dictionary and locals() returned the actual dictionary. This feature is useful in the debugger. When the <span class="blsp-spelling-corrected" id="SPELLING_ERROR_8">implementation</span> changed to use a simple C array instead of a dict, the interpreter arranged to copy variables back and forth between the dictionary and the array when the debugger was used. (This behavior is also needed to make features like exec and import * work.)<br /><br />In many cases, it is fine to copy free variables into the dictionary returned by locals. If changes are made to those variables, they can be written back to the appropriate part of the closure rather than creating local variables that shadow the free variables.<br /><br />Class <span class="blsp-spelling-error" id="SPELLING_ERROR_9">namespaces</span> pose a serious problem in the current <span class="blsp-spelling-error" id="SPELLING_ERROR_10">CPython</span> implementation. The class stores local variables in a dictionary. When the body of the class finishes execution, this dictionary is passed to the class constructor. Keys in the dictionary become attributes of the class. If you call locals(), free variables could be copied into the dictionary for access in the debugger or introspection. But if they are copied, they will become attributes of the class, which was not intended. It's a messy problem, because it is possible, though inscrutable, for<br />the same name to be used for a free variable in a method and a class attribute; they have the same name, but they refer to different bindings.<br /><br />For now, we are fixing this in Python 2.x by omitting free variables from the dictionary returned by locals() when locals() is called in a class block. This makes introspection more difficult but prevents locals() from polluting the class <span class="blsp-spelling-error" id="SPELLING_ERROR_11">namespace</span>.<br /><br />What are some other solutions for the class problem? It might be possible to return a copy of the class dictionary with the free variables added. Changes to this dictionary are written back to the real dictionary or free variables when you run in the debugger. It wouldn't be possible to reflect all changes to the dictionary; it would only work in contexts like debugging or using exec. I'm not sure if that would be too confusing.<br /><br />We could also make two different functions, where locals() and vars() seem like reasonable names. The locals() could return the actual dictionary object for classes, without adding the free variables. The vars() could return a dictionary will all variables, but it would be a copy. Then client code could get whatever they wanted.Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com1tag:blogger.com,1999:blog-19730683.post-17790407150888474092007-02-26T02:26:00.001-05:002009-01-29T16:35:55.708-05:00PyCon Pictures<div style="font-family: arial,sans-serif; font-size: 83%; text-align: center; width: 194px;"><div style="-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: transparent url(http://picasaweb.google.com/f/img/transparent_album_background.gif) no-repeat scroll left center; height: 194px;"><a href="http://picasaweb.google.com/jhylton/PyCon"><img height="160" src="http://lh5.google.com/image/jhylton/ReJ9MiphxHE/AAAAAAAAAzs/ETozFumn4Kc/s160-c/PyCon.jpg" style="border: medium none; margin-top: 16px; padding: 0px;" width="160" /></a></div><a href="http://picasaweb.google.com/jhylton/PyCon"></a><br />
<div style="color: #4d4d4d; font-weight: bold; text-decoration: none;"><a href="http://picasaweb.google.com/jhylton/PyCon">PyCon</a></div><br />
<div style="color: grey;"></div></div><br />
<br />
My first Python conference was almost ten years ago, at a hotel in downtown San Jose. Guido introduced Python 1.5 that year, and <a href="http://www.python.org/workshops/1997-10/proceedings/hugunin.html">Jim Hugunin introduced JPython</a>. I ran the very first lightning talks session. Ten years later, there are still a lot of familiar faces, but the conference is much bigger. The community is larger and their interests more diverse. The keynote speakers were variously engaging and entertaining, probably equally Randy Pausch's talk in <a href="http://www.python.org/workshops/2000-01/">2000</a>.<br />
<br />
I attended a few talks, fixed a few bugs, and got a chance to re-engage with Python development. I have had little time for Python since 2.5 was released and the compiler rewrite finished. I'm looking forward to a full sprint day to get some code written. I had hoped to fix some obscure bugs, but Armin Rigo's bug reports were too obscure to get to the bottom of with just an hour's study.<br />
<br />
A small group of python-devers and Googlers had an over-the-top dinner at the Mansion on Turtle Creek.<br />
<br />
I've collected a few <a href="http://picasaweb.google.com/jhylton/PyCon">PyCon pictures</a> over the week, snapshots of friends, speakers, and other Pythonistas. <b>Update:</b> I added a few pictures from the sprints on Monday (2/26/07).Jeremy Hyltonhttp://www.blogger.com/profile/05832343974221233570noreply@blogger.com3Addison, TX, USA32.94953410802632 -96.82435512542724632.945032608026317 -96.831650625427244 32.954035608026324 -96.817059625427248