Re: cython3: Cannot start!

2018-12-24 Thread Stefan Behnel
Paulo da Silva schrieb am 22.12.18 um 19:26: > Sorry if this is OT. > > I decided to give cython a try and cannot run a very simple program! > > 1. I am using kubuntu 18.04 and installe cython3 (not cython). > > 2. My program tp.pyx: > > # cython: language_level=3 > print("Test",2) > > 3. setu

Re: Side by side comparison - CPython, nuitka, PyPy

2018-12-24 Thread Stefan Behnel
Anthony Flury via Python-list schrieb am 21.12.18 um 09:06: > I thought I would look at a side by side comparison of CPython, nuitka and > PyPy Interesting choice. Why nuitka? > *The functionality under test* > > I have a library (called primelib) which implements a Sieve of Erathoneses > in pu

Re: Fastest first

2018-12-24 Thread Stefan Behnel
Avi Gross schrieb am 17.12.18 um 01:00: > SHORT VERSION: a way to automatically run multiple algorithms in parallel > and kill the rest when one returns an answer. One (somewhat seasonal) comment on this: it doesn't always have to be about killing (processes or threads). You might also consider a

Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-23 Thread Stefan Behnel
Cameron Simpson schrieb am 23.01.19 um 00:21: >  from __future__ import absolute_imports, print_function > > gets you a long way. ... and: division. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Implement C's Switch in Python 3

2019-02-03 Thread Stefan Behnel
Chris Angelico schrieb am 03.02.19 um 02:23: > Of course, you can also precompute this: > > day_ordinal = mapper( > [1, 21, 31], "st", > [2, 22], "nd", > [3, 23], "rd", > ) > def f(x): return day_ordinal.get(x, "th") … in which case I would also 'precompute' the ".get" and

Re: C API PyObject_GetAttrString returns not the object I expected

2019-02-10 Thread Stefan Behnel
Barry Scott schrieb am 10.02.19 um 13:08: > After calling PyObject_GetAttrString() I expected to get a PyObject string > back but I found that I had been given a instead. > > (gdb) p *args_o > $4 = > > What is going on and how do I get from the to the object > I > want? Phil is right abou

Re: Using PyArg_ParseTuple to with optional fields.

2019-02-28 Thread Stefan Behnel
Anthony Flury via Python-list schrieb am 28.02.19 um 10:18: > I am trying to write an extension module with a function (actually an > __init__ method, but I am not sure that matters) where the function can be > called as either : > >     my_func() > > or > >     my_func( a, b, c, d) - where a,b,

Re: Embedding Python in C

