Chris Angelico gmail.com> writes:
> I'm working with the ast module to do some analysis on Python
> codebases, and once I've found what I'm looking for, I want to print
> something out. The file name I'm hanging onto externally, so that
> works; and the nodes all have a lineno. So far so good. But
On 10/09/2012 18:07, Dan Goodman wrote:
On 04/09/2012 03:54, Roy Smith wrote:
Let's assume you're testing two strings for equality. You've already
done the obvious quick tests (i.e they're the same length), and you're
down to the O(n) part of comparing every charac
On 10/09/2012 18:33, Oscar Benjamin wrote:
Computing the hash always requires iterating over all characters in the string
so is best case O(N) where string comparison is best case (and often average
case) O(1).
Yep, but you already have O(N) costs just creating the strings in the
first place,
On 04/09/2012 03:54, Roy Smith wrote:
Let's assume you're testing two strings for equality. You've already
done the obvious quick tests (i.e they're the same length), and you're
down to the O(n) part of comparing every character.
I'm wondering if it might be faster to start at the ends of the s
Hi all,
Until recently, our package has been pure Python, so distributing it has
been straightforward. Now, however, we want to add some extension
modules in C++. We're happy to provide source only distributions on
Linux because almost all Linux users will have all the required
compilers and
Hi,
On 26/04/2011 15:40, Mihai Badoiu wrote:
> I have terrible performance for multiplication when one number gets very
> close to zero. I'm using cython by writing the following code:
This might be an issue with denormal numbers:
http://en.wikipedia.org/wiki/Denormal_number
I don't know much
On Feb 22, 1:32 pm, Robert Kern wrote:
> On 2/22/11 1:49 PM, goodman wrote:
>
> > Hi, my question is this: Is it a bad idea to create a wrapper class
> > for a dictionary so I can add attributes?
>
> Nope. I do recommend adding a custom __repr__(), though.
>
Hi, my question is this: Is it a bad idea to create a wrapper class
for a dictionary so I can add attributes? E.g.:
class DictWithAttrs(dict):
pass
More information:
I'm using a nested defaultdict to store a machine-learning model,
where the first key is a class, the second key is a feature,
hey appear in the .tar.gz file (i.e. execute bit not
set), but I'm not sure if these values are meaningful because they
probably don't correspond to any underlying values in the Win 7 file system.
Any help much appreciated!
Thanks,
Dan Goodman
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 4, 4:43 pm, Lawrence D'Oliveiro wrote:
> In message
> <0f1a17f4-b6a9-4e89-ac26-74b1098a0...@b19g2000prj.googlegroups.com>, goodman
> wrote:
>
> > Hi, I'm wondering why subprocess.Popen does not seem to replace the
> > current process, even
On Nov 4, 1:22 am, goodman wrote:
> Note: Our server is a Linux machine, but we're restricted to Python
> 2.4.
>
> Hi, I'm wondering why subprocess.Popen does not seem to replace the
> current process, even when it uses os.execvp (according to the
> documentation:ht
Note: Our server is a Linux machine, but we're restricted to Python
2.4.
Hi, I'm wondering why subprocess.Popen does not seem to replace the
current process, even when it uses os.execvp (according to the
documentation: http://docs.python.org/library/subprocess.html#subprocess.Popen).
Specifically,
On 10/07/2010 22:08, Neal Becker wrote:
Sumatra looks like an interesting project
http://pypi.python.org/pypi/Sumatra/0.2
But I have some questions. Is there any mail list or forum? I can't find
anything on the website.
It's part of Neural Ensemble which has a google group (not specifically
I tried a very similar thing, but not using with statements:
http://mail.python.org/pipermail/python-list/2010-March/1239577.html
Dan
On 04/05/2010 22:36, Terry Reedy wrote:
In a current thread, people have claimed that generating properly
indented nested blocks is a pain because of the need t
Hi all,
I'm doing some C++ code generation using Python, and would be interested
in any comments on the approach I'm taking.
Basically, the problem involves doing some nested loops and executing
relatively simple arithmetic code snippets, like:
for i in xrange(len(X)):
X[i] += 5
Actually
eric.le.bi...@spectro.jussieu.fr wrote:
I initially tried to create a Float_ref class that inherits from
numpy.array, so that objects of the new class behave like numpy.array
in calculations, but also contain an "uncertainty" atribute, but this
is apparently not allowed ("cannot create 'builtin_f
eric.le.bi...@spectro.jussieu.fr wrote:
Hello,
Is there a way to easily build an object that behaves exactly like a
float, but whose value can be changed? The goal is to maintain a list
[x, y,…] of these float-like objects, and to modify their value on the
fly (with something like x.value = 3.1
MRAB wrote:
Here's my solution (I haven't bothered with making it efficient, BTW):
import operator
def solve(n):
best_len = n
best_expr = ""
for x in range(1, n - 2):
for y in range(x, n):
for op, name in operator_list:
# Does this pair with this
This sounds kind of similar to a problem I posted to this list last
year, you might find that thread gives you some ideas:
http://mail.python.org/pipermail/python-list/2008-January/474071.html
Dan
--
http://mail.python.org/mailman/listinfo/python-list
Mark Dickinson wrote:
Well, random numbers is one thing. But how about the following:
n = 12345**13
n
154662214940914131102165197707101295849230845947265625L
int(n ** (1./13)) # should be 12345; okay
12345
int((n-1) ** (1./13)) # should be 12344; oops!
12345
Good point! Oops indeed. :
Mark Dickinson wrote:
I'd also be a bit worried about accuracy. Is it important to you
that the
integer part of the result is *exactly* right, or is it okay if
(n**13)**(1./13) sometimes comes out as slightly less than n, or if
(n**13-1)**(1./13) sometimes comes out as n?
I don't think accura
Takes less than 1 sec here to do (10**100)**(1./13) a million times, and
only about half as long to do (1e100)**(1./13), or about 14 times as
long as to do .2**2. Doesn't look like one could hope for it to be that
much quicker as you need 9 sig figs of accuracy to get the integer part
of (10**1
On Oct 22, 8:26 am, Py-Fun <[EMAIL PROTECTED]> wrote:
> I'm stuck trying to write a function that generates a factorial of a
> number using iteration and not recursion. Any simple ideas would be
> appreciated.
def fac_btt(num):
total = 1
if num > 1:
for i in range(
I am new to Python and programming. I am looking for some basic
instruction here.
How should I: Open a Text file, read from it, modify it, print to
another .txt?
For instance: Read a string, sort it, write the sorted string.
I understand the algorithms but I don't know the actual mechanics of
P
24 matches
Mail list logo