I'd like to write a Fork class to wrap os.fork that allows something like this:
with Fork():
# to child stuff, end of block will automatically os._exit()
# parent stuff goes here
This would require (I think) that the __enter__ method of my Fork
class to be able to return a value or raise an exc
> Python doesn't have memory leaks.
Yeah, interesting bit of trivia: python is the world's only non-trivial
program that's totally free of bugs. Pretty exciting! But seriously,
python 2.4, at least, does have some pretty trivially exposed memory leaks
when working with strings. A simple example
I'm not sure what a visual object is, but to create an instance of an
object whose name is known, you can use "eval":
>>> oname = 'list'
>>> obj = eval(oname)()
>>> obj
[]
>>> type(obj)
Hope that helps!
On 26/07/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I'm trying to generate visual p
Python enters some sort of infinite loop when attempting to read data from a
malformed file that is big5 encoded (using the codecs library). This
behaviour can be observed under Linux and FreeBSD, using Python 2.4 and 2.5.
A really simple example illustrating the bug follows:
Python 2.4.4 (#1, M
and b.py has some method (let's call it d) within it. I can, from python,
do:
That should be c.py, of course.
Is this message getting no replies because it's confusing, it's poorly
worded, it's a dumb question, or is it just that nobody knows the answer?
I'm stuck on this, so any suggestions
Supposing that I have a directory tree like so:
a/
__init__.py
b/
__init__.py
c.py
and b.py has some method (let's call it d) within it. I can, from python, do:
from a.b.c import d
d()
And, that works. Now, suppose I want to have a zipped module under a,
called b.zip. Is there any
Agreed. This would be similar to:
py> 1 + 1.0
Traceback: can only add int to int. Etc.
But then again, the unimaginative defense would be that it wouldn't be
python if you could catentate a list and a tuple.
Of course, that behaviour would be quite defensible; auto-casting int to
float is _w
I remember something about it coming up in some of the discussions of
free lists and better behavior in this regard in 2.5, but I don't
remember the details.
Under Python 2.5, my original code posting no longer exhibits the bug - upon
calling del(a), python's size shrinks back to ~4 MB, which i
My first thought was that interned strings were causing the growth,
but that doesn't seem to be the case.
Interned strings, as of 2.3, are no longer immortal, right? The intern doc
says you have to keep a reference around to the string now, anyhow. I
really wish I could find that thing I read
$ python
Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # Python is using 2.7 MiB
... a = ['1234' for i in xrange(10 << 20)]
>>> # Python is using 42.9 MiB
..
I just tried on my system
(Python is using 2.9 MiB)
>>> a = ['a' * (1 << 20) for i in xrange(300)]
(Python is using 304.1 MiB)
>>> del a
(Python is using 2.9 MiB -- as before)
And I didn't even need to tell the garbage collector to do its job. Some
info:
It looks like the big difference betwe
After reading
http://www.python.org/doc/faq/general/#how-does-python-manage-memory, I
tried modifying this program as below:
a=[]
for i in xrange(33,127):
for j in xrange(33,127):
for k in xrange(33,127):
for l in xrange(33, 127):
a.append(chr(i)+chr(j)+chr(k)+chr(l))
import sys
sys
I have a pair of python programs that parse and index files on my computer
to make them searchable. The problem that I have is that they continually
grow until my system is out of memory, and then things get ugly. I
remember, when I was first learning python, reading that the python
interpreter
13 matches
Mail list logo