Skip to content

Instantly share code, notes, and snippets.

View vsajip's full-sized avatar

Vinay Sajip vsajip

View GitHub Profile
@vsajip
vsajip / mptest2.py
Created February 10, 2011 08:25
Example of multiprocessing and logging where main process uses a thread
#!/usr/bin/env python
# Copyright (C) 2011 Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
# of the software without specific, written prior permission.
Index: Doc/library/logging.handlers.rst
===================================================================
--- Doc/library/logging.handlers.rst (revision 88415)
+++ Doc/library/logging.handlers.rst (working copy)
@@ -332,6 +332,27 @@
partial sends which can happen when the network is busy.
+ .. method:: createSocket()
+
@vsajip
vsajip / gist:845082
Created February 26, 2011 09:52
Example bbreport output
$ python bbreport.py -b 3.x
Selected builders: 22 / 213 (branch: 3.x)
3.x.dmg 88574, 88544, 88532, 88500
AMD64 Gentoo Wide 3.x *** , 88639, 88636, 88633
AMD64 Leopard 3.x *** , 88636, 88633, 88632
857 88636: # 1 failed: test_os
856 88633: # 2 failed: test_logging test_os
855 88632: # 2 failed: test_logging test_os
AMD64 OpenIndiana 3.x *** , 88627, 88625, 88622
642 88627: # 2 failed: test_gdb test_os
@vsajip
vsajip / pmv.py
Created March 29, 2011 22:38
Poor man's virtualize.py
# Copyright (C) 2011 Vinay Sajip.
#
# Poor man's virtualize.py.
#
# Use with a Python executable built from the Python fork at
#
# https://bitbucket.org/vinay.sajip/pythonv/ as follows:
#
# python pmv.py env_dir
#
@vsajip
vsajip / sysconf.py
Created March 31, 2011 17:33
Prints useful system configuration information for Python.
from distutils.sysconfig import get_python_inc, get_python_lib, get_makefile_filename
import os
import sys
import sysconfig
def title(s):
print('-'*len(s))
print(s)
print('-'*len(s))
# Copyright (C) 2011 Vinay Sajip.
#
# Poor man's virtualize.py.
#
# Use with a Python executable built from the Python fork at
#
# https://bitbucket.org/vinay.sajip/pythonv/ as follows:
#
# python -m virtualize env_dir
#
from cStringIO import StringIO
import gnupg
import logging
import os
import shutil
def generate_key(gpg, first_name, last_name, domain, passphrase=None):
"Generate a key"
params = {
'Key-Type': 'DSA',
@vsajip
vsajip / test-py27.log
Created April 16, 2011 09:41
simplejson 2.1.4 test results on Python 3.2
running test
running egg_info
writing simplejson.egg-info/PKG-INFO
writing top-level names to simplejson.egg-info/top_level.txt
writing dependency_links to simplejson.egg-info/dependency_links.txt
reading manifest file 'simplejson.egg-info/SOURCES.txt'
writing manifest file 'simplejson.egg-info/SOURCES.txt'
running build_ext
test_circular_composite (simplejson.tests.test_check_circular.TestCheckCircular) ... ok
test_circular_default (simplejson.tests.test_check_circular.TestCheckCircular) ... ok
@vsajip
vsajip / test_results.txt
Created April 17, 2011 10:32
Time stdlib json against simplejson
Python 2.7
==========
Python version: 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2]
11.21484375 KiB read
Timing simplejson:
0.271898984909
Timing stdlib json:
0.338716030121
@vsajip
vsajip / test_results.txt
Created April 18, 2011 00:08
Time stdlib json versus simplejson on Python 3.2 with and without speedups
Python 3.2 numbers
==================
(jst3)vinay@eta-natty:~/projects/scratch$ python time_json.py --no-speedups
Python version: 3.2 (r32:88445, Mar 25 2011, 19:28:28)
[GCC 4.5.2]
11.21484375 KiB read
Timing simplejson (without speedups):
4.585145950317383
Timing stdlib json (without speedups):
3.9949100017547607