insomnihack

When sleep eludes, the keyboard beckons

Speed up PyCharm Debugging with Psyco

August 7, 2010 Dale 4 Comments

I’ve been digging what JetBrains is doing with PyCharm, and I’m looking forward to the 1.0 release. Almost everyone doing Python development at work has switched to it. I noticed something a while back that peaked my curiosity, though. While debugging, I came across a cryptic message in PyCharm’s console window:

[text]
pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)
[/text]

What’s all this now? Are you saying something on my box isn’t running as fast as it could be? That wouldn’t do at all.

So, I loaded up my web browser. A quick Google search later and I’d found the psyco project on Sourceforge. Psyco is a specialized Python compiler, created by Armin Rigo who is now working on PyPy. Psyco speeds up the execution of most Python programs with a single extension module. Development of psyco was recently taken over by Christian Tismer, who has made many improvements to psyco.

At work, I tend to live in Windows or Ubuntu, and at the moment I was working in Windows, so I followed the link over to Michael Foord’s site where he’d thrown together some 32-bit Windows binaries for psyco 2.0 on Python 2.4, 2.5, and 2.6. I grabbed the 2.6 version, but I didn’t immediately install it.

To gauge the benefit of a psyco-powered debugger versus one without, I first needed to run a baseline benchmark. My work box is a Dell Precision T7400 with an Intel Zeon E5405 @ 2.0Ghz with 8Gb ram on Windows XP SP2 x64. My Python version is 2.6.5 (32-bit – psyco does not as yet work with x64).

I created a new Python project, and copied the pystone.py benchmark file from my Python distribution’s test folder into it. Here’s the results of my first non-psyco debugger run.

[text highlight=”6″]
C:/Tools/Python26/python.exe "C:\Program Files (x86)\JetBrains\PyCharm 96.742\helpers\pydev\pydevd.py" –client 127.0.0.1 –port 13926 –file C:/Source/PsycoTest/pystone.py
Connected to pydevd (version 1.1)
pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)
pydev debugger: starting
Pystone(1.1) time for 50000 passes = 8.70703
This machine benchmarks at 5742.49 pystones/second

Process finished with exit code 0
[/text]

Next, I installed psyco and ran the test again.

[text highlight=”5″]
C:/Tools/Python26/python.exe "C:\Program Files (x86)\JetBrains\PyCharm 96.742\helpers\pydev\pydevd.py" –client 127.0.0.1 –port 13936 –file C:/Source/PsycoTest/pystone.py
Connected to pydevd (version 1.1)
pydev debugger: starting
Pystone(1.1) time for 50000 passes = 5.49379
This machine benchmarks at 9101.18 pystones/second

Process finished with exit code 0
[/text]

Not too shabby. My pystone benchmark went from 5742.49 to 9101.18: a 63% improvement just by installing a Python library! Clearly I’m going to have to experiment using psyco for some of my own projects.

Programming PyCharm, Python, tools

Building a Home Theater PC

August 4, 2010 Dale Leave a Comment

After years of suffering with Time-Warner Cable’s craptacular American Scientific DVR and near-monthly service fee hikes, I decided (perhaps foolishly) to try and build myself a home theater PC (HTPC). The goal was to construct a single box I could use to play BluRay movies, stream content from YouTube and Hulu, as well as record live cable or over-the-air digital TV transmissions.

Reasons to Build an HTPC

There are numerous benefits of an HTPC over the usual assortment of individual PVR and DVD devices including:

  • The ability to consume all media from a single box, including:
    • Cable and OTA digital TV,
    • Streaming internet content such as Hulu, YouTube, and Netflix,
    • DVDs and Bluray discs,
    • High definition 720p and 1080p digital content.
  • The ability to access music, photos, and home movies from my TV,
  • A better DVR experience than that available from the cable companies (including the ability to remove commercials from recorded content),
  • The ability to access the internet from my TV.

Reasons NOT to Build an HTPC

