Feb 5, 2012


A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines

- R. W. Emerson

Looking over the VPI iterator sample code I posted last night from PyHVL, I noticed something. I've defined the API as follows:

def vpi_iterator(handle, type=vpiNet):
With the handle first and an optional type parameter second, taking the default value of vpiNet. Looking again at the C implementation, I see that the method signature is the reverse:
itr = vpi_iterate(vpiNet, mod);
Now, I'm faced with a decision. I could make the Python vpi_iterator() call consistent with the similar C API, and reverse the parameters, or I can keep it the same way. Keeping it the same way allows the use of the default argument for vpiNet. Optional arguments must follow required arguments, so I couldn't reverse it and keep the type=vpiNet as an option, it would have to become (type, handle). In this case, I don't think the default type is particularly intuitive from the name, so I would tend to think there is more value in reversing the arguments, so that it is consistent with the C API's similar function signature.
def vpi_iterator(type, handle):
Some people might think this is a totally arbitrary consideration. I believe this sort of detail is important. My favorite languages are internally consistent, so that when you start using a new library or part of the language, the structures and idioms are so familiar you can often code things correctly without having fully read the documentation. Most of the Python standard library is like that, you can pick up a new library and be productive, quickly, because there aren't jarring inconstancies. If I want people to use this vpi_iterator method, coming from C, it will help if it matches the general argument patterns used there. Less friction to getting code working first time.
Each of these is just a small thing that you have to remember, but each time it catches you out it is annoying and maybe knocks you off your train of thought to fix it. The details and consistency are important to people being productive in a language.

I wish SystemVerilog had more of that consistency - semicolons to mark the end of a function definition, then a begin/end syntax for blocks, or {} for some parts of the language to define blocks. end, endfunction, endtask. Just extra details that get in the way of writing clean code the first time.

There are comments.

Improving sshfs connections

I'm finding sshfs to be excellent for remotely accessing drives over ssh. There's a couple of tweaks to the ssh config file that can make things even better. If you haven't used an ssh config file, it can be used to store general and connection specific information, to save you typing it every time. The file lives in ~/.ssh/config

Host <hostname>


Host <otherhostname>



Host short

Hostname ssh.long_url_name.com

Username myusername

so, instead of typing ssh myusername@ssh.long_url_name.com I can instead run the following:
ssh short
To improve the sshfs you should add
ServerAliveInterval 15 
to the Host that you connect over sshfs, which will make sshfs to a ssh keepalive ping every 15 seconds.

There are comments.

Feb 12, 2008


Finally! Now my Mac can do everything my windows machine can do. I'm so happy.

There are comments.