|
1 | 1 | #!/usr/bin/env python
|
| 2 | + |
2 | 3 | '''
|
3 | 4 | This illustrates a leak that occurs with any interactive backend.
|
4 | 5 | Run with :
|
|
13 | 14 | You may need to edit cbook.report_memory to support your platform
|
14 | 15 |
|
15 | 16 | '''
|
| 17 | +from __future__ import print_function |
16 | 18 | import os, sys, time
|
17 | 19 | import gc
|
18 | 20 | from optparse import OptionParser
|
|
48 | 50 | import pylab
|
49 | 51 | import matplotlib.cbook as cbook
|
50 | 52 |
|
51 |
| -print '# columns are: iteration, OS memory (k), number of python objects' |
52 |
| -print '#' |
| 53 | +print('# columns are: iteration, OS memory (k), number of python objects') |
| 54 | +print('#') |
53 | 55 | for i in range(indEnd+1):
|
54 | 56 |
|
55 | 57 | fig = pylab.figure()
|
|
68 | 70 | gc.collect()
|
69 | 71 | end = val
|
70 | 72 |
|
71 |
| -print '# columns above are: iteration, OS memory (k), number of python objects' |
72 |
| -print '#' |
73 |
| -print '# uncollectable list:', gc.garbage |
74 |
| -print '#' |
| 73 | +print('# columns above are: iteration, OS memory (k), number of python objects') |
| 74 | +print('#') |
| 75 | +print('# uncollectable list:', gc.garbage) |
| 76 | +print('#') |
75 | 77 |
|
76 | 78 | if i > indStart:
|
77 |
| - print '# Backend %(backend)s, toolbar %(toolbar)s' % matplotlib.rcParams |
| 79 | + print('# Backend %(backend)s, toolbar %(toolbar)s' % matplotlib.rcParams) |
78 | 80 | backend = options.backend.lower()
|
79 | 81 | if backend.startswith("gtk"):
|
80 | 82 | import gtk
|
81 | 83 | import gobject
|
82 |
| - print "# pygtk version: %s, gtk version: %s, pygobject version: %s, glib version: %s" % \ |
83 |
| - (gtk.pygtk_version, gtk.gtk_version, |
84 |
| - gobject.pygobject_version, gobject.glib_version) |
| 84 | + print("# pygtk version: %s, gtk version: %s, pygobject version: %s, glib version: %s" % \ |
| 85 | + (gtk.pygtk_version, gtk.gtk_version, |
| 86 | + gobject.pygobject_version, gobject.glib_version)) |
85 | 87 | elif backend.startswith("qt4"):
|
86 | 88 | import PyQt4.pyqtconfig
|
87 |
| - print "# PyQt4 version: %s, Qt version %x" % \ |
| 89 | + print("# PyQt4 version: %s, Qt version %x" % \ |
88 | 90 | (PyQt4.pyqtconfig.Configuration().pyqt_version_str,
|
89 |
| - PyQt4.pyqtconfig.Configuration().qt_version) |
| 91 | + PyQt4.pyqtconfig.Configuration().qt_version)) |
90 | 92 | elif backend.startswith("qt"):
|
91 | 93 | import pyqtconfig
|
92 |
| - print "# pyqt version: %s, qt version: %x" % \ |
| 94 | + print("# pyqt version: %s, qt version: %x" % \ |
93 | 95 | (pyqtconfig.Configuration().pyqt_version_str,
|
94 |
| - pyqtconfig.Configuration().qt_version) |
| 96 | + pyqtconfig.Configuration().qt_version)) |
95 | 97 | elif backend.startswith("wx"):
|
96 | 98 | import wx
|
97 |
| - print "# wxPython version: %s" % wx.__version__ |
| 99 | + print("# wxPython version: %s" % wx.__version__) |
98 | 100 | elif backend.startswith("tk"):
|
99 | 101 | import Tkinter
|
100 |
| - print "# Tkinter version: %s, Tk version: %s, Tcl version: %s" % (Tkinter.__version__, Tkinter.TkVersion, Tkinter.TclVersion) |
| 102 | + print("# Tkinter version: %s, Tk version: %s, Tcl version: %s" % (Tkinter.__version__, Tkinter.TkVersion, Tkinter.TclVersion)) |
101 | 103 |
|
102 |
| - print '# Averaging over loops %d to %d' % (indStart, indEnd) |
103 |
| - print '# Memory went from %dk to %dk' % (start, end) |
104 |
| - print '# Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart)) |
| 104 | + print('# Averaging over loops %d to %d' % (indStart, indEnd)) |
| 105 | + print('# Memory went from %dk to %dk' % (start, end)) |
| 106 | + print('# Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))) |
105 | 107 |
|
106 | 108 | if options.cycles:
|
107 | 109 | cbook.print_cycles(gc.garbage)
|
0 commit comments