Tuesday 5 February 2013

Removing .pyc Files: A Coda

A few days ago, I wrote a blog post detailing a git hook that would automatically remove .pyc files when checking out a different branch. I received a variety of feedback, which I will outline here.

Firstly, +Jeff Mahoney provided a more efficient implementation of the git hook in a comment on the original post. I haven't tested this, but it might provide a more efficient implementation if you need it.

Secondly, there are a number of helpful comments on the reddit post, including a fine-tuned git/xargs command.

Finally, and most importantly, a number of people (both in the blog comments and on reddit) pointed out the PYTHONDONTWRITEBYTECODE environment variable.  Setting this to anything will mean that Python doesn't generate .pyc or .pyo files, completely circumventing the problem that I was trying to solve.

7 comments:

  1. So what about the performance penalty of not having pyc files?

    ReplyDelete
    Replies
    1. This is purely for development purposes; I would absolutely not suggest using PYTHONDONTWRITEBYTECODE in production.

      And having said that, our test run (of a little more than 2 minutes) demonstrates no run-time difference with the environment variable set, so I suspect you're unlikely to notice.

      Delete
    2. There shouldn't be a runtime difference, as far as I understand it. The python runtime generates the bytecode if a .pyc doesn't exist, so the end result is the same (with a small startup delay)

      Delete
    3. Then it's ok for development, very handy the tip btw, I'll use it in my repos.

      Delete
  2. FWIW, Ubuntu provides a "pyclean" command. The command, at /usr/bin/pyclean, is the source code.

    ReplyDelete
  3. It is similar to Three Card Poker®, but with one main difference. In Three Card®, the play wager should equal the ante; in Four Card®, gamers could wager as much as} three times their ante when staying within the recreation. Three-Card Poker 먹튀프렌즈 is a fast-moving recreation that gives gamers 4 ways to win. To begin, each the gamers and the supplier are every dealt a three-card poker hand.

    ReplyDelete
  4. Additionally, the Live model has 1xbet a widget for a reside chat, which can to} let you get in contact with the supplier. From humble beginnings amongst Italian soldiers, the game was popularized by French the Aristocracy, finally spreading far and extensive. It now options prominently because the excessive curler card game of selection throughout Asia, Europe, and the Americas.

    ReplyDelete