I'm not exactly sure what you are asking here, but one problem that is
notable in your example is that the center function is indented inside the
__init__ function. This would create a closure instead of a method on
PositionWindow, which is probably not what you want.
-Zac
On Sun, Jan 9, 2011
This should help:
http://docs.python.org/library/pickle.html
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer
Zindagi Games
On Sat, Aug 14, 2010 at 5:13 PM, kj no.em...@please.post wrote:
In af7fdb85-8c87-434e-94f3-18d8729bf...@l25g2000prn.googlegroups.com
Raymond Hettinger
Is there a utility to extract the stacks from a running python program that
is hung?
Sounds like a long shot but if anyone knows it would be you guys.
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer
Zindagi Games
--
http://mail.python.org/mailman/listinfo/python-list
')
1.4162585386092708
timeit.timeit('dict()', 'from threading import Lock')
0.2730348901369162
timeit.timeit('list()', 'from threading import Lock')
0.1719480219512306
-Zac
On Fri, Jul 2, 2010 at 1:26 PM, Antoine Pitrou solip...@pitrou.net wrote:
On Mon, 28 Jun 2010 16:46:41 -0700
Zac Burns zac
In my experience it is far more expensive to allocate a lock in python then
it is the types that use them. Here are some examples:
timeit.timeit('Lock()', 'from threading import Lock')
1.4449114807669048
timeit.timeit('dict()')
0.2821554294221187
timeit.timeit('list()')
0.17358153222312467
Sure, but I think you're timing the wrong thing here. You would only
allocate the lock relatively rarely - it's the overhead of *acquiring*
the lock that's the real problem.
r...@durian:~$ python -m timeit -s from threading import Lock; l =
Lock() l.acquire(); l.release()
100
In the threading module there are several code bits following this
convention:
###
def Class(*args, **kwargs):
return _Class(*args, **kwargs)
class _Class(...
###
This is true for Event, RLock, and others.
Why do this? It seems to violate the rule of least astonishment
(isinstance(Event(),
Why can't I inherit from traceback to 'spoof' tracebacks? I would like to
create a traceback that is save-able to re-raise exceptions later without
leaking all the locals. (I'm sure this idea has been discussed before but I
can't find it anymore.)
class Traceback(types.TracebackType): pass
Except you can't re-raise them.
Yes, I should have noted that in the original post:
raise RuntimeError, 'X', wrapped_traceback
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: raise: arg 3 must be a traceback or None
Does someone know where the thread went about
http://www.ristorantealpirata.com/home.php
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer
Zindagi Games
--
http://mail.python.org/mailman/listinfo/python-list
Yes, please do not remove me. Sorry for the inconvenience!
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer
Zindagi Games
On Tue, Apr 20, 2010 at 3:36 PM, Chris Kaynor ckay...@zindagigames.comwrote:
There was a G-mail invasion earlier today that allowed e-mails to be sent
On Tue, Dec 22, 2009 at 8:56 AM, John j...@nurfuerspam.de wrote:
another thread can remove the key prior to the has_key call; or perhaps
edges isn't a real dictionary?
of course. But unless there is a way of using threading without being aware
of
it, this is not the case. Also, edges
Greetings,
I'm trying to re-purpose the lib2to3 module and along the way came up with
this pattern:
funcdef'def' name=NAME parameters ['-' test] ':' suite=suite
It seems to have 2 problems:
1. Single-line defs are not matched. Eg: def singleLineFunc(): return 1
+ 2 is not matched, but
On Tue, Dec 22, 2009 at 3:21 PM, Benjamin Peterson benja...@python.orgwrote:
The pattern for that is funcdef 'def' 'singleLineFunc' parameters '(' ')'
':' simple_stmt return_stmt 'return' arith_expr '1' '+' '2' '\n'
. No
suite.
I'm trying to match any function block, the two examples
I've overloaded __import__ to modify modules after they are
imported... but running dir(module) on the result only returns
__builtins__, __doc__, __file__,
__name__, __package__, and __path__.
Why is this? More importantly, where can I hook in that would allow me
to see the contents of the
On Tue, Nov 10, 2009 at 2:27 PM, Benjamin Peterson benja...@python.org wrote:
Zac Burns zac256 at gmail.com writes:
What can I do about this?
Not run it in a thread.
--
http://mail.python.org/mailman/listinfo/python-list
Isn't requesting that pickle not be used in a thread a bit
Using python 2.6
cPickle.dumps has an import which is causing my application to hang.
(figured out by overriding builtin.__import__ with a print and seeing
that this is the last line of code being run. I'm running
cPickle.dumps in a thread, which leads me to believe that the first
restriction
Oh, I'm pickling an NotImplementedError and it's importing exceptions.
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Tue, Nov 10, 2009 at 10:50 AM, Zac Burns zac...@gmail.com wrote:
Using python 2.6
cPickle.dumps has an import which
Using the assertNotEqual method of UnitTest (synonym for failIfEqual)
only checks if first == second, but does not include not (first !=
second)
According to the docs:
http://docs.python.org/reference/datamodel.html#specialnames
There are no implied relationships among the comparison operators.
I was with you right up to the last six words.
Whether it's worth changing assertNotEqual to be something other than an
alias of failIfEqual is an interesting question. Currently all the
assert* and fail* variants are aliases of each other, which is easy to
learn. This would introduce a
There are 10741 occurences of ): or :( in our source code and only 2
occurrences of :) or (:. Not what you would expect from a language
named after a comedian.
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
--
I have a class called Signal which is a descriptor. It is a descriptor
so that it can create BoundSignals, much like the way methods work.
What I would like to do is to have the class be a descriptor when
instantiated in what will be the locals of the class, but not a
descriptor everywhere else.
Currently it is possible to import a file of one path to more than one
'instance' of a module. One notable example is import __init__ from
a package. See
http://stackoverflow.com/questions/436497/python-import-the-containing-package
This recently caused a devastating bug in some of my code. What
On Thu, Sep 24, 2009 at 1:38 PM, Carl Banks pavlovevide...@gmail.com wrote:
On Sep 24, 10:26 am, Zac Burns zac...@gmail.com wrote:
Currently it is possible to import a file of one path to more than one
'instance' of a module. One notable example is import __init__ from
a package.
Seehttp
The mysocket.mysend method given at
http://docs.python.org/howto/sockets.html has an (unwitting?) O(N**2)
complexity for long msg due to the string slicing.
I've been looking for a way to optimize this, but aside from a pure
python 'string slice view' that looks at the original string I can't
On Mon, Sep 21, 2009 at 2:10 PM, Rob Williscroft r...@freenet.co.uk wrote:
wrote in news:mailman.216.1253565002.2807.python-l...@python.org in
comp.lang.python:
Niether of the CPython versions (2.5 and 3.0 (with modified code))
exibited any memory increase between allocated 1 meg + and end
On Wed, Sep 9, 2009 at 6:52 PM, David Stanek dsta...@dstanek.com wrote:
On Wed, Sep 9, 2009 at 4:28 PM, Zac Burnszac...@gmail.com wrote:
How would you suggest to figure out what is the problem?
I don't think you said your OS so I'll assume Linux.
Sometimes it is more noise than value, but
I have a server running Python 2.6x64 which after running for about a
month decides to lock up and become unresponsive to all threads for
several minutes at a time. While it is locked up Python proceeds to
consume large amounts of continually increasing memory.
The basic function of the server is
If it has been running continuously all that time then it might be that
the dictionary has grown too big (is that possible?) or that it's a
memory fragmentation problem. In the latter case it might be an idea to
restart Python every so often; perhaps it could do that automatically
during a
As I understand it, the double underscores is to create a namespace
reserved for python's internal use. That way python can add more
variables and methods in the future and as long as people respect the
namespace their code will not break with future revisions.
--
Zachary Burns
(407)590-4814
Aim
Greetings,
I would like a set like object that when iterated maintains a count of
where iteration stopped and then re-orders itself based on that count
so that the iteration stopped on the most bubble to the top.
An example use case for this would be for something like a large table
of regular
I have a large pickle file, which happens to be a list with lots of
objects in it.
What sort of things can I do without unpickling the whole object?
I would particularly like to retrieve one of the elements in the list
without unpicking the whole object.
If the answer is not specific to lists
Where do you get this beta? I heard that Psyco V2 is coming out but
can't find anything on their site to support this.
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Sat, Jul 4, 2009 at 5:26 AM, larudwerlarud...@freenet.de wrote:
just out
I think I have figured this out, thanks for your input.
The time comes from lazy modules related to e-mail importing on
attribute access, which is acceptable. Hence of course
why ImportError was sometime raised.
I originally was thinking that accessing __file__ was triggering some
mechanism that
The section of code below, which simply gets the __file__ attribute of
the imported modules, takes more than 1/3 of the total startup time.
Given that many modules are complicated and even have dynamic
population this figure seems very high to me. it would seem very high
if one just considered the
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Thu, Jun 4, 2009 at 6:24 PM, Zac Burns zac...@gmail.com wrote:
The section of code below, which simply gets the __file__ attribute of
the imported modules, takes more than 1/3 of the total
It seems that one cannot start a thread in an atexit callback.
My use case is that I have a IO heavy callback that I want to run in a
thread so that other callbacks can finish while it's doing it's thing
to save on exit time.
Example code (py3k)
I would like to know when my function is called whether or not the
return value is used. Is this doable in python? If it is, can it ever
be pythonic?
The use case is that I have functions who's side effects and return
values are cached. I would like to optimize them such that I don't
have to
On Wed, Apr 29, 2009 at 10:14 AM, Simon Brunning
si...@brunningonline.net wrote:
2009/4/29 Zac Burns zac...@gmail.com:
Why not return a proxy, and have the proxy do the retrieval of the
needed data if it's used? Delegation is ridiculously easy in Python.
Interesting idea. I like it.
I've
The point of caching is that it lets you retrieve a result cheaply that
was expensive to produce by saving the result in case it's needed again.
If the caching itself is expensive because it requires network access
then, IMHO, that's not proper caching! (You would need a 2-level cache,
ie a
Is it really worth it to not implement list.clear and answer this
question over and over again?
I see no reason that a list shouldn't have a .clear method.
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Thu, Apr 2, 2009 at 5:32 PM, Esmail
The first line: doLoad = False, is to be ignored.
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Thu, Jan 15, 2009 at 10:30 AM, Zac Burns zac...@gmail.com wrote:
I'm not sure I fully understand the question no moving the code
I'm not sure I fully understand the question no moving the code to a
function, but you can prevent reload in a module by doing something
like this:
doLoad = False
try:
no_reload
except NameError:
no_reload = True
else:
raise RuntimeError, This module is not meant to be reloaded.
--
Zachary
and
Module.py contained support code for the package.
-Zac
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Tue, Jan 6, 2009 at 4:57 PM, Gabriel Genellina
gagsl-...@yahoo.com.ar wrote:
En Mon, 05 Jan 2009 23:04:30 -0200, Zac Burns zac...@gmail.com
I have a decorator in a class to be used by that class and by inheriting classes
##
class C(object):
@staticmethod # With this line enabled or disabled usage in either C
or D will be broken. To see that D works remember to remove usage in C
def decorateTest(func):
- Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Thu, Jan 8, 2009 at 10:54 AM, Zac Burns zac...@gmail.com wrote:
I have a decorator in a class to be used by that class and by inheriting
classes
##
class C(object):
@staticmethod # With this line enabled or disabled
wrote:
On Jan 8, 12:27 pm, Zac Burns zac...@gmail.com wrote:
Thanks for your patience waiting for me to isolate the problem.
| Package
--__init__.py -empty
--Package.py -empty
--Module.py
import cPickle
class C(object):
pass
def fail():
return cPickle.dumps
bdesth.quelquech...@free.quelquepart.fr wrote:
Jonathan Gardner a écrit :
On Jan 8, 11:18 am, Zac Burns zac...@gmail.com wrote:
In my use case (not the example below) the decorator returns a
function of the form def f(self, *args, **kwargs) which makes use of
attributes on the instance self
Greetings,
I have a module that attempts to pickle classes defined in that module.
I get an error of the form:
PicklingError: Can't pickle class 'Module.SubModule.Class': import
of module Module.SubModule failed
when using cPickle (protocol -1, python version 2.5.1).
The module has already been
The class method seems to be the most promising, however I have more
'state' methods to worry about so I might end up building new classes
on the fly rather than have a class per permutation of states! Now the
code isn't quite as clear as I thought it was going to be.
It seems unfortunate to me
:
Zac Burns [EMAIL PROTECTED] writes:
The class method seems to be the most promising, however I have more
'state' methods to worry about so I might end up building new classes
on the fly rather than have a class per permutation of states! Now the
code isn't quite as clear as I thought
Ok. Feature request then - assignment of a special method name to an
instance raises an error.
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Thu, Dec 4, 2008 at 10:13 AM, George Sakkis [EMAIL PROTECTED] wrote:
On Dec 4, 1:03 pm, Zac
There is a problem with this however, which prompted me to actually
write an unzip function.
One might expect to be able to do something like so (pseudocode)...
def filesAndAttributes():
files = walk()
attributes = [attr(f) for f in files]
return zip(files, attributes)
files,
Sorry for the long subject.
I'm trying to create a subclass dictionary that runs extra init code
on the first __getitem__ call. However, the performance of __getitem__
is quite important - so I'm trying in the subclassed __getitem__
method to first run some code and then patch in the original
More succinct failure:
keys, values = zip(*{}.iteritems())
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
On Tue, Dec 2, 2008 at 4:47 PM, Zac Burns [EMAIL PROTECTED] wrote:
There is a problem with this however, which prompted me to actually
Greetings,
It seems that marshal.load will lock the problem if the file object
(in this case a pipe) is not ready to be read from - even if it's done
in a thread.
The use case here is in writing a scripting interface for perforce
using the -G option
Greetings,
I have a dictionary that seems to be misbehaving on a membership
check. This test code:
1: import types
2: assert myDict.__class__ is types.DictionaryType
3: assert (key in myDict.keys()) == (key in myDict)
raises AssertionError on line three. The dictionary items are all of
type
an equivalency check of some sort (I don't know the C code, this is an
educated guess) without ever hashing so it succeeded.
--
Zachary Burns
Aim - Zac256FL
Production Engineer
Zindagi Games
On Wed, Nov 5, 2008 at 11:34 AM, Zac Burns [EMAIL PROTECTED] wrote:
Greetings,
I have a dictionary
58 matches
Mail list logo