2019-07-19 Thread Stefan Behnel
Jesse Ibarra schrieb am 17.07.19 um 20:39: > My options seem rather limited, I need to make a Pipeline from > (Smalltalk -> C -> Python) then go back (Smalltalk <- C <- Python). > Since Smalltalk does not support Python directly I have to settle with > the C/Python API > (https://docs.python.org/3.

Re: Embedding Python in C

2019-07-20 Thread Stefan Behnel
Jesse Ibarra schrieb am 20.07.19 um 04:12: > Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python. > I can only call Pyhton code through C/Python API. Ok, but that doesn't mean you need to write code that uses the C-API of Python. All you need to do is: 1) Start up a CPython ru

Re: Embedding Python in C

2019-07-23 Thread Stefan Behnel
Jesse Ibarra schrieb am 22.07.19 um 18:12: > On Saturday, July 20, 2019 at 1:11:51 PM UTC-6, Stefan Behnel wrote: >> Jesse Ibarra schrieb am 20.07.19 um 04:12: >>> Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python. >>> I can only call Pyhto

Content MathML implementation?

2005-09-25 Thread Stefan Behnel
Hi! I was looking for an implementation of a parser/model/serializer for Content MathML in Python. Does anyone know about something useful? I need to work with math expressions (arithmetic/bool), especially converting them between different representations (Python, SQL), determining dependencies

ANN: MathDOM 0.1 - MathML in Python

2005-09-28 Thread Stefan Behnel
Hi everyone, I herefore announce the availability of the first public version of MathDOM on SourceForge. http://sourceforge.net/projects/mathdom MathDOM is a set of Python modules (using PyXML and pyparsing) that import mathematical terms as a Content MathML DOM. It currently parses MathML and l

Python 3! Finally!

2005-09-30 Thread Stefan Behnel
Hi! I just firefoxed to Python.org and clicked on the bz2 link at http://python.org/2.4.2/ and what did I get? Python-3.4.2.tar.bz2 !! Python 3 - what we've all been waiting for, finally, it's there! Weird, though, the md5sum is the same as for the Python-2.4.2.tar.bz2 that I downloaded late (l

ANN: MathDOM 0.5.0 - MathML in Python

2005-10-07 Thread Stefan Behnel
Hi everyone, MathDOM 0.5 is ready for download from SourceForge. http://mathdom.sourceforge.net/ MathDOM is a set of Python modules (using PyXML and pyparsing) that import mathematical terms as a Content MathML DOM. It currently parses MathML and literal infix terms into a DOM and writes out Mat

wrapping single classes in an extension module

2005-10-12 Thread Stefan Behnel
Hi! In a project, I'm providing an API that is made up by augmenting XML DOM elements with tag specific attributes and methods. These actually operate on the DOM and fulfill the need of making the DOM API more user friendly and domain specific. I currently use PyXML/4DOM and I'm considering movin

Re: UI toolkits for Python

2005-10-15 Thread Stefan Behnel
Kenneth McDonald schrieb: > Is there any emerging consensus on the "best" UI for toolkit. Tk never > quite made it but from what I can see, both qt and wxWin are both doing > fairly well in general. I'm already aware of the licensing issues > surrounding qt (fwiw, I think their license fee for

Re: UI toolkits for Python

2005-10-15 Thread Stefan Behnel
Kenneth McDonald wrote: > Is there any emerging consensus on the "best" UI for toolkit. Tk never > quite made it but from what I can see, both qt and wxWin are both doing > fairly well in general. I'm already aware of the licensing issues > surrounding qt (fwiw, I think their license fee for co

ANN: MathDOM 0.5.2 - MathML in Python - now featuring lxml API!

2005-10-17 Thread Stefan Behnel
Hi everyone, MathDOM 0.5.2 is ready for download from SourceForge. http://mathdom.sourceforge.net/ MathDOM is a set of Python modules (using pyparsing and either PyXML or lxml) that import mathematical terms as a Content MathML DOM. It currently parses MathML and literal infix terms into a DOM a

Attribute value of instance method non-modifiable?

2005-10-26 Thread Stefan Behnel
Hi! I just stumbled over this: .>>> class test(object): ... def t(): pass ... t.testval = 1 ... .>>> test.t .>>> test.t.testval 1 .>>> test.t.testval = 2 Traceback (most recent call last): File "", line 1, in ? AttributeError: 'instancemethod' object has no attribute 'testval' .>>> dir(te

Prepending to traceback

2005-02-02 Thread Stefan Behnel
Hi! I'm writing a parser using pyparsing and I would like to augment the ParserException tracebacks with information about the actual error line *in the parsed text*. Pyparsing provides me with everything I need (parsed line and column), but is there a way to push that information on the traceba

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-02 Thread Stefan Behnel
Leeuw van der, Tim schrieb: I'm using the following combination of software: - Pydev Eclipse plugin (pydev 0.8.5) - eclipse 3.0.1 - windows XP SP1 - pygtk 2.4.1 - GTK 2.6.1 (for windows32 native) First of all, try tightening the field. Are all of these packages needed to reproduce the error? Try

Re: Is this a contradiction in the docs ?

2005-02-02 Thread Stefan Behnel
Fuzzyman schrieb: Hmmm... my code will *never* need to run on anything other than CPython because I use py2exe to turn it into a frozen python distribution. So if it was always safe in CPython then that would be fine for me. No one will ever need more than 640K of RAM and BTW, my program will be r

Re: What's wrong with `is not None`?

2005-02-09 Thread Stefan Behnel
Frans Englich schrieb: What is the equivalent expression which is more secure; `!= None`? Note that this is not necessarily equivalent. '!=' and '==' possibly run method calls on objects which can be costly depending on their implementation and can even raise exceptions if called with None. If I wa

Re: probably weird or stupid newbie dictionary question

2005-02-09 Thread Stefan Behnel
hawkmoon269 schrieb: some other languages' hash table (Perl's, for instance). But FMU a dictionary's keys are *themselves* hashed so that a hash table exists that maps hashed key values to keys in the dictionary. I guess you're mixing up the terms "hashing" and "storing in a hash-table". When we

frozenset() without arguments should return a singleton

2005-02-11 Thread Stefan Behnel
Hi! frozenset() doesn't behave as the other immutable empty data types in 2.4: .>>> '' is '' True .>>> () is () True .>>> frozenset() is frozenset() False .>>> id(()),id(()) (1077579820, 1077579820) .>>> id(()) 1077579820 .>>> id(frozenset()),id(frozenset()) (1077581296, 1077581296) .>>> id(frozens

frozenset() without arguments should return a singleton

2005-02-11 Thread Stefan Behnel
Hi! frozenset() doesn't behave as the other immutable empty data types in 2.4: .>>> '' is '' True .>>> () is () True .>>> frozenset() is frozenset() False .>>> id(()),id(()) (1077579820, 1077579820) .>>> id(()) 1077579820 .>>> id(frozenset()),id(frozenset()) (1077581296, 1077581296) .>>> id(frozens

[PATCH] Re: frozenset() without arguments should return a singleton

2005-02-12 Thread Stefan Behnel
Terry Reedy schrieb: frozenset() called without arguments (or on empty sequences) should always return a singleton object. If we interpret 'should' as 'preferably by me', ok. It will take some programmer's time to add the special case check and run the test suite, and check in the changes. Yours?

Re: [PATCH] Re: frozenset() without arguments should return a singleton

2005-02-12 Thread Stefan Behnel
Raymond Hettinger wrote: >Stefan Behnel wrote: I stumbled over the fact that 'frozenset()' doesn't return a constant but creates a new object everytime. Since it is immutable, I wrote to c.l.py that this behaviour is different from what tuple() & Co do. It is not quite co

Re: [PATCH] Re: frozenset() without arguments should return a singleton

2005-02-13 Thread Stefan Behnel
Raymond Hettinger wrote: It is not quite correct to say that this is what all immutables do: .>>>x = 500 .>>>y = 600 - 100 .>>>x is y False That is an implementation detail, not guaranteed by the language (i.e. not necessarily true in future versions, in Jython, or other implementations). It is j

changing __call__ on demand

2005-02-13 Thread Stefan Behnel
Hi! This somewhat puzzles me: Python 2.4 (#1, Feb 3 2005, 16:47:05) [GCC 3.3.4 (pre 3.3.5 20040809)] on linux2 Type "help", "copyright", "credits" or "license" for more information. .>>> class test(object): ... def __init__(self): ... self.__call__ = self.__call1 ... def __call1(self): ...

Re: changing __call__ on demand

2005-02-13 Thread Stefan Behnel
Michael Hoffman schrieb: __call__, like __getitem__, and __getattr__ is called on the class object, not the instance object. So, no, not as far as I am aware, without using metaclass trickery. The simplest option IMO is to use another level of indirection as you suggest. Thanks for the quick answer

[PATCH] allow partial replace in string.Template

2005-02-14 Thread Stefan Behnel
Hi! Here's a trivial patch against Lib/string.py that adds two new methods. The first replaces the template by a partially resolved substitution and the second creates a new, partially substituted template. I find those two useful enough for integration in the stdlib, especially the replacing on

Re: [PATCH] allow partial replace in string.Template

2005-02-14 Thread Stefan Behnel
Nick Coghlan wrote a) Patches are more likely to be looked at if placed on the SF patch tracker. see your own b), I wanted to discuss them first. b) I don't quite see the point, given how easy these are to spell using the basic safe_substitute. You're replacing one liners with one-liners. Still,