In the interest of disclosure, you should know there are just as many reasons not to build one.

  • Complex hardware requirements. Do you need a quad core CPU, or will a dual work? Does one need dual tuners? What’s a tuner?
  • More complex software configuration. Windows Media Center or MythTV can be confusing to set up even for experienced computer users; navigating the rocky shoals of codec configuration can be even more frustrating.
  • Setting up all software so that the whole thing is easy to use for the non-computer geeks in the household (i.e. programming the damned remote).

The whole process requires a significant amount of technical skill. A quicker way for a less nerdy folks to get a lot of what an HTPC will do is buying an Apple TV. Setup and operation is easy, but as with many of the delights of Apple’s walled garden, you may find yourself limited when you want to replace your DVR or view file formats such as MKV.

Hardware

After a bit of research reading recent blogs, reviews and forum discussions on HTPC hardware, here’s what I settled on for my box. Note that these specs are probably a bit out-dated by the time you read this. I ran into a strange issue with WordPress and too many images in unordered lists that had me down a bit of a rabbit hole for a bit.

Case

Antec Black Fusion Remote Micro ATX HTPC

No dorky mid-towers for this HTPC. I wanted something that looked like a piece of stereo equipment. The Fusion has bumpers for isolating hard drive noise, a couple of quiet 120 mm fans, and an isolated power supply chamber to keep power heat from the components. I’ll be ditching the unremarkable remote for something sweeter.

Antec Fusion Black

Antec Fusion Black

Motherboard

ASUS Maximus III GENE

The Maximus III GENE features a built-in SupremeFX X-Fi sound chip, so I don’t need a sound card. It comes with 9 USB ports, an eSATA port, Firewire (1394), & 7 SATA ports.

Maximus III GENE

Maximus III GENE

CPU

Intel Core i5-670 3.46GHz 4MB 73W Dual-Core

Dual-core fast, while clocking in at a lean(ish) 73W, the i5-670 should handle most HTPC tasks without breaking a sweat.

Intel Core i5-670

Intel Core i5-670

RAM

G.SKILL 4GB (2 x 2GB) DDR3 1600

4Gb of fast DDR3 memory should be plenty for recording and playback.

G.SKILL 4Gb DDR3

G.SKILL 4Gb DDR3

Hard Drive

SAMSUNG Spinpoint F3 HD103SJ 1TB 7200 RPM 32MB SATA

Fast and affordable, the HD103SJ is also very quiet, so it won’t distract use from what we’re watching.

Spinpoint S3 1Tb

Spinpoint S3 1Tb

BluRay/DVD

Pioneer 12X BD-R 4MB SATA BDR-205BKS

I’ll need a drive that plays and burns both BluRay and DVD disk, and the Pioneer can spit out BluRay disks at 12x.

Pioneer BDR-205BKS

Pioneer BDR-205BKS

Graphics

XFX HD-567X-YNFC Radeon HD 5670 512MB

Perhaps a bit underpowered for the latest PC games, this card does support accelerated video trans-coding and HDMI, and the whole thing including fan fits on one slot, which really helps on the cramped Micro ATX motherboard and case I’ll be using.

XFX Radeon HD 5670 512MB

XFX Radeon HD 5670 512MB

Tuner

Hauppauge HVR-2250 OEM

This card sports dual digital TV receivers for ATSC or clear QAM so I can watch and record two ATSC or clear QAM digital TV programs at the same time. It records all ATSC and QAM formats, including the high definition 1080i format. It has dual built-in hardware MPEG-2 encoders for recording analog cable TV, so I can watch and record two cable TV programs at the same time. Finally, the built-in antenna splitter allows me to make one connection to either cable TV or an ATSC antenna, and watch and record up to 2 channels.

Hauppauge HVR-2250

Hauppauge HVR-2250

Power Supply

SeaSonic X650 Gold 650W ATX12V.

This power supply has plenty of capacity for my HTPC, and its modular, so I can remove any cables I don’t need. This helps with airflow and cooling.  It’s pretty quiet; the fan only spins when the unit starts to get warm. It’s 90% energy efficient, earning it an 80 PLUS Gold certification.

