Martin v. Löwis v.loewis.de> writes:
> > This is a good test for Python implementation bottlenecks. Run
> > that tokenizer on HTML, and see where the time goes.
>
> I looked at it with cProfile, and the top function that comes up
> for a larger document (52k) is
> ...validator.HTMLConformanceCh
pdb.set_trace()
at the point you want the debugger to stop. Useful if you want to
break after some failing condition, for instance.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] (David M. Cooke) writes:
>
> Bruno's already mentioned that iterators and generators aren't
> sequences. Numpy arrays act like the other sequence types:
>
>>>> a = numpy.array([])
>>>> a
> array([], dtype=int64)
>>>> le
iterators and generators aren't
sequences. Numpy arrays act like the other sequence types:
>>> a = numpy.array([])
>>> a
array([], dtype=int64)
>>> len(a)
0
>>> bool(a)
False
(0-dimensional numpy arrays are pathological anyways)
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
ipy/numpy/
>
>
> * numpy should install now with easy_install from setuptools
Note that you'll need to use the latest setuptools (0.6b1). The hacks
I added to get easy_install and numpy.distutils to get along are hard
enough without trying to be backward compatible :-(
--
|>|\
e you'd probably want to use numpy. We've optimized x**n so
that it does handle n=0.5 and integers specially; it makes more sense
to do this for an array of numbers where you can do the special
manipulation of the exponent, and then apply that to all the numbers
in the array at once.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
Python 2.4 :-) Lost comments and stuff, but the code came out great.
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
s installed) it's really to
compile: python setup.py build && python setup.py install.
Do you need Tiger (10.4) or Panther (10.3) compatibility?
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmas
li
There's also pyPDF, at http://pybrary.net/pyPdf/. I haven't tried it,
but it looks interesting.
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
r module
scipy.random. It's actually used to wrap some C code, but it does the
job well.
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
a6 = -0.00019 84090
a8 = 0.0 27526
a10= -0.0 00239
x2 = x**2
return 1. + x2*(a2 + x2*(a4 + x2*(a6 + x2*(a8 + x2*a10
(or least that's what I like to write). Now, if I were going to higher
precision, I'd have more digits of course.
--
|>|\/|<
/-
TY_HOLE_PASS_AUTHORIZATION.html
>From what I can see, this is still true in Apache 2.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
ally an "iskeyword" function
there :)
For modules, sys.modules is a dictionary of the modules that have been
imported.
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
Robert Kern <[EMAIL PROTECTED]> writes:
> greg wrote:
>> David M. Cooke wrote:
>>
>>>>To solve that, I would suggest a fourth category of "arbitrary
>>>>ordering", but that's probably Py3k material.
>>>
>>>We've
orget the one module to rule them all, subprocess:
file_list = subprocess.Popen(['ls'], stdout=subprocess.PIPE).communicate()[0]
which by default won't use the shell (unless you pass shell=True to it).
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
y size:
[1+2j, 3+4j].sort(key=abs)
and since .sort() is stable, for those numbers where the key is the
same, the order will stay the same.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
's doable.
It should also be doable with Maple, using the OpenMaple API. I've
looked at it, and it should be possible. I haven't had the time to
actually do anything, though :-)
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
to handle
than the general case.
--
|>|\/|<
/------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
o could be included in the desc field.
return PyCObject_FromVoidPtr(dib, NULL)
(the NULL can be replaced with a routine that will free the image.)
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
/scipy.org) has wraps for FFTW (Fast
Fourier Transform in the West).
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
versioned form, db_create_4002). Running 'nm -D -g' on the
libsvn_fs_base library shows it uses the same db_create_4002 function.
--
|>|\/|<
/--\
|David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/
|[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
/usr/lib/libtasn1.so.2 (0x002a96d1b000)
libgcrypt.so.11 => /usr/lib/libgcrypt.so.11 (0x002a96e2b000)
libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0x002a96f77000)
libz.so.1 => /usr/lib/libz.so.1 (0x002a9707b000)
If it doesn't look like that, then
use threads, use a Queue.Queue object where
timestamps w/ state changes are pushed on in thread 1, and popped
off and analysed before logging in thread 2. (Or something; this
just popped in my head.)
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
you could use
>>> import numarray.ieeespecial
>>> numarray.ieeespecial.plus_inf
inf
(there's minus_inf, nan, plus_zero, and minus_zero also)
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
objects can fail. If you *know* A and B
objects can't be compared for equality, it'd be ok to raise a
TypeError, but that should be after a type test.
> Also, do you need to increment the reference count
> of Py_NotImeplemented before returning it?
Yes; it's a singleton like Py_None.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
some
customization options that might be helpful. In particular, I'd try
import Gnuplot
Gnuplot.GnuplotOpts.prefer_fifo_data = 0
... then the data will be save to a temporary file instead of piped
through a fifo.
Alternatively, try
Gnuplot.GnuplotOpts.prefer_inline_data = 1
... then no file will be used.
[I don't use Gnuplot myself; this is just what I came up with after a
few minutes of looking at it]
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
anything numerical in Python, you'll want them :-)
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
():
val = testme()
wi = int(val >> 4)
bi = int(val & 0xF)
print wi
print bi
print tbl[wi,bi]
and that'll work.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
true anymore, of course (it was in 2.2.3). In 2.3.5, UserDict,
tarfile and some the Mac-specific module use classmethod, and the
datetime extension module use the C version (the METH_CLASS flag).
And staticmethod (and METH_STATIC) aren't used at all in 2.3 or 2.4 :-)
[if you ignore __new__]
--
so makes it easier to know what is a global :-)
--
|>|\/|<
/------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
ctly this approach, with some extra frills:
looking in subdirectories, for instance.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
make things easier on yourself; the
documentation has a good overview:
http://www.python.org/doc/2.4/lib/module-cgi.html
In this case, your script would look something like this:
import cgi
form = cgi.FieldStorage()
if form.getvalue('sort') == 'ascending':
... sort in asce
r:
def __init__(self, text):
self.m = None
self.text = text
def match(self, pat):
self.m = pat.match(self.text)
return self.m
def __getitem__(self, name):
return self.m.group(name)
Then, use it like
for line in fo:
m = Matcher(line)
if m.matc
t;, "&",
and "%20value"? The xml.sax.handler.ContentHandler.characters method
(which I presume you're using for SAX, as you don't mention!) is not
guaranteed to get all contiguous character data in one call. Also check
if .skippedEntity() methods are firing.
--
|>
m.
Are you sure it's monkey/chicken/dog/cat, and not
monkey\chicken\dog\cat? The later one will print monkey\\chicken...
because of the repr() call.
Also, you probably want it as [\x20-\x7e] (the DEL character \x7f
isn't printable). You're also missing tabs (\t).
The
the name of the python file, minus the ".py" extension.
You'd better hope someone doesn't name their plugin
'os; os.system("rm -rf /"); import sys'
Use __import__ instead.
--
|>|\/|<
/--
is more suited to type testing
(for example, writing "isinstance(f, file)").
"""
... which more accurately reflects what I believe the consensus is
about the usage of open vs. file.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
27;s linked, then it's not being installed right.
You don't have a previous Numeric installation that's being picked up
instead of the one you're trying to install, do you?
At the interpreter prompt, check that
>>> import Numeric
>>> Numeric.__file_
, and set some directories)
Also set use_dotblas to 1.
- do the 'python setup.py build', 'python setup.py install' dance.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
st version is 23.7. It should be
real easy to upgrade to that, as that version picks up Apple's vecLib
framework for the linear algebra routines. Just do the usual 'python
setup.py build', 'sudo python setup.py install'. That should put the
header files where the MMTK install
^
I think that's your error. The extension type is declared to be
hyper.PeriodicGrid, where it actually is model.hyper.PeriodicGrid
(because hyper is in the model package).
Pickle stores g.__class__.__module__ (which is "hyper") and
g.__class__.__name__ (="PeriodicGrid") to find the class object for
reimporting, and on unpickling, tries to do __import__("hyper"), which
fails.
The tp_name slot of your extension type should be "model.hyper.PeriodicGrid".
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
rted a few times.
You'll want to change it to
def swig_sources(self, sources, extension=None):
so that if you use an older python it won't complain about missing
arguments.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
page.
Searching instead of indexing makes it very resilient :-)
--
|>|\/|<
/----------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
unction keys would have to be specified as the key sequence sent by a
function key ("\e[11~" for F1, for instance).
Have a look at the readline info page, or the man page. The syntax of
readline.parse_and_bind is the same as that of an inputrc file.
--
|>|\/|<
/-
uot;
1000 loops, best of 3: 464 usec per loop
$ python2.4 -m timeit "[x*x for x in range(1000)]"
1000 loops, best of 3: 216 usec per loop
So factor of 2, instead of 13700 ...
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
"(like time.strptime()).")},
> +
> {"combine", (PyCFunction)datetime_combine,
>METH_VARARGS | METH_KEYWORDS | METH_CLASS,
>PyDoc_STR("date, time -> datetime with same date and time fields")},
It probably would help to add some documentation to add to the
datetime module documentation.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
ime
tt = time.strptime('20041231', '%Y%m%d')
t = datetime.date.fromtimestamp(time.mktime(tt))
# now in a easier-to-handle form than the time tuple
t += datetime.timedelta(days=1)
print t.strftime('%Y%m%d')
--
|>|\/|<
/-
is if getattr, when raising
AttributeError, somehow reused the old traceback (which would point
out the original problem). I don't know how to do that, though.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
py), then, from the command line:
$ python -m timeit -s 'from x import foo' 'foo()'
(the -m is for python 2.4 to run the timeit module; use the full path
to timeit.py instead for earlier pythons)
Alternatively, the examples for the timeit module has another way to
time functions defined in a module.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
luding depends, data files, and other
stuff you'd think it would do. When in doubt, add it to MANIFEST.in.
--
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
--
http://mail.python.org/mailman/listinfo/python-list
50 matches
Mail list logo