reversed heapification?

2005-03-07 Thread Stefan Behnel
Hi! I need a general-purpose best-k sorting algorithm and I'd like to use heapq for that (heapify + heappop*k). The problem is that heapify and heappop do not support the "reverse" keyword as known from sorted() and list.sort(). While the decorate-sort-undecorate pattern allows me to replace the "k

Re: reversed heapification?

2005-03-07 Thread Stefan Behnel
Kent Johnson schrieb: heapq.nlargest() heapq.nsmallest() ? Python 2.4 only Thanks! Those are *very* well hidden in the documentation. Maybe I already read that page too often... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: reversed heapification?

2005-03-07 Thread Stefan Behnel
Kent Johnson wrote: heapq.nlargest() heapq.nsmallest() On second thought, that doesn't actually get me very far. I do not know in advance how many I must select since I need to remove duplicates *after* sorting (they are not necessarily 'duplicate' enough to fall into the same sort bucket). What

Re: reversed heapification?

2005-03-07 Thread Stefan Behnel
Jeff Epler wrote: Can you use something like (untested) class ComparisonReverser: def __init__(self, s): self.s = s def __cmp__(self, o): return cmp(o, self.s) def __lt__... # or whichever operation hashes use then use (ComparisonReverser(f(x)), i, x) as the decorated i

Re: shuffle the lines of a large file

