Understanding hashing in Python
I've talked about the __hash__ special method a fair bit in here (and a note in the middle of this ), but today it's time to actually write enough backgroundso that people can actually understand why you might want to write aspecial method for it, what you need to do, and what the whole story is.The first and biggest question is simple; why is it interesting to giveobjects what I called a 'hash identity'?
The motivation for hash identities
My story of running scripts from the web
One of the famous terrifying ideas for system administratorsis people being told 'oh, to install this just pipe thisURL into a (root) shell' (see, for example, this tweet ). OnTwitter Imentioned that I used to do this sometimes, so today I'm going toexplain myself. Trust me, it's less insane than it looked.
Once upon a time I was responsible for a bunch of more or less identicalLinux machines. We had two forms of automated installs.
Checksums and hashes
Every so often I run across something on the Internetthat makes me grind my teeth at how wrong itis. Today's example is Jeff Atwood's Speed Hashing , where hesignificantly mangles what both checksums and hashes are in an otherwisereasonable article. Since it has made me grumpy, I'm going write a summarywhat they actually are.
(Yes, yes, you may now cue the obligatory XKCD strip .)
A checksum function isdesigned to always change its value if an N bit or less
Why we haven't taken to DTrace
Recently I read Barriers to entry for DTrace adoption ( via Twitter ). As ithappens I have an opinion on this, since we use Solaris and I have donea modest amount of things with DTrace. My belief is that DTrace hasbetween two and three problems, depending on how you look at it.
(Part of our non-use of DTrace is that I once had a bad experience wherestarting to use DTrace on a production fileserver had immediate andsignificant bad effects. I've seen DTrace work okay
Why I hate having /tmp as a tmpfs
There is a recent move in Linux to turn /tmp into a tmpfs. As a sysadmin, I am afraid that I have a visceral dislikeof this (and always have).
The core problem with a RAM-backed /tmp is that it creates a new easyway to accidentally DOS your machine. When /tmp is only a disk, it'spretty clear how much space you have left and filling up /tmp is onlya minor to moderate inconvenience. When /tmp is backed by RAM,
More on equality in Python (well, mostly Python 2.7)
There are undoubtedly some languages where if you create a new class,instances of the class don't support equality checks at all until youtell the language how to do this. Python is friendlier, so it gives allclasses a default idea of ordinary equality ,the equality of == . This default is object identity; for anuncustomized class, ' a == b ' is the same as ' a is b '. This is kindof minimal but it's hard to argue that an object is
Python's two versions of equality, with a long digression on hash()
Python has three two versions of equality; in order ofpickiness, they are == (plain equality) and is identity. When Istarted writing this entry I was going to say that there were three andthe third was hash identity, but I am wrong about that. We'll talk abouthash identity at the end.
Plain equality is actually surprisingly complicated if you want itto be. A class can control how all of the comparison operators workwith special methods (aka 'magic methods'),
The problem of ZFS pool and filesystem version numbers
ZFS pools and filesystems have version numbers for the straightforwardreason; it lets ZFS augment or (carefully) change the on-disk storageformat to add new features. Old versions of ZFS will know that theyshouldn't touch a pool with a new version because they don't understandall of its metadata; new versions of ZFS will know that some poolscan't have new metadata written to them and so on. All of this is veryconventional.
In light of my previous entry on the several OS
Why I no longer believe that you need Solaris if you want ZFS
Four years ago I wrote an entry on why you wantedto use Solaris if you were going to use ZFS. Recently I have beenreconsidering this issue, and I no longer believe that you need to pickSolaris if you're going to use ZFS. What has happened is that ZFS andZFS development has changed drastically.
Back in 2008 it was clear that there was only one ZFS. All of the realZFS development was happening at Sun and was being done to Solaris; allother versions were
Our sysadmin environment
I've said before that we don'thave anything like a traditional ops or 'devops' environment here . This raises an obvious question: what isour work like?
The simple way to describe it is that my group is traditionaluniversity sysadmins (well, for departmental computing). This meansthat our job is to provide an environment with various services,things like network connectivity, reasonably decent file storage , printing, email, some machinesthat people can log into to do various things (including run big