SeaSonic X650 Gold

SeaSonic X650 Gold

Network

NETGEAR XAVB101-100NAS

I’m too lazy to wire the house, but I also didn’t want to mess with WIFI issues on my TV. I hadn’t used power line networking before, and this seemed a suitable compromise between short and long term laziness.

NETGEAR XAVB101

NETGEAR XAVB101

Keyboard

IOGear Multimedia 2.4GHz Wireless GKM561R

After all, this is a PC. I don’t want to waste time trying to enter text with a remote when Shelly and I have to pause Aristocats so we can find out who did the voices for the hound dogs on IMDB. The GKM561R is basic, functional, and relatively inexpensive.

IOGear GKM561R

IOGear GKM561R

Remote

Logitech Harmony One

One remote to rule them all, one remote to find them, one remote to bring them all and in the darkness bind them. Full color touch screen, one-touch activity controls, ergonomic, programmable with an constantly expanding library of supported devices, and a rechargeable base. Also, it looks like a phaser – pew, pew.

Logitech Harmony One

Logitech Harmony One

Operating System

Windows 7 Ultimate 64-bit

I use Linux for work and on my unRAID file server, but I’m just not down for the level of console kung foolery required to get everything I want in an HTPC working under it. Also, there are other interested parties waiting on the system who don’t know their way around Linux.

Some Assembly Required

After a week or so, all the pieces were in from Newegg.com and Amazon.com, and it was time to put everything together.

Building a system is always a bit of a pain in the ass, especially if you have big troll hands like mine. This job was particularly annoying. HTPC cases are smaller than the roomy towers I’m used to building systems with, and getting things situated took some time. Soon, I ran into my first unforeseen problem.

SATA Cable Problem

SATA Cable Problem

As you can see, the nice little array of SATA connectors on the side of the Maximus III Gene end up almost flush with the Fusion’s drive separation wall. In order to get the SATA cables connected, I had to cut a new opening  in with my Dremel.

Once that was done, I had a bit more pulling and prodding to get all the cables connected. Were I to do it again, I’d avoid this particular case/motherboard combination.

Next Steps

Now that the box is put together and running, I’ll be spending my time installing software and learning the ins and outs of configuring all the different pieces required to make this new machine a true home theater PC. I’ll share what I’ve learned in subsequent posts, so stay tuned.

Computers htpc

Run Coverage.py under PyCharm

July 18, 2010 Dale Leave a Comment

PyCharm‘s test runner does not currently support running Ned Batchelder’s excellent Python code coverage tool coverage.py. While this may be addressed before final release, you can easily set up a run/debug configuration manually to get the same effect. From within PyCharm, select the Run -> Edition Configurations menu item.

Coverage.py Configuration

Coverage.py Configuration

In the Run/Debug Configurations dialog, click the box with the plus sign in the upper right corner to create a new Python script configuration. Call the configuration whatever you want. I tend to run coverage.py as part of nose, so I enter the path to the nosetests-script.py on my file system in the Script field. Under Windows, this will be in the Scripts sub-directory of your Python installation directory. If you’re on Linux or OSX, you can use the nose/core.py file in your site-packages folder.

In the Script parameters field, I enter the --with-coverage and --cover-package command line parameters. Finally, in the Working directory field, I add the path to the directory containing my unit tests. Running this configuration executes code coverage on my unit test directory, and PyCharm is smart enough to recognize any stack traces that may occur during the run, providing click-able links to the offending lines of code.

Programming PyCharm, Python, tools, unit tests

« Previous Page
Next Page »

About Me

Hi, my name's Dale, and this is my tech blog. Read More…

Search

Tags

blogging c# database Django documentation Email furniture git hacks htpc IPython Linux mac nas packaging PyCharm Python Roleplaying tools twitter unit tests virtualenv Visual Studio vmware Windows

Copyright © 2025 · Equilibre Theme on Genesis Framework · WordPress · Log in