2005-03-10 Thread Stefan Behnel
Simon Brunning wrote: On Tue, 8 Mar 2005 14:13:01 +, Simon Brunning wrote: selected_lines = list(None for line_no in xrange(lines)) Just a short note on this line. If lines is really large, its much faster to use from itertools import repeat selected_lines = list(repeat(None, len(lines)))

Re: pyasm 0.2 - dynamic x86 assembler for python

2005-03-10 Thread Stefan Behnel
Hi! What about an interface like this: -- @pyasm def hello_world(*some_args): """ !CHARS hello_str 'Hello world!\n\0' !PROC hello_world PYTHON !ARG self !ARG args PUSH hello_str CALL PySys_WriteStdout ADD ESP, 0x4

Re: RELEASED Python 2.4 (final)

2004-11-30 Thread Stefan Behnel
Dave Merrill schrieb: Newb question: Is it possible/recommended to have multiple versions of Python installed simultaneously? Earlier, I installed 2.4rc1, and a number of things in my 2.3.3 install stopped working. Are there known techniques for managing multiple versions? Short answer: depends on

Re: Syntax for extracting multiple items from a dictionary

2004-11-30 Thread Stefan Behnel
shark schrieb: row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken", "state" : "Alaska"} cols = ("city", "state") Is there a best-practices way to ask for an object containing only the keys named in cols out of row? In other words, to get this: {"city" : "Hoboken", "state" : "Alaska"} U

Re: Python 2.3.5 ?

2004-12-08 Thread Stefan Behnel
Stefan mails! the way you read it doesn't reflect why top-posting is bad: It's me wrote: Not to mention that there are packages out there that doesn't work (yet) with 2.4. Pynum is one such package. -- It's me "Larry Bates" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Just because 2

Re: Compiling PIL for Python 2.4

2004-12-13 Thread Stefan Behnel
Fuzzyman schrieb: I'll post this to the image-sig as well, but the audience is a bit wider here. Sorry, can't help you on the rest (which seems to be rather MS and compiler specific), but in general: cross-posting is not a good idea. Read any of the many copies of the Netiquette on this topic. In

".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

2004-12-16 Thread Stefan Behnel
Nick Coghlan schrieb: data = [['foo','bar','baz'],['my','your'],['holy','grail']] result = [] for d in data: .>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']] .>>> from itertools import chain .>>> result = "".join(chain(*data)) 'foobarbazmyyourholygrail' This is the first time I see

Re: looking for wget-like module for getching software

2004-12-16 Thread Stefan Behnel
Robert P. J. Day schrieb: that is, i can just say, "go get file gcc-3.4.2.tar.bz2", and start searching at "ftp://pub.gnu.org/pub/gcc";. i may not know how far down in the directory structure that file is, but wget will happily search recursively until it finds it. That sounds pretty inefficient

Heap class for heapq module

2005-03-23 Thread Stefan Behnel
Hi! I filed a patch for a Heap class to be integrated into the heapq module (in addition the the currently available functions). The main features are support for iteration and for the standard keyword arguments of sort() and sorted(): key, cmp, reverse. http://sourceforge.net/tracker/index.php

Re: The Running Time of += on Char Strings ?

2005-03-24 Thread Stefan Behnel
Edg Bamyasi schrieb: What is the running time of conactination on character strings. i.e. .>>>joe="123" .>>>joe+="9" is it Amortized Constant time? I don't think it would be O((number of chars)^2) but i really don't know. First of all, this idiom is generally avoided in loops (where

Re: Python 2.4 killing commercial Windows Python development ?

2005-04-18 Thread Stefan Behnel
Roger Binns schrieb: As far as I can tell, they failed at two hurdles. One is that there is a new BitPim release every two weeks and they can't really keep up with that. (eg it takes around two weeks for packages with a lot of attention on Gentoo to become stable and often is a lot longer) This i

Re: XML-RPC -- send file

2005-04-19 Thread Stefan Behnel
codecraig schrieb: CLIENT --- d = xmlrpclib.Binary(open("C:\\somefile.exe").read()) server.sendFile(d) SERVER -- def sendFile(tmp): print "FILE:", tmp This returns None. Don't know what XML-RPC expects, but you may either try to return something else from the function or ma

Re: parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread Stefan Behnel
larry.martell...@gmail.com, 25.11.2013 23:22: > I have an XML file that has an element called "Node". These can be nested to > any depth and the depth of the nesting is not known to me. I need to parse > the file and preserve the nesting. For exmaple, if the XML file had: > > > > >

Re: parsing nested unbounded XML fields with ElementTree

2013-11-26 Thread Stefan Behnel
Larry Martell, 26.11.2013 13:23: > On Tue, Nov 26, 2013 at 2:38 AM, Stefan Behnel wrote: >> larry.martell...@gmail.com, 25.11.2013 23:22: >>> I have an XML file that has an element called "Node". These can be nested >>> to any depth and the depth of the

Re: Optimizing list processing

2013-12-12 Thread Stefan Behnel
Terry Reedy, 12.12.2013 03:26: > from itertools import count > table = sorted(t for t in zip(iterable, count)) This is a useless use of a generator expression. sorted(zip(...)) is enough (and likely to be substantially faster also). Stefan -- https://mail.python.org/mailman/listinfo/python-lis

Re: Blog "about python 3"

2014-01-05 Thread Stefan Behnel
Johannes Bauer, 05.01.2014 13:14: > I've pushed the > migration of *large* projects at work to Python3 when support was pretty > early and it really wasn't a huge deal. I think there are two sides to consider. Those who can switch their code base to Py3 and be happy (as you did, apparently), and t

Re: Porting c extension - PyBuffer_New() deprecated in python3. What's the replacement?

2014-01-11 Thread Stefan Behnel
Mark Heieis, 11.01.2014 06:47: > I need to convert the following existing c extension code to support Python 3. > > // --- existing code -- > > // PyBuffer_New() deprecated in python3 > if (!(pyBuf = PyBuffer_New(len))) > { > return NULL; > } > > // should use mem

Re: 'Straße' ('Strasse') and Python 2

2014-01-12 Thread Stefan Behnel
Peter Otten, 12.01.2014 09:31: > wxjmfa...@gmail.com wrote: > >> >>> sys.version >> 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] >> >>> s = 'Straße' >> >>> assert len(s) == 6 >> >>> assert s[5] == 'e' >> >>> >> >> jmf > > Signifying nothing. (Macbeth) > > Python 2.7.2+ (def

Re: Writing SOME class methods in C

2015-11-29 Thread Stefan Behnel
Oscar Benjamin schrieb am 18.11.2015 um 13:52: > On 18 November 2015 at 07:50, Daniel Haude wrote: >> >> I'm trying to implement some (but not all) methods of a Python class in C. >> What I've found on the Net is: >> - how to implement entire modules in C so that I can import that module and >>

Re: XML Patch

2014-10-26 Thread Stefan Behnel
Nicholas Cole schrieb am 26.10.2014 um 18:00: > I'm looking for a python library that can parse XML Documents and > create xml-aware "diff" files, and then use those to patch documents. > In other words, I'd like something similar to the Google > diff-match-patch tools, but something which is XML a

Re: XML Patch

2014-10-27 Thread Stefan Behnel
Hi, please keep this on-list. Nicholas Cole schrieb am 26.10.2014 um 22:43: > On Sun, Oct 26, 2014 at 6:30 PM, Stefan Behnel wrote: >> Nicholas Cole schrieb am 26.10.2014 um 18:00: >>> I'm looking for a python library that can parse XML Documents and >>> create

Re: (-1)**1000

2014-10-29 Thread Stefan Behnel
Ned Batchelder schrieb am 26.10.2014 um 21:45: > On 10/26/14 4:07 PM, Tony the Tiger wrote: >> On Wed, 22 Oct 2014 10:27:34 +0200, ast wrote: >> >>> If i am writing (-1)**1000 on a python program, will the interpreter do >>> (-1)*(-1)*...*(-1) or something clever ? >> >> Even vs. odd. It ought to k

Re: Working with HTML5 documents

2014-11-20 Thread Stefan Behnel
Tim schrieb am 20.11.2014 um 18:31: > On Thursday, November 20, 2014 12:04:09 PM UTC-5, Denis McMahon wrote: >>> On Wednesday, November 19, 2014 2:08:27 PM UTC-7, Denis McMahon wrote: So what I'm looking for is a method to create an html5 document using "dom manipulation", ie: d

Re: Most gratuitous comments

2014-11-20 Thread Stefan Behnel
Chris Angelico schrieb am 20.11.2014 um 06:06: > On Thu, Nov 20, 2014 at 3:58 PM, Steven D'Aprano wrote: >> And the award for the most gratuitous comments before an import goes to >> one of my (former) workmates, who wrote this piece of code: >> >> # Used for base64-decoding. >> import base64 >> #

Re: Working with HTML5 documents

2014-11-20 Thread Stefan Behnel
Ian Kelly schrieb am 20.11.2014 um 20:44: > On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote: >> There's also the E-factory for creating (sub-)trees and a nicely objectish >> way: >> >> http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory > > T

Re: Embedded python 'scripting engine' inside Python app

2014-11-23 Thread Stefan Behnel
Chris Angelico schrieb am 23.11.2014 um 11:35: > On Sun, Nov 23, 2014 at 9:28 PM, Patrick Stinson wrote: >> Is there a better and more secure way to do the python-within-python in >> order allow users to automate your app? > > More secure? Basically no. You could push the inner script into a > sep

Re: jitpy - Library to embed PyPy into CPython

2014-12-07 Thread Stefan Behnel
Albert-Jan Roskam schrieb am 06.12.2014 um 21:28: > On Fri, Dec 5, 2014 8:54 PM CET Mark Lawrence wrote: >> For those who haven't heard thought this might be of interest >> https://github.com/fijal/jitpy > > Interesting, but it is not clear to me when you would use jitpy instead > of pypy. I thin

Re: xml SAX Parsing in python

2014-12-17 Thread Stefan Behnel
Hi, Abubakar Roko schrieb am 17.12.2014 um 07:30: > Please I am new in using python to write program. I am trying to parse an XML > document using sax parse and store the parsed result in a tree like > definedbelow. XNode class define an xml element which has an ID , a tag, a > text value, chi

Re: lxml objectify - attribute elements to list.

2015-02-08 Thread Stefan Behnel
Sayth Renshaw schrieb am 08.02.2015 um 12:22: > How can I actually access the values of an element with lxml objectify? > > for example if I had this element in my xml file. > > VenueCode="151" TrackName="Main" TrackCode="149"> > > I can see all the attributes using this. > > In [86]: for chil

Cython - was: Future of Pypy?

2015-02-23 Thread Stefan Behnel
Dave Farrance schrieb am 23.02.2015 um 15:13: > Dave Cook wrote: >> On 2015-02-22, Dave Farrance wrote: >> >>> It's still quicker to do a re-write in the more cumbersome C >> >> You should try Cython. > > I did try Cython when I was trying to figure out what to do about the slow > speed. My initi

Re: insert html into ElementTree without parsing it

2014-03-01 Thread Stefan Behnel
graeme.piete...@gmail.com, 24.02.2014 10:45: > I am building HTML pages using ElementTree. > I need to insert chunks of untrusted HTML into the page. I do not need or > want to parse this, just insert it at a particular point as is. How would you want to find out if it can be safely inserted or n

why indentation should be part of the syntax

2014-03-02 Thread Stefan Behnel
Haven't seen any mention of it on this list yet, but since it's such an obvious flaw in quite a number of programming languages, here's a good article on the recent security bug in iOS, which was due to accidentally duplicated code not actually being as indented as it looked: https://www.imperialv

Re: how to get bytes from bytearray without copying

2014-03-04 Thread Stefan Behnel
Juraj Ivančić, 04.03.2014 16:23: > Just for reference, it is doable in pure Python, with ctypes help For some questionable meaning of "pure". Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: How to create an instance of a python class from C++

2014-03-12 Thread Stefan Behnel
Barry Scott, 11.03.2014 22:37: > On 5 Mar 2014, at 00:14, Bill wrote: >> I can't figure out how to create an instance >> of a python class from 'C++': > > Why not use pycxx from http://sourceforge.net/projects/cxx/? > > This lib does all the heavy lifting for you for both python2 and python3. > H

Re: python obfuscate

2014-04-12 Thread Stefan Behnel
Sturla Molden, 11.04.2014 11:17: > Joshua Landau wrote: > >> However, if this really is your major blocker to using Python, I >> suggest compiling with Cython. > > Cython restains all the code as text, e.g. to readable generate exceptions. No, it actually doesn't. It only keeps the code in C com

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Chris Angelico, 09.05.2014 11:02: > On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan wrote: >> Hai, I would like to parse this multiple root element XML > > Easy fix might be to wrap it in and , which will give > you a new root. ElementTree's XMLParser() can be use efficiently for this. Something

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Marko Rauhamaa, 09.05.2014 14:38: > Marko Rauhamaa: >> Alain Ketterlin: >>> Marko Rauhamaa writes: Sometimes the XML elements come through a pipe as an endless sequence. You can still use the wrapping technique and a SAX parser. However, the other option is to write a tiny XML scanne

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Marko Rauhamaa, 09.05.2014 20:04: > I think the worst part of XML is that you can't parse it without a DTD > or schema. Nonsense. > I was very hopeful about json until I discovered they require the parser > to dynamically support five different character encodings. > > XML at least standardized

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Burak Arslan, 09.05.2014 18:52: > On 05/09/14 16:55, Stefan Behnel wrote: >> ElementTree has gained a nice API in >> Py3.4 that supports this in a much saner way than SAX, using iterators. >> Basically, you just dump in some data that you received and get back an >> iter

Re: NumPy, SciPy, & Python 3X Installation/compatibility issues

2014-05-10 Thread Stefan Behnel
esaw...@gmail.com, 10.05.2014 19:07: > Let me state at the start that I am new to Python. I am moving away from > Fortran and Matlab to Python and I use all different types of numerical and > statistical recipes in my work. I have been reading about NumPy and SciPy and > could not find any defin

Re: Using threads for audio computing?

2014-05-11 Thread Stefan Behnel
lgabiot, 12.05.2014 07:33: > Le 11/05/14 17:40, lgabiot a écrit : > >> I guess if my calculation had to be performed on a small number of >> samples (i.e. under the value of the Pyaudio buffer size (2048 samples >> for instance), and that the calculation would last less than the time it >> takes t

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 02:27: > I'm using Python in an embedded situation. In particular I have to load > python scripts through a memory interface so regular python module > loading can not be used. I got working so far a module loader object > I've added using C++ to sys.meta_path . Now I'm tot

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 15:00: > On 05/17/2014 01:58 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 02:27: >>> I'm using Python in an embedded situation. In particular I have to load >>> python scripts through a memory interface so regular python module &g

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Hi, please avoid top-posting. Roland Plüss, 17.05.2014 15:49: > On 05/17/2014 03:26 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 15:00: >>> On 05/17/2014 01:58 PM, Stefan Behnel wrote: >>>> Roland Plüss, 17.05.2014 02:27: >>>>> I'm usin

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 17:28: > On 05/17/2014 04:01 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 15:49: >>> On 05/17/2014 03:26 PM, Stefan Behnel wrote: >>>> Roland Plüss, 17.05.2014 15:00: >>>>> On 05/17/2014 01:58 PM, Stefan Behnel

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 18:28: > On 05/17/2014 05:49 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 17:28: >>> On 05/17/2014 04:01 PM, Stefan Behnel wrote: >>>> Roland Plüss, 17.05.2014 15:49: >>>>> On 05/17/2014 03:26 PM, Stefan Behnel

Re: Loading modules from files through C++

2014-05-20 Thread Stefan Behnel
Roland Plüss, 20.05.2014 19:17: > PyObject * const loadedModule = Py_InitModule3( fullname, NULL, "Loaded > module" ); > PyObject * const moduleDict = PyModule_GetDict( loadedModule ); // > borrowed reference > PyDict_SetItemString( moduleDict, "__builtins__", PyEval_GetBuiltins() ); > PyRun_String

Re: How keep Python 3 moving forward

2014-05-24 Thread Stefan Behnel
Devin Jeanpierre, 24.05.2014 18:03: > On Sat, May 24, 2014 at 2:59 AM, Marko Rauhamaa wrote: >> blindanagram: >> Instead of focusing on bringing legacy libraries to Python3 (for which >> there never seems to be a critical need), Python3 needs a brand new >> killer module/application/library that is

Re: How keep Python 3 moving forward

2014-05-25 Thread Stefan Behnel
Roy Smith, 24.05.2014 01:57: > I installed and ran caniusepython3. It tells me: > >> Finding and checking dependencies ... >> [WARNING] rpclib not found >> >> You need 19 projects to transition to Python 3. >> Of those 19 projects, 17 have no direct dependencies blocking their >> transition: >>

Re: Make Python Compilable, convert to Python source to Go

2014-05-25 Thread Stefan Behnel
bookaa bookaa, 25.05.2014 10:17: > I think the significance of Python to Go, is it give us opportunity to > make Python project run fast. You shouldn't make that your only goal, because you'll have a really hard time achieving it (to put it mildly). Stefan -- https://mail.python.org/mailman/l

Re: Make Python Compilable, convert to Python source to Go

2014-05-26 Thread Stefan Behnel
Ben Finney, 26.05.2014 05:20: > bookaa bookaa writes: >> Generally, people consider Python as a script language. >> It has high development efficiency >> but run too slowly > > Which Python implementation are you talking about? Run time is not a > property of the language. It is a property of the

Re: how avoid delay while returning from C-python api?

2014-05-28 Thread Stefan Behnel
Lakshmipathi.G, 28.05.2014 12:22: > I have C-Python api like below. It works fine, but the problem is > while invoking this method > from python script say > > #cat script.py > > offset=0 > size=4 > write_object(offset,size) > > > > This calls write_this_c() C api and returns quickly to next

Re: Python 3 is killing Python

2014-05-28 Thread Stefan Behnel
Terry Reedy, 29.05.2014 02:41: > On 5/28/2014 3:23 PM, Larry Martell wrote: >> Somthing I came across in my travels through the ether: >> >> https://medium.com/@deliciousrobots/5d2ad703365d/ > > Claim: "Python 3 languishes in disuse." > > Fact: in 2013, there were around 14 million downloads of w

Re: Python 3 is killing Python

2014-05-31 Thread Stefan Behnel
Johannes Bauer, 31.05.2014 13:09: > Lucky for you 2.7.5 isn't all that different from Py3 and most of it > will apply. You'll be missing out on a bunch of cool features (arbitrary > precision ints Py2 has them as well (although they are called long). 1 << 300 gives the right answer in both Py2 and

Re: PyArg_ParseTuple() when the type could be anything?

2013-08-03 Thread Stefan Behnel
David M. Cotter, 03.08.2013 02:55: > I'd like to be able to use PyArg_ParseTuple() in a generic way. > > for example, i'd like to have all commands start with 1 integer parameter, > and this "commandID" will inform me of what parameters come next (via LUT). > > knowing that i can then call Parse

Re: Python performance

2013-08-03 Thread Stefan Behnel
Wayne Werner, 03.08.2013 15:09: > On Fri, 2 Aug 2013, Schneider wrote: >> I have to write a small SMTP-Relay script (+ some statistic infos) and >> I'm wondering, if this >> can be done in python (in terms of performance, of course not in terms of >> possibility ;) ). >> >> It has to handle around

Re: PEP 450 Adding a statistics module to Python

2013-08-10 Thread Stefan Behnel
Ben Finney, 10.08.2013 07:05: > Skip Montanaro writes: >> Given that installing numpy or scipy is generally no more difficult >> that executing "pip install (scipy|numpy)" I'm not really feeling the >> need for a battery here... > > See the Rationale of PEP 450 for more reasons why “install NumPy”

Re: Calling Python macro from ctypes

2013-08-13 Thread Stefan Behnel
Steven D'Aprano, 13.08.2013 08:25: > On Mon, 12 Aug 2013 13:42:14 +0200, Peter Otten wrote: >> Steven D'Aprano wrote: >> >>> Is it possible to call a Python macro from ctypes? For example, Python >>> 3.3 introduces some new macros for querying the internal representation >>> of strings: >>> >>> htt

Re: lxml question -- creating an etree.Element attribute with ':' in the name

2013-09-19 Thread Stefan Behnel
Burak Arslan, 18.09.2013 21:35: > On 09/18/13 21:59, Roy Smith wrote: >> I can create an Element with a 'foo' attribute by doing: >> >> etree.Element('my_node_name', foo="spam") >> >> But, how do I handle something like: >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";, since "xmlns:xsi

Re: Running code from source that includes extension modules

2013-10-02 Thread Stefan Behnel
Michael Schwarz, 02.10.2013 17:38: > I've just started looking into distutils because I need to write an > extension module in C (for performance reasons) and distutils seems to be > the most straight-forward way. > > I've had success building a C file into a Python extension module using > "pytho

Re: Python Front-end to GCC

2013-10-23 Thread Stefan Behnel
Antoine Pitrou, 22.10.2013 10:55: > Philip Herron writes: >> Its interesting a few things come up what about: >> exec and eval. I didn't really have a good answer for this at my talk at >> PYCon IE 2013 but i am going to say no. I am >> not going to implement these. Partly because eval and exec at

Re: Processing large CSV files - how to maximise throughput?

2013-10-24 Thread Stefan Behnel
Chris Angelico, 25.10.2013 08:13: > On Fri, Oct 25, 2013 at 2:57 PM, Dave Angel wrote: >> But I would concur -- probably they'll both give about the same speedup. >> I just detest the pain that multithreading can bring, and tend to avoid >> it if at all possible. > > I don't have a history of majo

Re: my favorite line of py code so far

2013-11-09 Thread Stefan Behnel
Peter Otten, 09.11.2013 12:49: > There is no obvious meaning attached to _ -- so don't use it. Not quite true. Depending on the context, the obvious meanings of "_" in Python are either 1) "ignore me", e.g. in _, b = some_tuple or 2) "this is a non-public thing", as in class Xyz:

<    1   2   3   4   5   6   7   8   9   10   >