title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,467,922 | <p>I have a hard time believing that any script without any prior knowledge of the data (unlike MySql which has such info pre-loaded), would be faster than a SQL approach.</p>
<p>Aside from the time spent parsing the input, the script needs to "keep" sorting the order by array etc...</p>
<p>The following is a first g... | 9 | 2009-09-23T18:50:07Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,468,019 | <p>Isn't this just as simple as </p>
<pre><code> SELECT DISTINCT aa, bb, cc FROM tablename ORDER BY bb DESC LIMIT 5
</code></pre>
<p>?</p>
<p>Of course, it's hard to tell what would be fastest without testing it against the data. And if this is something you need to run very fast, it might make sense to optimize yo... | 0 | 2009-09-23T19:09:24Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,468,030 | <p>This is a sketch in Common Lisp</p>
<p>Note that for long files there is a penalty for using READ-LINE, because it conses a fresh string for each line. Then use one of the derivatives of READ-LINE that are floating around that are using a line buffer. Also you might check if you want the hash table be case sensitiv... | 3 | 2009-09-23T19:12:02Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,468,087 | <p>Pick "top 5" would look something like this. Note that there's no sorting. Nor does any list in the top_5 dictionary ever grow beyond 5 elements.</p>
<pre><code>from collections import defaultdict
import sys
def keep_5( aList, aPair ):
minbb= min( bb for bb,cc in aList )
bb, cc = aPair
if bb < min... | -1 | 2009-09-23T19:23:02Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,468,626 | <p>Here is a C++ solution. I didn't have a lot of data to test it with, however, so I don't know how fast it actually is.</p>
<p>[edit] Thanks to the test data provided by the awk script in this thread, I
managed to clean up and speed up the code a bit. I am not trying to find out the fastest possible version - the in... | 1 | 2009-09-23T21:32:51Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,468,831 | <p>This took 45.7s on my machine with 27M rows of data that looked like this:</p>
<pre><code>42 0.49357 0
96 0.48075 1
27 0.640761 2
8 0.389128 3
75 0.395476 4
24 0.212069 5
80 0.121367 6
81 0.271959 7
91 0.18581 8
69 0.258922 9
</code></pre>
<p>Your script took 1m42 on this data, the c++ example too 1m46 (g++ t.cpp ... | 3 | 2009-09-23T22:19:09Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,469,267 | <p>Interestingly, the original Python solution is by far the cleanest <em>looking</em> (although the C++ example comes close). </p>
<p>How about using Pyrex or Psyco on your original code?</p>
| 1 | 2009-09-24T00:37:18Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,469,525 | <p>Of <em>all</em> the programs in this thread that I've tested so far, <strong>the OCaml version is the fastest</strong> and also among the <strong>shortest</strong>. (Line-of-code-based measurements are a little fuzzy, but it's not <em>clearly longer</em> than the Python version or the C or C++ versions, and it <em>i... | 2 | 2009-09-24T02:39:38Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,469,787 | <p>Has anybody tried doing this problem with just awk. Specifically 'mawk'? It should be faster than even Java and C++, according to this blog post: <a href="http://anyall.org/blog/2009/09/dont-mawk-awk-the-fastest-and-most-elegant-big-data-munging-language/" rel="nofollow">http://anyall.org/blog/2009/09/dont-mawk-awk-... | 1 | 2009-09-24T04:34:01Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,469,955 | <p>The Pig version would go something like this (untested):</p>
<pre><code> Data = LOAD '/my/data' using PigStorage() as (aa:int, bb:float, cc:chararray);
grp = GROUP Data by aa;
topK = FOREACH grp (
sorted = ORDER Data by bb DESC;
lim = LIMIT sorted 5;
GENERATE group as aa, lim;
)
STORE topK INTO '/m... | 0 | 2009-09-24T05:50:46Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,469,997 | <p>You could use smarter data structures and still use python.
I've ran your reference implementation and my python implementation on my machine and even compared the output to be sure in results.</p>
<p>This is yours:</p>
<pre><code>$ time python ./ref.py < data-large.txt > ref-large.txt
real 1m57.689s
user... | 6 | 2009-09-24T06:08:23Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,474,658 | <p>Since you asked about Matlab, here's how I did something like what you're asking for. I tried to do it without any for loops, but I do have one because I didn't care to take a long time with it. If you were worried about memory then you could pull data from the stream in chunks with fscanf rather than reading the ... | 1 | 2009-09-24T23:14:46Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,477,216 | <p>Pretty straightforward Caml (27 * 10^6 rows -- 27 sec, C++ by hrnt -- 29 sec)</p>
<pre><code>open Printf
open ExtLib
let (>>) x f = f x
let cmp x y = compare (fst x : float) (fst y)
let wsp = Str.regexp "[ \t]+"
let () =
let all = Hashtbl.create 1024 in
Std.input_lines stdin >> Enum.iter (fun line... | 2 | 2009-09-25T13:12:46Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,481,186 | <p>That was a nice lunch break challenge, he, he.</p>
<p>Top-N is a well-known database killer. As shown by the post above, there is no way to efficiently express it in common SQL.</p>
<p>As for the various implementations, you got to keep in mind that the slow part in this is not the sorting or the top-N, it's the p... | 0 | 2009-09-26T13:19:37Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,484,752 | <p>Well, please grab a coffee and read the source code for strtod -- it's mindboggling, but needed, if you want to float -> text -> float to give back the same float you started with.... really...</p>
<p>Parsing integers is a lot faster (not so much in python, though, but in C, yes).</p>
<p>Anyway, putting the data i... | 0 | 2009-09-27T23:21:10Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,486,887 | <p>I love lunch break challenges. Here's a 1 hour implementation.</p>
<p>OK, when you don't want do some extremely exotic crap like additions, nothing stops you from using a custom base-10 floating point format whose only implemented operator is comparison, right ? lol.</p>
<p>I had some fast-atoi code lying around f... | 0 | 2009-09-28T12:58:42Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,497,938 | <p>Speaking of lower bounds on compute time :</p>
<p>Let's analyze my algo above :</p>
<pre><code>for each row (key,score,id) :
create or fetch a list of top scores for the row's key
if len( this list ) < N
append current
else if current score > minimum score in list
replace minimum ... | 1 | 2009-09-30T12:58:14Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
What language could I use for fast execution of this database summarization task? | 1,467,898 | <p>So I wrote a Python program to handle a little data processing
task.</p>
<p>Here's a very brief specification in a made-up language of the computation I want:</p>
<pre><code>parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
</code></pre>
<p>That is, ... | 9 | 2009-09-23T18:45:07Z | 1,502,932 | <p>Here is one more OCaml version - targeted for speed - with custom parser on Streams. Too long, but parts of the parser are reusable. Thanks <strong>peufeu</strong> for triggering competition :)</p>
<p>Speed :</p>
<ul>
<li>simple ocaml - 27 sec</li>
<li>ocaml with Stream parser - 15 sec</li>
<li>c with manual parse... | 3 | 2009-10-01T09:40:44Z | [
"python",
"sql",
"lisp",
"ocaml",
"apache-pig"
] |
How does this work? | 1,467,902 | <p>So I'm trying to comprehend the source file for csv2rec in matplotlib.mlab. It is used to take a csv file and parse the data into certain formats. So it may take a string '234' and convert it to int. or take a date string and make it into python datetimes. </p>
<pre><code>def get_converters(reader):
conver... | 0 | 2009-09-23T18:45:52Z | 1,467,916 | <p>Unless I'm missing something, on the first iteration "i" is 0, so the following is executed:</p>
<pre><code>converters = [mybool]*len(row)
</code></pre>
<p>and that initializes "converters"</p>
| 1 | 2009-09-23T18:48:55Z | [
"python",
"function",
"matplotlib"
] |
How does this work? | 1,467,902 | <p>So I'm trying to comprehend the source file for csv2rec in matplotlib.mlab. It is used to take a csv file and parse the data into certain formats. So it may take a string '234' and convert it to int. or take a date string and make it into python datetimes. </p>
<pre><code>def get_converters(reader):
conver... | 0 | 2009-09-23T18:45:52Z | 1,467,924 | <p>Converters gets set again at the beginning of the loop with</p>
<pre><code>if i==0:
converters = [mybool]*len(row)
</code></pre>
<p>So after that it's not None anymore.</p>
| 2 | 2009-09-23T18:51:02Z | [
"python",
"function",
"matplotlib"
] |
How does this work? | 1,467,902 | <p>So I'm trying to comprehend the source file for csv2rec in matplotlib.mlab. It is used to take a csv file and parse the data into certain formats. So it may take a string '234' and convert it to int. or take a date string and make it into python datetimes. </p>
<pre><code>def get_converters(reader):
conver... | 0 | 2009-09-23T18:45:52Z | 1,468,122 | <p>First,</p>
<pre><code>converters = None
</code></pre>
<p>sets an initial value for <code>converters</code>. This way, if the iteration doesn't happen (because <code>readers</code> might be empty) then when the function returns <code>converters</code> it will exist and have the value <code>None</code>.</p>
<p>If ... | 1 | 2009-09-23T19:34:18Z | [
"python",
"function",
"matplotlib"
] |
python: how to get all members of an array except for ones that match a condition | 1,467,930 | <p>I'm trying to create an array of all .asm files I need to build <em>except</em> for one that is causing me trouble right now. Here's what I have, based on the Scons <a href="http://www.scons.org/doc/HTML/scons-user/a10760.html" rel="nofollow">"Handling Common Cases"</a> page:</p>
<pre><code>projfiles['buildasm'] = ... | 1 | 2009-09-23T18:51:54Z | 1,467,945 | <pre><code>projfiles['buildasm'] = ['#build/'+os.path.splitext(x)[0]+'.asm' for x in projfiles['a'] if x != 'baz.a']
</code></pre>
<p>or more generally:</p>
<pre><code>ignored_files = ['baz.a',
'foo.a',
'xyzzy.a',
]
projfiles['buildasm'] = ['#build/'+os.path.splitext... | 7 | 2009-09-23T18:53:58Z | [
"python"
] |
python win32 extensions documentation | 1,468,099 | <p>I'm new to both python and the python win32 extensions available at <a href="http://python.net/crew/skippy/win32/">http://python.net/crew/skippy/win32/</a> but I can't find any documentation online or in the installation directories concerning what exactly the win32 extensions provide. Where is this information?</p>... | 13 | 2009-09-23T19:27:17Z | 1,468,133 | <p>You'll find documentation here:
<a href="http://docs.activestate.com/activepython/2.4/pywin32/PyWin32.HTML">http://docs.activestate.com/activepython/2.4/pywin32/PyWin32.HTML</a></p>
<p>(Note: most of the API docs are under 'modules' and 'objects'. Note that the documentation is very sparse here but rembember: since... | 10 | 2009-09-23T19:35:59Z | [
"python",
"documentation",
"pywin32"
] |
python win32 extensions documentation | 1,468,099 | <p>I'm new to both python and the python win32 extensions available at <a href="http://python.net/crew/skippy/win32/">http://python.net/crew/skippy/win32/</a> but I can't find any documentation online or in the installation directories concerning what exactly the win32 extensions provide. Where is this information?</p>... | 13 | 2009-09-23T19:27:17Z | 1,468,190 | <p>In addition to ChristopheD's recommendations I also find that <a href="http://timgolden.me.uk/python/index.html" rel="nofollow">Tim Golden's Python Stuff</a> is very useful.</p>
<p>Good Luck,
Cutaway</p>
| 2 | 2009-09-23T19:49:02Z | [
"python",
"documentation",
"pywin32"
] |
python win32 extensions documentation | 1,468,099 | <p>I'm new to both python and the python win32 extensions available at <a href="http://python.net/crew/skippy/win32/">http://python.net/crew/skippy/win32/</a> but I can't find any documentation online or in the installation directories concerning what exactly the win32 extensions provide. Where is this information?</p>... | 13 | 2009-09-23T19:27:17Z | 1,468,275 | <p><a href="http://oreilly.com/catalog/9781565926219" rel="nofollow" title="Print ISBN: 978-1-56592-621-9 | ISBN 10: 1-56592-621-8">Python Programming On Win32</a> from O'Reilly is a great, if dated, book on the subject. I've read it and is very good.</p>
<p><a href="http://rads.stackoverflow.com/amzn/click/1565926218... | 0 | 2009-09-23T20:09:53Z | [
"python",
"documentation",
"pywin32"
] |
python win32 extensions documentation | 1,468,099 | <p>I'm new to both python and the python win32 extensions available at <a href="http://python.net/crew/skippy/win32/">http://python.net/crew/skippy/win32/</a> but I can't find any documentation online or in the installation directories concerning what exactly the win32 extensions provide. Where is this information?</p>... | 13 | 2009-09-23T19:27:17Z | 1,469,940 | <p>PyWin32 docs are included with <a href="http://www.activestate.com/activepython/" rel="nofollow">ActivePython</a> (which I highly recommend you to install). ChristopheD's link is for Python 2.4 which is an older version. For Python 2.6 version (which is the latest), <a href="http://downloads.activestate.com/ActivePy... | 2 | 2009-09-24T05:45:44Z | [
"python",
"documentation",
"pywin32"
] |
Python CreateFile Cannot Find PhysicalMemory | 1,468,130 | <p>I am trying to access the Physical Memory of a Windows 2000 system (trying to do this without a memory dumping tool). My understanding is that I need to do this using the CreateFile function to create a handle. I have used an older version of <a href="http://www.msuiche.net/2008/06/14/capture-memory-under-win2k3-o... | 0 | 2009-09-23T19:35:22Z | 1,468,792 | <p>I don't believe it's possible to access the physical memory object from user mode land in Windows. As your <a href="http://www.msuiche.net/2008/06/14/capture-memory-under-win2k3-or-vista-with-win32dd/" rel="nofollow">win32dd link</a> suggests, you will need to do it from kernel mode.</p>
| 0 | 2009-09-23T22:09:01Z | [
"python",
"memory",
"ctypes",
"createfile"
] |
Cross-platform help viewer with search functionality | 1,468,314 | <p>I am looking for a help viewer like Windows CHM that basically provides support for </p>
<ol>
<li>adding content in HTML format</li>
<li>define Table of Contents</li>
<li>decent search</li>
</ol>
<p>It should work on Windows, Mac and Linux. Bonus points for also having support for generating a "plain HTML/javascri... | 0 | 2009-09-23T20:20:40Z | 1,468,448 | <p><a href="http://docs.wxwidgets.org/stable/wx%5Fwxhtmlhelpcontroller.html#wxhtmlhelpcontroller" rel="nofollow">wxHtmlHelpController</a>, which is part of <a href="http://www.wxwidgets.org/" rel="nofollow">wxWidgets</a>, is a cross-platform viewer for HtmlHelp.</p>
<p>I'm not sure how easy it is to use it from a non-... | 2 | 2009-09-23T20:50:15Z | [
"python",
"documentation",
"cross-platform",
"chm"
] |
Cross-platform help viewer with search functionality | 1,468,314 | <p>I am looking for a help viewer like Windows CHM that basically provides support for </p>
<ol>
<li>adding content in HTML format</li>
<li>define Table of Contents</li>
<li>decent search</li>
</ol>
<p>It should work on Windows, Mac and Linux. Bonus points for also having support for generating a "plain HTML/javascri... | 0 | 2009-09-23T20:20:40Z | 1,809,732 | <p>wxHtmlHelpController doesn't support any scripting within pages, nor does it support css.</p>
| 1 | 2009-11-27T16:49:08Z | [
"python",
"documentation",
"cross-platform",
"chm"
] |
How to contribute improvements to packages hosted on Cheeseshop ( pypi )? | 1,468,476 | <p>I've been using zc.buildout more and more and I'm encountering problems with some recipes that I have solutions to.</p>
<p>These packages generally fall into several categories:</p>
<ol>
<li>Package with no obvious links to a project site</li>
<li>Package with links to free hosted service like github or google co... | 2 | 2009-09-23T20:55:40Z | 1,468,603 | <p>Your "upload my personalized fork" solution sounds like a terrible idea. You should try <a href="http://pypi.python.org/pypi/collective.recipe.patch" rel="nofollow">http://pypi.python.org/pypi/collective.recipe.patch</a> which lets you automatically patch eggs. Try <a href="http://stackoverflow.com/questions/557462/... | 3 | 2009-09-23T21:27:52Z | [
"python",
"collaboration",
"buildout",
"pypi"
] |
How do you turn an unquoted Python function/lambda into AST? 2.6 | 1,468,634 | <p>This seems like it should be easy, but I can't find the answer anywhere - nor able to derive one myself. How do you turn an unquoted python function/lambda into an AST? </p>
<p>Here is what I'd like to be able to do.</p>
<pre><code>import ast
class Walker(ast.NodeVisitor):
pass
# ...
# note, this doesnt... | 5 | 2009-09-23T21:34:07Z | 1,468,652 | <p>Your lambda expression is a function, which has lots of information, but I don't think it still has source code associated with. I'm not sure you can get what you want.</p>
| 0 | 2009-09-23T21:37:45Z | [
"python",
"abstract-syntax-tree"
] |
How do you turn an unquoted Python function/lambda into AST? 2.6 | 1,468,634 | <p>This seems like it should be easy, but I can't find the answer anywhere - nor able to derive one myself. How do you turn an unquoted python function/lambda into an AST? </p>
<p>Here is what I'd like to be able to do.</p>
<pre><code>import ast
class Walker(ast.NodeVisitor):
pass
# ...
# note, this doesnt... | 5 | 2009-09-23T21:34:07Z | 1,468,770 | <p>In general, you can't. For example, <code>2 + 2</code> is an expression -- but if you pass it to any function or method, the argument being passed is just the number <code>4</code>, no way to recover what expression it was computed from. Function source code can sometimes be recovered (though not for a <code>lambd... | 9 | 2009-09-23T22:03:27Z | [
"python",
"abstract-syntax-tree"
] |
How do you turn an unquoted Python function/lambda into AST? 2.6 | 1,468,634 | <p>This seems like it should be easy, but I can't find the answer anywhere - nor able to derive one myself. How do you turn an unquoted python function/lambda into an AST? </p>
<p>Here is what I'd like to be able to do.</p>
<pre><code>import ast
class Walker(ast.NodeVisitor):
pass
# ...
# note, this doesnt... | 5 | 2009-09-23T21:34:07Z | 1,469,053 | <p>You can't generate AST from compiled bytecode. You need the source code.</p>
| 1 | 2009-09-23T23:33:28Z | [
"python",
"abstract-syntax-tree"
] |
How do you turn an unquoted Python function/lambda into AST? 2.6 | 1,468,634 | <p>This seems like it should be easy, but I can't find the answer anywhere - nor able to derive one myself. How do you turn an unquoted python function/lambda into an AST? </p>
<p>Here is what I'd like to be able to do.</p>
<pre><code>import ast
class Walker(ast.NodeVisitor):
pass
# ...
# note, this doesnt... | 5 | 2009-09-23T21:34:07Z | 1,470,481 | <p>If you only get access to the function/lambda you only have the compiled python bytecode. The exact Python AST can't be reconstructed from the bytecode because there is information loss in the compilation process. But you can analyze the bytecode and create AST's for that. There is one such analyzer in GeniuSQL. I a... | 5 | 2009-09-24T08:52:11Z | [
"python",
"abstract-syntax-tree"
] |
How do you turn an unquoted Python function/lambda into AST? 2.6 | 1,468,634 | <p>This seems like it should be easy, but I can't find the answer anywhere - nor able to derive one myself. How do you turn an unquoted python function/lambda into an AST? </p>
<p>Here is what I'd like to be able to do.</p>
<pre><code>import ast
class Walker(ast.NodeVisitor):
pass
# ...
# note, this doesnt... | 5 | 2009-09-23T21:34:07Z | 12,204,014 | <p><a href="https://github.com/srossross/Meta" rel="nofollow">The Meta library</a> allows you to recover the source in many cases, with some exceptions such as comprehensions and lambdas.</p>
<pre><code>import meta, ast
source = '''
a = 1
b = 2
c = (a ** b)
'''
mod = ast.parse(source, '<nofile>', 'exec')
code =... | 4 | 2012-08-30T19:23:35Z | [
"python",
"abstract-syntax-tree"
] |
What networking libraries/frameworks exist for Python? | 1,468,780 | <p>I was wondering what good networking libraries/frameworks there are for Python.</p>
<p>Please provide a link to the standard API documentation for the library, and perhaps a link to a decent tutorial to get started with it.</p>
<p>A comment or two about its advantages/disadvantages would be nice as well.</p>
| 1 | 2009-09-23T22:06:21Z | 1,468,812 | <p><a href="http://twistedmatrix.com/" rel="nofollow">Twisted</a> is the most complete, and complex, of all Python networking frameworks.</p>
<p>It's well-established and very complete, but it has a steep learning curve.</p>
<p><a href="http://twistedmatrix.com/trac/wiki/Documentation" rel="nofollow">Documentation he... | 3 | 2009-09-23T22:12:26Z | [
"python",
"networking",
"frameworks"
] |
What networking libraries/frameworks exist for Python? | 1,468,780 | <p>I was wondering what good networking libraries/frameworks there are for Python.</p>
<p>Please provide a link to the standard API documentation for the library, and perhaps a link to a decent tutorial to get started with it.</p>
<p>A comment or two about its advantages/disadvantages would be nice as well.</p>
| 1 | 2009-09-23T22:06:21Z | 1,468,815 | <p>Consider the <a href="http://twistedmatrix.com/trac/" rel="nofollow">Twisted</a> framework. The advantage:</p>
<ul>
<li>solid reactor implementation</li>
<li>support for almost all network protocols found in the wild</li>
<li>well documented</li>
</ul>
<p>Disadvantages:</p>
<ul>
<li>it's <em>huge</em></li>
<li>th... | 4 | 2009-09-23T22:12:45Z | [
"python",
"networking",
"frameworks"
] |
What networking libraries/frameworks exist for Python? | 1,468,780 | <p>I was wondering what good networking libraries/frameworks there are for Python.</p>
<p>Please provide a link to the standard API documentation for the library, and perhaps a link to a decent tutorial to get started with it.</p>
<p>A comment or two about its advantages/disadvantages would be nice as well.</p>
| 1 | 2009-09-23T22:06:21Z | 1,468,816 | <p>The standard library has <a href="http://docs.python.org/library/asyncore.html">asyncore</a> which is good for very simple stuff as well as the <a href="http://docs.python.org/library/socketserver.html">SocketServer</a> stuff if you'd prefer something that does threads. There's also <a href="http://twistedmatrix.co... | 6 | 2009-09-23T22:14:07Z | [
"python",
"networking",
"frameworks"
] |
What networking libraries/frameworks exist for Python? | 1,468,780 | <p>I was wondering what good networking libraries/frameworks there are for Python.</p>
<p>Please provide a link to the standard API documentation for the library, and perhaps a link to a decent tutorial to get started with it.</p>
<p>A comment or two about its advantages/disadvantages would be nice as well.</p>
| 1 | 2009-09-23T22:06:21Z | 1,469,904 | <p>In case you want to build/manipulate your own packets there is Scapy too :)</p>
<p>The usage is pretty straight forward, it lets you do whatever you want with the packets
and it's multi-Platform.</p>
<p>Project Page: <a href="http://www.secdev.org/projects/scapy/" rel="nofollow">http://www.secdev.org/projects/scap... | 1 | 2009-09-24T05:35:36Z | [
"python",
"networking",
"frameworks"
] |
Python canvas suggestions | 1,469,286 | <p>I'm looking for a very simple canvas for python. What I really need is the ability to draw lines and circles, move them around / get rid of them, and scroll the canvas (so, I'm ideally drawing on an infinite canvas, and just scrolling it around). Ideally, the code would look like:</p>
<pre><code>c = Canvas()
l1 = c... | 1 | 2009-09-24T00:47:16Z | 1,469,299 | <p>I've used PyGame with a good deal of success for such things:</p>
<p><a href="http://www.pygame.org/" rel="nofollow">http://www.pygame.org/</a></p>
| 0 | 2009-09-24T00:50:28Z | [
"python",
"canvas"
] |
Python canvas suggestions | 1,469,286 | <p>I'm looking for a very simple canvas for python. What I really need is the ability to draw lines and circles, move them around / get rid of them, and scroll the canvas (so, I'm ideally drawing on an infinite canvas, and just scrolling it around). Ideally, the code would look like:</p>
<pre><code>c = Canvas()
l1 = c... | 1 | 2009-09-24T00:47:16Z | 1,469,305 | <p>You may want to look at this question:
<a href="http://stackoverflow.com/questions/67000/fast-pixel-precision-2d-drawing-api-for-graphics-app">http://stackoverflow.com/questions/67000/fast-pixel-precision-2d-drawing-api-for-graphics-app</a></p>
<p>The first suggestion is for pyglet, <a href="http://code.google.com/... | 0 | 2009-09-24T00:53:11Z | [
"python",
"canvas"
] |
Python canvas suggestions | 1,469,286 | <p>I'm looking for a very simple canvas for python. What I really need is the ability to draw lines and circles, move them around / get rid of them, and scroll the canvas (so, I'm ideally drawing on an infinite canvas, and just scrolling it around). Ideally, the code would look like:</p>
<pre><code>c = Canvas()
l1 = c... | 1 | 2009-09-24T00:47:16Z | 1,616,803 | <p>I ended up using WxPython with the built-in FloatCanvas. I wouldn't really advise it for anyone else, though; it depends on NumPy, which is a very big installation, and is almost completely undocumented (reading the sources was a big part of the app I programmed). It is, however, very nice and does a lot for you.</p... | 1 | 2009-10-24T03:05:48Z | [
"python",
"canvas"
] |
Why can't I import the 'math' library when embedding python in c? | 1,469,370 | <p>I'm using the example in python's 2.6 docs to begin a foray into embedding some python in C. The <a href="http://docs.python.org/extending/embedding.html#pure-embedding" rel="nofollow">example C-code</a> does not allow me to execute the following 1 line script:</p>
<pre><code>import math
</code></pre>
<p>Using li... | 2 | 2009-09-24T01:20:33Z | 1,469,445 | <p>I'm using Python 2.6, and I successfully compiled and ran that same example code that you listed, without changing anything in the source. </p>
<pre>
$ gcc python.c -I/usr/include/python2.6/ /usr/lib/libpython2.6.so
$ ./a.out random randint 1 100
Result of call: 39
$ ./a.out random randint 1 100
Result of call: 57... | 2 | 2009-09-24T01:53:31Z | [
"c++",
"python",
"c"
] |
Probability exercise returning different result that expected | 1,469,421 | <p>As an exercise I'm writing a program to calculate the odds of rolling 5 die with the same number. The idea is to get the result via simulation as opposed to simple math though. My program is this:</p>
<pre><code># rollFive.py
from random import *
def main():
n = input("Please enter the number of sims to run... | 2 | 2009-09-24T01:46:46Z | 1,469,443 | <p>The probability of getting a particular number five times is (1/6)^5, but the probability of getting any five numbers the same is (1/6)^4.</p>
<p>There are two ways to see this.</p>
<p>First, the probability of getting all 1's, for example, is (1/6)^5 since there is only one way out of six to get a 1. Multiply th... | 6 | 2009-09-24T01:52:56Z | [
"python",
"probability"
] |
Probability exercise returning different result that expected | 1,469,421 | <p>As an exercise I'm writing a program to calculate the odds of rolling 5 die with the same number. The idea is to get the result via simulation as opposed to simple math though. My program is this:</p>
<pre><code># rollFive.py
from random import *
def main():
n = input("Please enter the number of sims to run... | 2 | 2009-09-24T01:46:46Z | 1,469,446 | <p>Your math is wrong. The probability of getting five dice with the same number is <code>6*(1/6)^5 = 0.0007716</code>.</p>
| 1 | 2009-09-24T01:53:33Z | [
"python",
"probability"
] |
Probability exercise returning different result that expected | 1,469,421 | <p>As an exercise I'm writing a program to calculate the odds of rolling 5 die with the same number. The idea is to get the result via simulation as opposed to simple math though. My program is this:</p>
<pre><code># rollFive.py
from random import *
def main():
n = input("Please enter the number of sims to run... | 2 | 2009-09-24T01:46:46Z | 1,469,458 | <p>I think your expected probability is wrong, as you've stated the problem. (1/6)^5 is the probability of rolling some <em>specific</em> number 5 times in a row; (1/6)^4 is the probability of rolling <em>any</em> number 5 times in a row (because the first roll is always "successful" -- that is, the first roll will alw... | 0 | 2009-09-24T01:57:29Z | [
"python",
"probability"
] |
Probability exercise returning different result that expected | 1,469,421 | <p>As an exercise I'm writing a program to calculate the odds of rolling 5 die with the same number. The idea is to get the result via simulation as opposed to simple math though. My program is this:</p>
<pre><code># rollFive.py
from random import *
def main():
n = input("Please enter the number of sims to run... | 2 | 2009-09-24T01:46:46Z | 1,471,073 | <p>Very simply, there are <code>6 ** 5</code> possible outcomes from rolling 5 dice, and only 6 of those outcomes are successful, so the answer is <code>6.0 / 6 ** 5</code></p>
| 1 | 2009-09-24T11:25:15Z | [
"python",
"probability"
] |
Why am I receiving a low level socket error when using the Fabric python library? | 1,469,431 | <p>When I run the command:</p>
<pre><code>fab -H localhost host_type
</code></pre>
<p>I receive the following error:</p>
<pre><code>[localhost] Executing task 'host_type'
[localhost] run: uname -s
Fatal error: Low level socket error connecting to host localhost: Connection refused
Aborting.
</code></pre>
<p>Any t... | 16 | 2009-09-24T01:51:21Z | 1,469,466 | <p>The important part isn't the "low level error" part of the message - the important part is the "Connection refused" part. You'll get a "connection refused" message when trying to connect to a closed port.</p>
<p>The most likely scenario is that you are not running an ssh server on your machine at the time that Fab... | 24 | 2009-09-24T02:01:12Z | [
"python"
] |
Why am I receiving a low level socket error when using the Fabric python library? | 1,469,431 | <p>When I run the command:</p>
<pre><code>fab -H localhost host_type
</code></pre>
<p>I receive the following error:</p>
<pre><code>[localhost] Executing task 'host_type'
[localhost] run: uname -s
Fatal error: Low level socket error connecting to host localhost: Connection refused
Aborting.
</code></pre>
<p>Any t... | 16 | 2009-09-24T01:51:21Z | 11,511,884 | <p>I had the same problem, but the reason was different: While I could easily log in to the server via SSH (default port 22), fabric tried to connect on a closed port 9090.</p>
<p>Finally I recognized that I had defined "env.port=9090" in my old fabfile for some WSGI server setup; while that was never a problem, I upd... | 2 | 2012-07-16T20:17:32Z | [
"python"
] |
Why am I receiving a low level socket error when using the Fabric python library? | 1,469,431 | <p>When I run the command:</p>
<pre><code>fab -H localhost host_type
</code></pre>
<p>I receive the following error:</p>
<pre><code>[localhost] Executing task 'host_type'
[localhost] run: uname -s
Fatal error: Low level socket error connecting to host localhost: Connection refused
Aborting.
</code></pre>
<p>Any t... | 16 | 2009-09-24T01:51:21Z | 35,858,644 | <pre><code>env.roledefs = {
'role1': env.hosts[0:5],
'role2':[env.hosts[5],]
}
</code></pre>
<p>I encountered the same error if "role" value <strong>IS NOT A LIST</strong>. for example, the above code works but the following doesn't.</p>
<pre><code> env.roledefs = {
'role1': env.hosts[0:5],
'role2':env.hosts[5],
}
</... | 1 | 2016-03-08T03:54:50Z | [
"python"
] |
Why am I receiving a low level socket error when using the Fabric python library? | 1,469,431 | <p>When I run the command:</p>
<pre><code>fab -H localhost host_type
</code></pre>
<p>I receive the following error:</p>
<pre><code>[localhost] Executing task 'host_type'
[localhost] run: uname -s
Fatal error: Low level socket error connecting to host localhost: Connection refused
Aborting.
</code></pre>
<p>Any t... | 16 | 2009-09-24T01:51:21Z | 37,236,582 | <p>This can also happen in OS X 10.11.4 and Fabric 1.10.1, in the case where you are ssh'ing to a VM using Vagrant, which does port forwarding from localhost. In this case, localhost was resolving to the IPv6 <code>::1</code> address (not due to <code>/etc/hosts</code> file), and giving this error.</p>
<p>The fix was... | 2 | 2016-05-15T09:24:39Z | [
"python"
] |
Making a facade in Python 2.5 | 1,469,591 | <p>I want to have a Python class that acts as a wrapper for another Python class.</p>
<p>Something like this</p>
<pre><code>class xxx:
name = property( fset=lambda self, v: setattr(self.inner, 'name', v), fget=lambda self: getattr(self.inner, 'name' ))
def setWrapper( self, obj )
self.inner = obj
</co... | 1 | 2009-09-24T03:07:02Z | 1,469,599 | <p>This is where you use the <code>__setattr__</code> and <code>__getattr__</code> methods as documented <a href="http://docs.python.org/reference/datamodel.html#customizing-attribute-access" rel="nofollow">here</a>.</p>
<p>In short, if you do this:</p>
<pre><code>class Wrapper(object):
def __init__(self, wrapped... | 6 | 2009-09-24T03:10:53Z | [
"python"
] |
Making a facade in Python 2.5 | 1,469,591 | <p>I want to have a Python class that acts as a wrapper for another Python class.</p>
<p>Something like this</p>
<pre><code>class xxx:
name = property( fset=lambda self, v: setattr(self.inner, 'name', v), fget=lambda self: getattr(self.inner, 'name' ))
def setWrapper( self, obj )
self.inner = obj
</co... | 1 | 2009-09-24T03:07:02Z | 1,469,619 | <p>As another answer said, <code>__getattr__</code> and <code>__setattr__</code> are the key, <strong>but</strong> you need care when using the latter...:</p>
<pre><code>class Wrapper(object):
def __init__(self, wrapped):
object.__setattr__(self, 'inner', wrapped)
def __getattr__(self, n):
ret... | 5 | 2009-09-24T03:19:09Z | [
"python"
] |
Making a facade in Python 2.5 | 1,469,591 | <p>I want to have a Python class that acts as a wrapper for another Python class.</p>
<p>Something like this</p>
<pre><code>class xxx:
name = property( fset=lambda self, v: setattr(self.inner, 'name', v), fget=lambda self: getattr(self.inner, 'name' ))
def setWrapper( self, obj )
self.inner = obj
</co... | 1 | 2009-09-24T03:07:02Z | 1,469,753 | <p>I believe both Alex and Ben's answers should edit their setattr call as follows:</p>
<pre><code>setattr(self.inner, n, value)
</code></pre>
| 0 | 2009-09-24T04:19:04Z | [
"python"
] |
Django: ImportError: cannot import name Count | 1,469,614 | <p>I just pulled from my github and tried to setup my application on my Ubuntu (I originally ran my app on a Mac at home).</p>
<p>I re-created the database and reconfigured the settings.py -- also update the template locations, etc.</p>
<p>However, when I run the server "python manage.py runserver" get an error that ... | 3 | 2009-09-24T03:18:20Z | 1,469,658 | <p>I've updated my Django and it turns out that your import statement is correct as module structure was changed a bit. Are you sure your Django is of latest version?</p>
| 1 | 2009-09-24T03:41:08Z | [
"python",
"django"
] |
Django: ImportError: cannot import name Count | 1,469,614 | <p>I just pulled from my github and tried to setup my application on my Ubuntu (I originally ran my app on a Mac at home).</p>
<p>I re-created the database and reconfigured the settings.py -- also update the template locations, etc.</p>
<p>However, when I run the server "python manage.py runserver" get an error that ... | 3 | 2009-09-24T03:18:20Z | 1,469,712 | <p>This sounds like you're not using Django 1.1. Double check by opening up the Django shell and running</p>
<pre><code>import django
print django.VERSION
</code></pre>
<p>You should see something like <code>(1, 1, 0, 'final', 0)</code> if you're using 1.1</p>
| 1 | 2009-09-24T04:04:49Z | [
"python",
"django"
] |
Networkx node traversal | 1,469,653 | <p>Using Python's Networkx library, I created an undirected graph to represent a relationship network between various people. A snippet of my code is below:</p>
<pre><code>import networkx as nx
def creategraph(filepath):
G=nx.Graph()
#All the various nodes and edges are added in this stretch of code.
retur... | 0 | 2009-09-24T03:40:25Z | 1,469,670 | <p>The <a href="http://docs.python.org/library/random.html#random.choice" rel="nofollow">choice</a> function in the <a href="http://docs.python.org/library/random.html" rel="nofollow">random</a> module could help with the selection process. You don't really need to worry about the distinction between unicode and strin... | 4 | 2009-09-24T03:45:57Z | [
"python",
"graph",
"nodes",
"networkx"
] |
Understanding Python profile output | 1,469,679 | <p>I'm trying to use the Python profiler to speed up my code. I've been able to identify the specific function where nearly all of the time is spent, but I can't figure out where in that function the time is being spent.</p>
<p>Below I have the profile output, which shows that "appendBallot" is the primary culprit an... | 6 | 2009-09-24T03:50:00Z | 1,469,697 | <p>Yeah I came across that same problem as well.</p>
<p>The only way I know to work around this is to wrap your large function into several smaller function calls. This will allow the profiler to take into account each of the smaller function calls.</p>
<p>Interesting enough, the process of doing this (for me, anyway... | 5 | 2009-09-24T03:58:55Z | [
"python",
"profiling",
"profile"
] |
Understanding Python profile output | 1,469,679 | <p>I'm trying to use the Python profiler to speed up my code. I've been able to identify the specific function where nearly all of the time is spent, but I can't figure out where in that function the time is being spent.</p>
<p>Below I have the profile output, which shows that "appendBallot" is the primary culprit an... | 6 | 2009-09-24T03:50:00Z | 1,469,884 | <p>I've had a look at your code, and it looks like you make a lot of function calls and attribute lookups as part of your 'checking' or looking ahead before leaping. You also have a lot of code dedicated to track the same condition, i.e many bits of code looking at creating 'unique' IDs. </p>
<p>instead of trying to a... | 5 | 2009-09-24T05:25:49Z | [
"python",
"profiling",
"profile"
] |
Understanding Python profile output | 1,469,679 | <p>I'm trying to use the Python profiler to speed up my code. I've been able to identify the specific function where nearly all of the time is spent, but I can't figure out where in that function the time is being spent.</p>
<p>Below I have the profile output, which shows that "appendBallot" is the primary culprit an... | 6 | 2009-09-24T03:50:00Z | 1,470,014 | <p>I have used <a href="http://mg.pov.lt/blog/profiling.html" rel="nofollow" title="Profiling decorator">this decorator</a> in my code, and it helped me with my pyparsing tuning work.</p>
| 4 | 2009-09-24T06:12:26Z | [
"python",
"profiling",
"profile"
] |
Understanding Python profile output | 1,469,679 | <p>I'm trying to use the Python profiler to speed up my code. I've been able to identify the specific function where nearly all of the time is spent, but I can't figure out where in that function the time is being spent.</p>
<p>Below I have the profile output, which shows that "appendBallot" is the primary culprit an... | 6 | 2009-09-24T03:50:00Z | 1,470,325 | <p>I'll support Fragsworth by saying that you'll want to split up your function into smaller ones.</p>
<p>Having said that, you are reading the output correctly: the tottime is the one to watch. </p>
<p>Now for where your slowdown is likely to be:</p>
<p>Since there seem to be 100000 calls to appendBallot, and ther... | 3 | 2009-09-24T08:01:11Z | [
"python",
"profiling",
"profile"
] |
Understanding Python profile output | 1,469,679 | <p>I'm trying to use the Python profiler to speed up my code. I've been able to identify the specific function where nearly all of the time is spent, but I can't figure out where in that function the time is being spent.</p>
<p>Below I have the profile output, which shows that "appendBallot" is the primary culprit an... | 6 | 2009-09-24T03:50:00Z | 1,471,017 | <p>You have two problems in this little slice of code:</p>
<pre><code># Assign a ballot ID if one has not been given
if ballotID is None:
ballotID = len(self.ballotIDs)
assert(ballotID not in self.ballotIDs)
self.ballotIDs.append(ballotID)
</code></pre>
<p>Firstly it appears that self.ballotIDs is a list, so the ... | 2 | 2009-09-24T11:12:31Z | [
"python",
"profiling",
"profile"
] |
Understanding Python profile output | 1,469,679 | <p>I'm trying to use the Python profiler to speed up my code. I've been able to identify the specific function where nearly all of the time is spent, but I can't figure out where in that function the time is being spent.</p>
<p>Below I have the profile output, which shows that "appendBallot" is the primary culprit an... | 6 | 2009-09-24T03:50:00Z | 1,472,429 | <p>Profilers can be like that. The method I use is <a href="http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024">this</a>. It gets right to the heart of the problem in no time.</p>
| 3 | 2009-09-24T15:26:50Z | [
"python",
"profiling",
"profile"
] |
Better webserver performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi | 1,469,770 | <p>I am currently running a high-traffic python/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already ... | 2 | 2009-09-24T04:26:57Z | 1,469,813 | <p>I don't have thorough benchmarks, but I'm personally convinced that, just like lighttpd can outperform apache on simpler tasks, <code>mod_wsgi</code> gives apache the laurel when it comes to serving Python web apps. (<a href="http://nginx.net/" rel="nofollow"><code>nginx</code></a> with <em>its own</em> <code>mod_ws... | 1 | 2009-09-24T04:44:46Z | [
"python",
"django",
"apache",
"fastcgi",
"lighttpd"
] |
Better webserver performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi | 1,469,770 | <p>I am currently running a high-traffic python/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already ... | 2 | 2009-09-24T04:26:57Z | 1,470,382 | <p>I suggest <a href="http://nginx.net/" rel="nofollow">nginx</a> with <a href="http://bitbucket.org/barbuza/superfcgi" rel="nofollow">superfcgi</a> for web sites with high load. nginx is very fast for static files. superfcgi uses multiple processes with multiple threads that shows high stability for python application... | 4 | 2009-09-24T08:18:35Z | [
"python",
"django",
"apache",
"fastcgi",
"lighttpd"
] |
Better webserver performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi | 1,469,770 | <p>I am currently running a high-traffic python/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already ... | 2 | 2009-09-24T04:26:57Z | 1,470,459 | <p>Doesn't answer you question, but do you already use caching for your site? Like memcached? This might give you a better performance gain than going through the mess of switching webservers.</p>
| 1 | 2009-09-24T08:47:14Z | [
"python",
"django",
"apache",
"fastcgi",
"lighttpd"
] |
Better webserver performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi | 1,469,770 | <p>I am currently running a high-traffic python/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already ... | 2 | 2009-09-24T04:26:57Z | 9,142,698 | <p>you can try fcgid. <a href="https://github.com/chenyf/fcgid" rel="nofollow">https://github.com/chenyf/fcgid</a>, it's a C++ fastcgi server</p>
| 0 | 2012-02-04T17:11:07Z | [
"python",
"django",
"apache",
"fastcgi",
"lighttpd"
] |
PGP/GnuPG to encrypt | 1,469,798 | <p>Need to use PGP/GnuPG to encrypt.can suggest what the Python packages to use that.
for PGP encryption i.e. on the other side is PGP used to decrypt.</p>
| 2 | 2009-09-24T04:37:35Z | 1,469,809 | <p>You could try <a href="http://code.google.com/p/python-gnupg/" rel="nofollow">python-gnupg</a>. Encryption is covered in the docs <a href="http://www.red-dove.com/python%5Fgnupg/index.html#encryption-and-decryption" rel="nofollow">here</a>.</p>
| 0 | 2009-09-24T04:43:39Z | [
"python",
"gnupg"
] |
Eclipse+PyDev+GAE memcache error | 1,469,860 | <p>I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to <a href="http://code.google.com/appengine/articles/eclipse.html">this tutorial</a>.</p>
<p>Everything was working until I start to use memcache. PyDev reports the errors and I don'... | 18 | 2009-09-24T05:12:28Z | 1,469,935 | <p>What version of PyDev are you using? A recent one (1.5) or the old one referred by the Google tutorial?<br />
See <a href="http://sourceforge.net/projects/pydev/forums/forum/293649/topic/3388818" rel="nofollow">this thread</a>.</p>
<p>There is a similar <a href="http://root.cern.ch/root/roottalk/roottalk09/0064.htm... | 2 | 2009-09-24T05:44:39Z | [
"python",
"eclipse",
"google-app-engine",
"pydev"
] |
Eclipse+PyDev+GAE memcache error | 1,469,860 | <p>I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to <a href="http://code.google.com/appengine/articles/eclipse.html">this tutorial</a>.</p>
<p>Everything was working until I start to use memcache. PyDev reports the errors and I don'... | 18 | 2009-09-24T05:12:28Z | 2,930,265 | <p>I'm a bit late to the party, but you can add the following comment in all of your files that use memcache to selectively switch off pydev analysis:</p>
<p><code>#@PydevCodeAnalysisIgnore</code></p>
| 4 | 2010-05-28T15:25:20Z | [
"python",
"eclipse",
"google-app-engine",
"pydev"
] |
Eclipse+PyDev+GAE memcache error | 1,469,860 | <p>I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to <a href="http://code.google.com/appengine/articles/eclipse.html">this tutorial</a>.</p>
<p>Everything was working until I start to use memcache. PyDev reports the errors and I don'... | 18 | 2009-09-24T05:12:28Z | 3,126,195 | <p>If you don't want to turn off all code analysis for your project/module, then just turn it off for that line. <a href="http://stackoverflow.com/questions/2112715/how-do-i-fix-pydev-undefined-variable-from-import-errors/2248987#2248987">This answer</a> explains that you can hit Ctrl+1 to bring up quick fix and insert... | 4 | 2010-06-27T02:42:40Z | [
"python",
"eclipse",
"google-app-engine",
"pydev"
] |
Eclipse+PyDev+GAE memcache error | 1,469,860 | <p>I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to <a href="http://code.google.com/appengine/articles/eclipse.html">this tutorial</a>.</p>
<p>Everything was working until I start to use memcache. PyDev reports the errors and I don'... | 18 | 2009-09-24T05:12:28Z | 4,262,347 | <p>There is a cleaner solution: Try adding GAE's memcache to your forced builtins.</p>
<p>In your PyDev->Interpreter-Python->ForcedBuiltins window, add the "google.appengine.api.memcache" entry and apply.</p>
<p>Double-click on the memcache errors to check them back, they disappear!</p>
<p>Please make sure that syst... | 25 | 2010-11-24T00:09:11Z | [
"python",
"eclipse",
"google-app-engine",
"pydev"
] |
Eclipse+PyDev+GAE memcache error | 1,469,860 | <p>I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to <a href="http://code.google.com/appengine/articles/eclipse.html">this tutorial</a>.</p>
<p>Everything was working until I start to use memcache. PyDev reports the errors and I don'... | 18 | 2009-09-24T05:12:28Z | 15,501,478 | <p>This worked for me and it's different than the solutions above.
Pretty straight forward:
<a href="http://blog.kicaj.com/fixing-pydev-memcache-unresolved-import/" rel="nofollow">http://blog.kicaj.com/fixing-pydev-memcache-unresolved-import/</a></p>
<p>Just says to add the google_appengine folder to the pydev python ... | 3 | 2013-03-19T13:56:33Z | [
"python",
"eclipse",
"google-app-engine",
"pydev"
] |
Eclipse+PyDev+GAE memcache error | 1,469,860 | <p>I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to <a href="http://code.google.com/appengine/articles/eclipse.html">this tutorial</a>.</p>
<p>Everything was working until I start to use memcache. PyDev reports the errors and I don'... | 18 | 2009-09-24T05:12:28Z | 20,630,869 | <p>I fixed that by adding this few lines to my code on the top of my file:</p>
<pre><code>from google.appengine.api import memcache
# work-around for Eclipse+PyDev+GAE memcache error
if not hasattr(memcache, 'set'):
Client=None
memcache.setup_client(Client)
memcache = Client
</code></pre>
<p>You can commn... | 0 | 2013-12-17T09:50:53Z | [
"python",
"eclipse",
"google-app-engine",
"pydev"
] |
Python ctypes: copying Structure's contents | 1,470,343 | <p>I want to mimic a piece of C code in Python with ctypes, the code is something like:</p>
<pre><code>typedef struct {
int x;
int y;
} point;
void copy_point(point *a, point *b) {
*a = *b;
}
</code></pre>
<p>in ctypes it's not possible to do the following:</p>
<pre><code>from ctypes import *
class Point(Str... | 5 | 2009-09-24T08:07:40Z | 1,470,375 | <p>I'm now also thinking about defining a method like:</p>
<pre><code>def safe_copy(dst, src):
if type(src) != type(dst) or not isinstance(src, Structure):
raise Exception("wrong types")
memmove(addressof(dst), addressof(src), sizeof(src))
</code></pre>
<p>But there might be still nicer options out there...</... | 0 | 2009-09-24T08:17:34Z | [
"pointers",
"copy",
"python",
"ctypes"
] |
Python ctypes: copying Structure's contents | 1,470,343 | <p>I want to mimic a piece of C code in Python with ctypes, the code is something like:</p>
<pre><code>typedef struct {
int x;
int y;
} point;
void copy_point(point *a, point *b) {
*a = *b;
}
</code></pre>
<p>in ctypes it's not possible to do the following:</p>
<pre><code>from ctypes import *
class Point(Str... | 5 | 2009-09-24T08:07:40Z | 1,470,387 | <p>Pointer operations as rule are not very memory safe. I would create wrapper classes for each struct data type you are interested in and let them handle the pointer copy operations. Pretty much like you are doing here. There are lambda and map functions which you can use recursively as syntactic sugar.</p>
| 0 | 2009-09-24T08:20:33Z | [
"pointers",
"copy",
"python",
"ctypes"
] |
Python ctypes: copying Structure's contents | 1,470,343 | <p>I want to mimic a piece of C code in Python with ctypes, the code is something like:</p>
<pre><code>typedef struct {
int x;
int y;
} point;
void copy_point(point *a, point *b) {
*a = *b;
}
</code></pre>
<p>in ctypes it's not possible to do the following:</p>
<pre><code>from ctypes import *
class Point(Str... | 5 | 2009-09-24T08:07:40Z | 1,470,554 | <p>You can use sequence assignment to copy the pointed-to objects (rather than assigning to <code>p.contents</code>, which changes the pointer value):</p>
<pre><code>def copy(dst, src):
"""Copies the contents of src to dst"""
pointer(dst)[0] = src
# alternately
def new_copy(src):
"""Returns a new ctypes o... | 4 | 2009-09-24T09:10:35Z | [
"pointers",
"copy",
"python",
"ctypes"
] |
Python ctypes: copying Structure's contents | 1,470,343 | <p>I want to mimic a piece of C code in Python with ctypes, the code is something like:</p>
<pre><code>typedef struct {
int x;
int y;
} point;
void copy_point(point *a, point *b) {
*a = *b;
}
</code></pre>
<p>in ctypes it's not possible to do the following:</p>
<pre><code>from ctypes import *
class Point(Str... | 5 | 2009-09-24T08:07:40Z | 1,471,079 | <p><code>memmove</code> is the correct operation here. By setting the <code>argtypes</code> of your CopyPoint function, you can easily enforce type-safety.</p>
<pre><code>from ctypes import *
class Point(Structure):
_fields_ = [("x", c_int), ("y", c_int)]
def __str__(self):
return "<Point: x=%d, y... | 5 | 2009-09-24T11:26:51Z | [
"pointers",
"copy",
"python",
"ctypes"
] |
Python ctypes: copying Structure's contents | 1,470,343 | <p>I want to mimic a piece of C code in Python with ctypes, the code is something like:</p>
<pre><code>typedef struct {
int x;
int y;
} point;
void copy_point(point *a, point *b) {
*a = *b;
}
</code></pre>
<p>in ctypes it's not possible to do the following:</p>
<pre><code>from ctypes import *
class Point(Str... | 5 | 2009-09-24T08:07:40Z | 39,343,746 | <p>In python 3x,your code can run correctly. shown below:</p>
<pre><code>>>> from ctypes import *
>>> class Point(Structure):
... _fields_ = [("x", c_int),("y", c_int)]
>>> def copy_point(a, b):
... a.contents = b.contents
>>> p0 = pointer(Point())
>>> p1 = pointer(Poin... | 0 | 2016-09-06T08:07:15Z | [
"pointers",
"copy",
"python",
"ctypes"
] |
Why is the WindowsError while deleting the temporary file? | 1,470,350 | <ol>
<li>I have created a temporary file. </li>
<li>Added some data to the file created. </li>
<li>Saved it and then trying to delete it. </li>
</ol>
<p>But I am getting <code>WindowsError</code>. I have closed the file after editing it. How do I check which other process is accessing the file. </p>
<pre><code>C:\Doc... | 3 | 2009-09-24T08:10:28Z | 1,470,370 | <p>I believe you need to release the fptr to close the file cleanly. Try setting fptr to None.</p>
| 0 | 2009-09-24T08:16:06Z | [
"python",
"temporary-files"
] |
Why is the WindowsError while deleting the temporary file? | 1,470,350 | <ol>
<li>I have created a temporary file. </li>
<li>Added some data to the file created. </li>
<li>Saved it and then trying to delete it. </li>
</ol>
<p>But I am getting <code>WindowsError</code>. I have closed the file after editing it. How do I check which other process is accessing the file. </p>
<pre><code>C:\Doc... | 3 | 2009-09-24T08:10:28Z | 1,470,388 | <p>The file is still open. Do this:</p>
<pre><code>fh, filename = tempfile.mkstemp()
...
os.close(fh)
os.remove(filename)
</code></pre>
| 6 | 2009-09-24T08:20:54Z | [
"python",
"temporary-files"
] |
Why is the WindowsError while deleting the temporary file? | 1,470,350 | <ol>
<li>I have created a temporary file. </li>
<li>Added some data to the file created. </li>
<li>Saved it and then trying to delete it. </li>
</ol>
<p>But I am getting <code>WindowsError</code>. I have closed the file after editing it. How do I check which other process is accessing the file. </p>
<pre><code>C:\Doc... | 3 | 2009-09-24T08:10:28Z | 1,472,979 | <p>From the <a href="http://docs.python.org/library/tempfile.html#tempfile.mkstemp">documentation</a>:</p>
<blockquote>
<p>mkstemp() returns a tuple containing an OS-level handle to an open file (as would be returned by os.open()) and the absolute pathname of that file, in that order. New in version 2.3. </p>
</bloc... | 9 | 2009-09-24T17:02:49Z | [
"python",
"temporary-files"
] |
What is going on with this code from the Google App Engine tutorial | 1,470,405 | <pre><code>import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimePr... | 1 | 2009-09-24T08:25:43Z | 1,470,433 | <p>The first piece of code is a model definition:</p>
<pre><code>class Greeting(db.Model):
content = db.StringProperty(multiline=True)
</code></pre>
<p>It says that there is a model <code>Greeting</code> that has a <code>StringProperty</code> with the name <code>content</code>.</p>
<p>In the second piece of code... | 2 | 2009-09-24T08:35:18Z | [
"python",
"google-app-engine"
] |
What is going on with this code from the Google App Engine tutorial | 1,470,405 | <pre><code>import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimePr... | 1 | 2009-09-24T08:25:43Z | 1,470,455 | <p><a href="http://stackoverflow.com/users/45691/piquadrat">piquadrat</a>'s answer is good. You can read more about App Engine models <a href="http://code.google.com/appengine/docs/python/datastore/modelclass.html" rel="nofollow">here</a>.</p>
| 0 | 2009-09-24T08:46:13Z | [
"python",
"google-app-engine"
] |
What is going on with this code from the Google App Engine tutorial | 1,470,405 | <pre><code>import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimePr... | 1 | 2009-09-24T08:25:43Z | 1,470,480 | <pre><code>class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
</code></pre>
<p>This code instructs the ORM (object relational mapper) to create a table in the database with the fields "author", "content" and "date". Notic... | 2 | 2009-09-24T08:51:51Z | [
"python",
"google-app-engine"
] |
Create new List object in python | 1,470,446 | <p>I am a beginner in python. I want to Create new List object in python.</p>
<p><strong>My Code:</strong></p>
<pre><code>recordList=[]
mappedDictionay={}
sectionGroupName= None
for record in recordCols:
item = record
print item
if not sectionGroupName == record[0]:
sectionGroupName = record[0... | 3 | 2009-09-24T08:42:50Z | 1,470,460 | <p>It's not that easy to understand your question, especially since your code lost its formatting, but you can create new list objects quite easily. The following assigns a new list object to the variable recordList:</p>
<pre><code>recordList = list()
</code></pre>
<p>You could also use</p>
<pre><code>recordList = [... | 9 | 2009-09-24T08:47:29Z | [
"python",
"list"
] |
Create new List object in python | 1,470,446 | <p>I am a beginner in python. I want to Create new List object in python.</p>
<p><strong>My Code:</strong></p>
<pre><code>recordList=[]
mappedDictionay={}
sectionGroupName= None
for record in recordCols:
item = record
print item
if not sectionGroupName == record[0]:
sectionGroupName = record[0... | 3 | 2009-09-24T08:42:50Z | 1,470,463 | <p>Python is <a href="http://en.wikipedia.org/wiki/Garbage%5Fcollection%5F%28computer%5Fscience%29" rel="nofollow">garbage-collected</a>. Just do</p>
<pre><code>recordList = []
</code></pre>
<p>and you'll have a new empty list.</p>
| 3 | 2009-09-24T08:47:50Z | [
"python",
"list"
] |
Create new List object in python | 1,470,446 | <p>I am a beginner in python. I want to Create new List object in python.</p>
<p><strong>My Code:</strong></p>
<pre><code>recordList=[]
mappedDictionay={}
sectionGroupName= None
for record in recordCols:
item = record
print item
if not sectionGroupName == record[0]:
sectionGroupName = record[0... | 3 | 2009-09-24T08:42:50Z | 1,470,650 | <p>Don't use <code>del</code>. Period. It's an "advanced" thing.</p>
<pre><code>from collections import defaultdict
mappedDictionay= defaultdict( list ) # mappedDictionary is a poor name
sectionGroupName= None
for record in recordCols:
mappedDictionay[record[0]].append( record )
</code></pre>
| 4 | 2009-09-24T09:32:25Z | [
"python",
"list"
] |
Create new List object in python | 1,470,446 | <p>I am a beginner in python. I want to Create new List object in python.</p>
<p><strong>My Code:</strong></p>
<pre><code>recordList=[]
mappedDictionay={}
sectionGroupName= None
for record in recordCols:
item = record
print item
if not sectionGroupName == record[0]:
sectionGroupName = record[0... | 3 | 2009-09-24T08:42:50Z | 1,470,723 | <p>You can use <code>list()</code> or simply <code>[]</code> to create a new list.
However, I think what you are trying to achieve can be solved simply by using <code>grouby</code>:</p>
<pre><code>from itertools import groupby
mappedIterator = groupby(recordCols, lambda x: x[0])
</code></pre>
<p>or</p>
<pre><code>fr... | 0 | 2009-09-24T09:52:27Z | [
"python",
"list"
] |
Create new List object in python | 1,470,446 | <p>I am a beginner in python. I want to Create new List object in python.</p>
<p><strong>My Code:</strong></p>
<pre><code>recordList=[]
mappedDictionay={}
sectionGroupName= None
for record in recordCols:
item = record
print item
if not sectionGroupName == record[0]:
sectionGroupName = record[0... | 3 | 2009-09-24T08:42:50Z | 36,386,003 | <p>You want to create a new list?<br>
It's easy: for eg, you wanna make a list of days, write the following: </p>
<p><code>new_list=['mon','tue','wed','thurs','fri',sat','sun']</code> </p>
<p>Here the name of the list is <code>new_list</code> and it contains the name of different week days.</p>
<p><strong... | 0 | 2016-04-03T13:31:24Z | [
"python",
"list"
] |
How to check which part of app is consuming CPU? | 1,470,453 | <p>I have a wxPython app which has many worker threads, idle event cycles, and many other such event handling code which can consume CPU, for now when app is not being interacted with consumes about 8-10% CPU.</p>
<p>Question:</p>
<p>Is there a tool which can tell which part/threads of my app is consuming most CPU? I... | 0 | 2009-09-24T08:45:56Z | 1,470,508 | <p>If all your threads have unique start methods you could use the <a href="http://docs.python.org/library/profile.html" rel="nofollow">profiler that comes with Python</a>.</p>
<p>If you're on a Mac you should check out the Instruments app. You could also use <a href="http://en.wikipedia.org/wiki/DTrace" rel="nofollow... | 1 | 2009-09-24T09:00:50Z | [
"python",
"wxpython",
"cpu-usage"
] |
How to check which part of app is consuming CPU? | 1,470,453 | <p>I have a wxPython app which has many worker threads, idle event cycles, and many other such event handling code which can consume CPU, for now when app is not being interacted with consumes about 8-10% CPU.</p>
<p>Question:</p>
<p>Is there a tool which can tell which part/threads of my app is consuming most CPU? I... | 0 | 2009-09-24T08:45:56Z | 1,470,720 | <p>This isn't very practical at a language-agnostic level. Take away the language and all you have left is a load of machine code instructions sprinkled around with system calls. You could use strace on Linux or ProcessExplorer on Windows to try and guess what is going on from those system calls, but it would make far ... | 0 | 2009-09-24T09:51:32Z | [
"python",
"wxpython",
"cpu-usage"
] |
How to check which part of app is consuming CPU? | 1,470,453 | <p>I have a wxPython app which has many worker threads, idle event cycles, and many other such event handling code which can consume CPU, for now when app is not being interacted with consumes about 8-10% CPU.</p>
<p>Question:</p>
<p>Is there a tool which can tell which part/threads of my app is consuming most CPU? I... | 0 | 2009-09-24T08:45:56Z | 1,470,876 | <p>I am able to solve my problem by writing a modifed version of python <a href="http://docs.python.org/library/trace.html" rel="nofollow">trace</a> module , which can be enabled disabled, basically modify <code>Trace</code> class something like this</p>
<pre><code>import sys
import trace
class MyTrace(trace.Trace):
... | 0 | 2009-09-24T10:38:28Z | [
"python",
"wxpython",
"cpu-usage"
] |
How to check which part of app is consuming CPU? | 1,470,453 | <p>I have a wxPython app which has many worker threads, idle event cycles, and many other such event handling code which can consume CPU, for now when app is not being interacted with consumes about 8-10% CPU.</p>
<p>Question:</p>
<p>Is there a tool which can tell which part/threads of my app is consuming most CPU? I... | 0 | 2009-09-24T08:45:56Z | 1,608,455 | <p>On Windows XP and higher, <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow">Process Explorer</a> will show all processes, and you can view the properties of each process and see open threads. It shows thread ID, start time, state, kernel time, user time, and more.</p>
| 0 | 2009-10-22T16:35:43Z | [
"python",
"wxpython",
"cpu-usage"
] |
How can I tell the Django ORM to reverse the order of query results? | 1,470,676 | <p>In my quest to understand queries against Django models, I've been trying to get the last 3 added valid Avatar models with a query like:</p>
<pre><code>newUserAv = Avatar.objects.filter(valid=True).order_by("date")[:3]
</code></pre>
<p>However, this instead gives me the first three avatars added ordered by date. I... | 26 | 2009-09-24T09:39:09Z | 1,470,680 | <p>Put a hyphen before the field name.</p>
<pre><code>.order_by('-date')
</code></pre>
| 60 | 2009-09-24T09:40:23Z | [
"python",
"django"
] |
How can I tell the Django ORM to reverse the order of query results? | 1,470,676 | <p>In my quest to understand queries against Django models, I've been trying to get the last 3 added valid Avatar models with a query like:</p>
<pre><code>newUserAv = Avatar.objects.filter(valid=True).order_by("date")[:3]
</code></pre>
<p>However, this instead gives me the first three avatars added ordered by date. I... | 26 | 2009-09-24T09:39:09Z | 1,470,683 | <p>Reverse order with <code>.reverse()</code> </p>
<pre><code>newUserAv = Avatar.objects.filter(valid=True).order_by("date").reverse()[:3]
</code></pre>
| -2 | 2009-09-24T09:41:48Z | [
"python",
"django"
] |
Django: disallow can_delete on GenericStackedInline | 1,470,811 | <p>I've built this model which contains a generic foreign key:</p>
<pre><code>class MyModel(models.Model):
content_type = models.ForeignKey(ContentType, verbose_name=_('content type'))
object_id = models.PositiveIntegerField(_('object id'))
content_object = generic.GenericForeignKey('content_type', 'object... | 15 | 2009-09-24T10:16:36Z | 1,474,066 | <p>Update 2016: as per Stan's answer below, modern versions of django let you set <a href="https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin.can_delete" rel="nofollow"><code>can_delete = True</code></a> on the <a href="https://docs.djangoproject.com/en/1.9/ref/contrib/conten... | 7 | 2009-09-24T20:48:45Z | [
"python",
"django",
"django-admin",
"generics",
"formset"
] |
Django: disallow can_delete on GenericStackedInline | 1,470,811 | <p>I've built this model which contains a generic foreign key:</p>
<pre><code>class MyModel(models.Model):
content_type = models.ForeignKey(ContentType, verbose_name=_('content type'))
object_id = models.PositiveIntegerField(_('object id'))
content_object = generic.GenericForeignKey('content_type', 'object... | 15 | 2009-09-24T10:16:36Z | 4,895,968 | <p>Maybe It is a post '09 feature, but you can specify that without overriding the <code>__init__()</code> method :</p>
<pre><code>class StupidCarOptionsInline(admin.StackedInline):
model = models.StupidOption
form = StupidCarOptionAdminForm
extra = 0
can_delete = False
</code></pre>
| 19 | 2011-02-04T08:33:29Z | [
"python",
"django",
"django-admin",
"generics",
"formset"
] |
Twisted network client with multiprocessing workers? | 1,470,850 | <p>So, I've got an application that uses Twisted + Stomper as a STOMP client which farms out work to a multiprocessing.Pool of workers.</p>
<p>This appears to work ok when I just use a python script to fire this up, which (simplified) looks something like this:</p>
<pre><code># stompclient.py
logging.config.fileConf... | 7 | 2009-09-24T10:28:19Z | 1,471,108 | <p>A possible idea for you...</p>
<p>When running in daemon mode twistd will close stdin, stdout and stderr. Does something that your clients do read or write to these?</p>
| 0 | 2009-09-24T11:32:44Z | [
"python",
"twisted",
"multiprocessing"
] |
Twisted network client with multiprocessing workers? | 1,470,850 | <p>So, I've got an application that uses Twisted + Stomper as a STOMP client which farms out work to a multiprocessing.Pool of workers.</p>
<p>This appears to work ok when I just use a python script to fire this up, which (simplified) looks something like this:</p>
<pre><code># stompclient.py
logging.config.fileConf... | 7 | 2009-09-24T10:28:19Z | 1,472,271 | <p>Since the difference between your working invocation and your non-working invocation is only the "-n" option, it seems most likely that the problem is caused by the daemonization process (which "-n" prevents from happening).</p>
<p>On POSIX, one of the steps involved in daemonization is forking and having the paren... | 12 | 2009-09-24T14:58:46Z | [
"python",
"twisted",
"multiprocessing"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.