The Cython compiler is 20 years old today !

2022-04-04 Thread Stefan Behnel
x27;m happy to see and talk to the many, many users out there whom we could help to help their users get their work done. Happy anniversary, Cython! Stefan PS: The list of Cython implemented packages on PyPI is certainly incomplete, so please add the classifier to yours if it's m

Re: Files can only be modified in IDLE, but not via Powershell

2021-02-09 Thread Stefan Ritter
hrieb Peter Otten: On 08/02/2021 22:33, Stefan Ritter wrote: Hi, It would be highly appreciated if you could offer me some advice to solve a problem I'm currently facing: I have a Windows 10 ADM64 desktop and a Windows 10 AMD64 Laptop. I wrote some code to insert text in a .txt-file. It works

Files can only be modified in IDLE, but not via Powershell

2021-02-08 Thread Stefan Ritter
st regards, Stefan -- https://mail.python.org/mailman/listinfo/python-list

Documentation of __hash__

2020-02-05 Thread Stefan Halfpap
tion should be the other way around. But what is the reason (meaning) for the statement as it is? Best regards, Stefan -- https://mail.python.org/mailman/listinfo/python-list

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

Re: Embedding Python in C

2019-07-20 Thread Stefan Behnel
ond step 1), which is about 5 lines of Python C-API code if you write it yourself. Everything else can be implemented in Cython and Python. Stefan [1] https://docs.python.org/3/extending/embedding.html?highlight=PyImport_appendinittab#extending-embedded-python -- https://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python in C

2019-07-19 Thread Stefan Behnel
ternal program (in case you really need to do that and can't live with starting Python instead of Smalltalk), here's an example: https://github.com/cython/cython/tree/master/Demos/embed It uses the "--embed" argument to Cython that generates a C (main) function to start up the

Re: Using PyArg_ParseTuple to with optional fields.

2019-02-28 Thread Stefan Behnel
y up to here) – are you sure the above is a good user interface? Did you consider splitting the function into two, one that takes arguments and one that takes none? Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: C API PyObject_GetAttrString returns not the object I expected

2019-02-10 Thread Stefan Behnel
designed to keep users from having to learn all these things and instead lets you do them in Python. https://cython.org/ Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Implement C's Switch in Python 3

2019-02-03 Thread Stefan Behnel
t;th") … in which case I would also 'precompute' the ".get" and give the resulting callable a properly readable name all-together: find_special_day_ordinal = mapper( [1, 21, 31], "st", [2, 22], "nd", [3, 23], "rd",

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: Fastest first

2018-12-24 Thread Stefan Behnel
This could be implemented via a sequence of generators or coroutines in Python. Such an approach is often used in simulations (e.g. SimPy and other "discrete event" simulators), where exact control over the concurrency pattern is desirable. Stefan -- https://mail.python.org/mailman/listinfo/python-list

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

2018-12-24 Thread Stefan Behnel
I could. I understand that it came to life as an exercise, and you probably won't make production use of it. Actually, I doubt that there is a shortage of prime detection libraries. ;) Still, thanks for the writeup. It's helpful to see comparisons of "code how people write it" under different runtimes from time to time. Stefan [1] http://cython.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: cython3: Cannot start!

2018-12-24 Thread Stefan Behnel
that's the print statement, which is really parsed as (Py2) statement here, not as (Py3) function. In normal cases, the language level does not matter for the first statement in the source (because, why would you have a print() there?), so it took us a while to find this bug. pip-installing Cython will get you the latest release, where this bug is resolved. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling an unbound method in C using the Public API

2018-08-29 Thread Stefan Behnel
very unlikely to change within the Py3.7.x releases, but they are hopefully going to change for 3.8. See PEP 580. Your feedback on it is welcome. https://www.python.org/dev/peps/pep-0580/ Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: lxml namespace as an attribute

2018-08-17 Thread Stefan Behnel
, you can say doc.find(".//{http://some/namespace}Body";) and there is also an .iterfind() method for incremental searches and .findall() to return all matches as a list. 2) You can use the XPath subclass "ETXPath", which internally translates qualified tag names to a pr

Re: Tracking a memory leak in C extension - interpreting the output of PYTHONMALLOCSTATS

2018-07-28 Thread Stefan Behnel
in the future, give Cython a try. It can generate all the glue code safely for you, and probably also generates faster wrapper code than you would write yourself. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Stefan Behnel
ent beast, because Python code can always be interrupted by thread switches (between each byte code execution). C code cannot, unless it starts executing byte code (e.g. for calculating a key's hash value) or explicitly allows a thread switch at a given point. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Looking for a recent quote about dynamic typing, possibly on this list

2018-07-07 Thread Stefan Behnel
dynamism." > > You did refer us to http://lambda-the-ultimate.org/node/1519> on > this forum. That contains a quote attributed to John Aycock with the > meaning you paraphrase above. And since the link in that article seems broken, here's the cited paper: https://legacy

Re: Python for beginners or not? [was Re: syntax difference]

2018-06-26 Thread Stefan Ram
To: Steven D'Aprano From: "Stefan Ram" To: Steven D'Aprano From: r...@zedat.fu-berlin.de (Stefan Ram) Steven D'Aprano writes: >It has been a long, long time since Python has been a "simple" language >suitable for rank beginners, if it ever was. Py

Re: Python for beginners or not? [was Re: syntax difference]

2018-06-26 Thread Stefan Ram
To: Stefan Ram From: r...@zedat.fu-berlin.de (Stefan Ram) r...@zedat.fu-berlin.de (Stefan Ram) writes: >Still, one must not forget that learning Python encompasses >all the hard work it takes to learn how to program in every >language. "Beginner", however, is a very

Re: translating foreign data

2018-06-26 Thread Stefan Ram
To: Richard Damon From: "Stefan Ram" To: Richard Damon From: r...@zedat.fu-berlin.de (Stefan Ram) Richard Damon writes: >Now, if I have a parser that doesn't use the locale, but some other rule >base than I just need to provide it with the right rules, which is >bas

Re: Static variables [was Re: syntax difference]

2018-06-26 Thread Stefan Ram
To: Stefan Ram From: "Stefan Ram" To: Stefan Ram From: r...@zedat.fu-berlin.de (Stefan Ram) r...@zedat.fu-berlin.de (Stefan Ram) writes: >def f(): >def g(): >g.x += 1 >return g.x >g.x = 0 >return g Or, "for all g to sha

Re: Static variables [was Re: syntax difference]

2018-06-26 Thread Stefan Ram
To: Steven D'Aprano From: "Stefan Ram" To: Steven D'Aprano From: r...@zedat.fu-berlin.de (Stefan Ram) Steven D'Aprano writes: >def f(): >static x = 0 >def g(): >x += 1 >return x >return g What one can do today: ma

Re: Python for beginners or not? [was Re: syntax difference]

2018-06-25 Thread Stefan Ram
To: Steven D'Aprano From: r...@zedat.fu-berlin.de (Stefan Ram) Steven D'Aprano writes: >It has been a long, long time since Python has been a "simple" language >suitable for rank beginners, if it ever was. Python is not Scratch. Python is simpler insofar as you c

Re: translating foreign data

2018-06-24 Thread Stefan Ram
To: Richard Damon From: r...@zedat.fu-berlin.de (Stefan Ram) Richard Damon writes: >Now, if I have a parser that doesn't use the locale, but some other rule >base than I just need to provide it with the right rules, which is >basically just defining the right locale. Here&

Re: Static variables [was Re: syntax difference]

2018-06-24 Thread Stefan Ram
To: Steven D'Aprano From: r...@zedat.fu-berlin.de (Stefan Ram) Steven D'Aprano writes: >def f(): >static x = 0 >def g(): >x += 1 >return x >return g What one can do today: main.py def g(): g.x += 1 return g.x g.x = 0 pri

Re: Static variables [was Re: syntax difference]

2018-06-24 Thread Stefan Ram
To: Stefan Ram From: r...@zedat.fu-berlin.de (Stefan Ram) r...@zedat.fu-berlin.de (Stefan Ram) writes: >def f(): >def g(): >g.x += 1 >return g.x >g.x = 0 >return g Or, "for all g to share the same x": main.py def f():

Re: List replication operator

2018-05-25 Thread Stefan Behnel
's really just about avoiding a call to "copy.deepcopy()" in certain special cases at the cost of adding new syntax, then I have to agree that we'd better avoid adding the syntax instead. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: List replication operator

2018-05-24 Thread Stefan Behnel
ltin sequence types? The '**' operator cannot just recursively call '**' on the items in the list, because they may not support it. Or they may support it, but not in the expected way. And limiting this to lists of lists seems rather arbitrary. What about subtypes of lists?

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Stefan Behnel
\digit\Anaconda3\lib\encodings\cp1252.py", line 23, in decode > return codecs.charmap_decode(input,self.errors,decoding_table)[0] > > UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 202: > character maps to > > > I suspect the issue is that it's using cp1252.py, which I don't think is > UTF-8 as specified in the XML prolog. Is this an iterparse problem, or am I > using it wrongly? You are not showing enough of the stack trace to properly diagnose this problem, but seeing your code, my educated guess is that the problem is the encoding of the file *path name* and not the *content* of the XML file. I.e. it probably cannot even open the file. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Stefan Behnel
t the parser uses. Note, however, that the library that the OP uses is not lxml but xml.etree, i.e. the ElementTree XML support in the standard library. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-07 Thread Stefan Klinger
print('x after foo', x) class z: v = 12345 def bar(y): z.v = 2 * y # this is global print('z.v in bar', z.v) print('z.v before bar', z.v) bar(0) print('z.v after bar', z.v) Cheers Ste

Re: Writing a C extension - borrowed references

2018-03-21 Thread Stefan Behnel
ly just reverse engineering the Python code from the C-API code), but it's a one-time investment that can reduce the long-term maintenance cost a lot, often improves the performance, and usually also leads to nicer Python APIs, as what you get in the end is more obvious from the code, so you c

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Peter Otten schrieb am 09.03.2018 um 14:11: > Stefan Behnel wrote: > >> Andrew Z schrieb am 07.03.2018 um 05:03: >>> Hello, >>> with 3.6 and latest greatest lxml: >>> >>> from lxml import etree >>> >>> tree = etree.parse(&#x

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Steven D'Aprano schrieb am 09.03.2018 um 12:41: > On Fri, 09 Mar 2018 10:22:23 +0100, Stefan Behnel wrote: > >> Andrew Z schrieb am 07.03.2018 um 05:03: >>> Hello, >>> with 3.6 and latest greatest lxml: >>> >>> from lxm

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
tial Sample.xml: > > > http://www.example.com";> > >md_status_nonpro="true" type="INDIVIDUAL" prefix="jadoe"> > > > > it seems to not be happy with the empty tag . > But i'm not sure why and how to go about it. Could you explain why you want to do that? Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread Stefan Behnel
always be careful when evaluating benchmarks and their results, and to take good care that the benchmarks match the intended need, which is to help us understand and solve a real-world performance problem [1]. Stefan [1] That's also the problem in the post above and in the original benchmarks it

Re: Help on convert PyObject to string (c) Python 3.6

2018-02-19 Thread Stefan Behnel
The code it generates is probably also faster and safer than what you are currently writing (no offence, just experience from reading and writing a lot of such code). http://cython.org/ Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: c code generator from python

2018-02-19 Thread Stefan Behnel
bhattacharya.kush...@gmail.com schrieb am 17.01.2018 um 12:03: > Is there any python framework or any tool as which can generate C code from > python code as it is . http://cython.org/ Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: While, If, Count Statements

2017-11-27 Thread Stefan Ram
Cai Gengyang writes: Statement 0: >count = 0 Statement 1: >if count < 5: > print "Hello, I am an if statement and count is", count Statement 2: >while count < 10: > print "Hello, I am a while and count is", count > count += 1 There are three statements here. They are executed

Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-27 Thread Stefan Ram
Ram) (Stefan Ram) Greg Tibbet writes: >I'm an old timer, have programmed in Fortran, C, C++, Perl, and a bit >of Java and trying to learn this new-fangled Python language! Which actually is older than Java. >def ellipse(self, xy, fill=None, outline=None): >&

Re: Stopping an iterator and continuing later

2017-11-26 Thread Stefan Ram
r...@zedat.fu-berlin.de (Stefan Ram) writes: >Then you can use pickle or custom methods to save and >restore the object, or get the state from an iterator >and create a new iterator with that state later. One does not always have to write a custom class, for example: main.py impo

Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread Stefan Ram
Greg Tibbet writes: >I'm an old timer, have programmed in Fortran, C, C++, Perl, and a bit >of Java and trying to learn this new-fangled Python language! Which actually is older than Java. >def ellipse(self, xy, fill=None, outline=None): >"""Draw an ellipse.""" >ink, fill = sel

Re: Stopping an iterator and continuing later

2017-11-26 Thread Stefan Ram
r...@zedat.fu-berlin.de (Stefan Ram) writes: >Then you can use pickle or custom methods to save and >restore the object, or get the state from an iterator >and create a new iterator with that state later. One does not always have to write a custom class, for example: main.py impo

Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread Stefan Ram
Greg Tibbet writes: >I'm an old timer, have programmed in Fortran, C, C++, Perl, and a bit >of Java and trying to learn this new-fangled Python language! Which actually is older than Java. >def ellipse(self, xy, fill=None, outline=None): >"""Draw an ellipse.""" >ink, fill = sel

Re: Return str to a callback raise a segfault if used in string formating

2017-10-14 Thread Stefan Behnel
e: it's much easier to write extension modules in Cython than in plain C and C-API code. Much easier. There is a learning curve, sure, but it unburdens you from so many pitfalls and boilerplate code that it's always worth switching. And you also get faster code as a side-effect. How's that for a tradeoff. :) Stefan (Cython core developer) -- https://mail.python.org/mailman/listinfo/python-list

Re: Parentheses (as after "print")

2017-09-26 Thread Stefan Behnel
Stefan Ram schrieb am 26.09.2017 um 17:56: > Why do we newbies write »print 2«? Here's another hint. > This is an original transcript of what happened to me today: > > |>>> import( operator ) > | File "", line 1 > |import( operator ) >

Re: How does CPython build it's NEWS or changelog?

2017-09-21 Thread Stefan Behnel
t is the tooling for this? Is there some documentation, maybe a > mailingslist-diskussion or a but-report? https://docs.python.org/devguide/committing.html#what-s-new-and-news-entries https://github.com/larryhastings/blurb Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Even Older Man Yells At Whippersnappers

2017-09-19 Thread Stefan Behnel
Stefan Ram schrieb am 19.09.2017 um 17:00: > D'Arcy Cain writes: >> of course, I use calculators and computers but I still understand the >> theory behind what I am doing. > > I started out programming in BASIC. Today, I use Python, > the BASIC of the 21st cen

Re: Stdlib, what's in, what's out

2017-09-19 Thread Stefan Behnel
ng foreign dependencies low is also "better" in some cases. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Case-insensitive string equality

2017-09-05 Thread Stefan Behnel
Steve D'Aprano schrieb am 02.09.2017 um 02:31: > - the German eszett, ß, which has two official[1] uppercase forms: 'SS' > and an uppercase eszett I wonder if there is an equivalent to Godwin's Law with respect to character case related discussions and the Ge

Re: Python 3 removes name binding from outer scope

2017-07-25 Thread Stefan Behnel
out how to release them explicitly if they find out that they hurt and then additionally manage to debug where they are stored. Py2.x did the latter, and guess how many users knew about it? Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Progress on the Gilectomy

2017-06-10 Thread Stefan Behnel
he core and the stdlib would just not work correctly in > multithread environment without GIL. And the same applies to external extension modules. The GIL is really handy when it comes to reasoning about safety and correctness of algorithms under the threat of thread concurrency. Especially in

Re: Python Events in 2017, Need your help.

2017-02-10 Thread Stefan Behnel
Hi! Germany has three major Python events planned this year: - PyCon-Web in München (May 27-28th) - Python-Camp in Köln (April 8-9th) - PyCon-DE in Karlsruhe (October, dates TBA). http://pyconweb.org/ https://python-verband.org/informieren/events/pythoncamp-2017 Stefan Stephane Wirtel via

Re: windows utf8 & lxml

2016-12-26 Thread Stefan Behnel
n such a fashion returns this error: > > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: > invalid start byte Same thing as above: I don't see how this error message matches the code you show here. The exception you get might be a Python 2.x problem in the first place. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Cython taking more time than regular Python

2016-09-19 Thread Stefan Behnel
er loop Note that this is the worst benchmark ever. Any non-dump C compiler will happily apply Young Gauß and calculate the result in constant time. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: C Python extension to export an Function

2016-09-01 Thread Stefan Behnel
Ganesh Pal schrieb am 01.09.2016 um 17:24: > Thanks stefan and Gollwitzer , good to know there are many ways to do this > i.e via cython or SWIG but the C/Python API > <https://docs.python.org/2/c-api/> is probably the most widely used method It certainly was, years ago, but I

Re: C Python extension to export an Function

2016-09-01 Thread Stefan Behnel
es . We > have bunch of C code that's already available and C -Python seems to suit > me better >From your response it's not obvious whether you are aware that Cython also makes it substantially easier to *interface* CPython with external C code, in the same way that it makes it easy (but not necessary) to *avoid* writing C in the first place. So I thought I'd just mention that this is not a reason to rule it out as an excellent option. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Helloworld with Python C extension

2016-08-29 Thread Stefan Behnel
aising a proper IndexError for invalid index arguments (and it supports negative indexing). I also wouldn't be surprised if it's visibly faster than your C implementation. Unless your intention is to explicitly learn how to use the CPython C-API, you should give Cython a try instead. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Stefan Behnel
Stefan Behnel schrieb am 22.08.2016 um 08:03: > Steven D'Aprano schrieb am 22.08.2016 um 07:35: >> if sys.version < '3': >> import mymodule2 as mymodule >> else: >> import mymodule3 as mymodule > > This condition is going to fail when P

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Stefan Behnel
Steven D'Aprano schrieb am 22.08.2016 um 07:35: > if sys.version < '3': > import mymodule2 as mymodule > else: > import mymodule3 as mymodule This condition is going to fail when Python 30.0 comes out. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: usage of functools.partial in in parallelism

2016-07-31 Thread Stefan Behnel
n parallel or concurrently, but there's really nothing special about that use case. Does that answer your question? Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Stefan Behnel
t uses a direct name import, renaming the function at the same time is easy enough. I often do that with "os.path.join", for example, which turns into "join_path" on import. Same problem, easy solution. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Which one is the best XML-parser?

2016-07-02 Thread Stefan Behnel
ly one that can be queried with xpath) at > a time for each record of a document representing a list of objects. > Does anything like that exist? http://lxml.de/parsing.html#incremental-event-parsing https://docs.python.org/3/library/xml.etree.elementtree.html#pull-api-for-non-blocking-parsing Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: How are you supposed to define subclasses in C?

2016-04-21 Thread Stefan Behnel
tp://cython.org/ http://docs.cython.org/ In a nutshell, it lets you write beautiful Python code instead of ugly C code full of leaks and crashes, and then takes care of making it faster than the usual C-API calls you'd write by hand. It has some extended syntax for extension types and oth

Re: I'd like to add -march=native to my pip builds

2016-04-08 Thread Stefan Behnel
et the CFLAGS environment variable, e.g. CFLAGS="-O3 -march=native" pip install --no-use-wheel numpy Stefan -- https://mail.python.org/mailman/listinfo/python-list

Ammended proposal: Python 832? Re: The next major Python version will be Python 8

2016-04-01 Thread Stefan Hagen
32 -m stefan Before you write, think, after you read. Am 01.04.16 um 00:26 schrieb Victor Stinner: > Hi, > > Python 3 becomes more and more popular and is close to a dangerous point > where it can become popular that Python 2. The PSF decided that it's > time to elaborate a new s

Re: Bash-like pipes in Python

2016-03-19 Thread Stefan Otte
mul) ) `pipe` also allows you to us named arguments which would be difficult if you use operator overloading: pipe("sentaoisrntuwyo", (sorted, {"reverse": True})) Beste Grüße, Stefan On Wed, Mar 16, 2016 at 4:39 PM, Steven D'Aprano wrote: > On Thu, 17 Mar 2016 02:22

Re: Bash-like pipes in Python

2016-03-18 Thread Stefan Otte
satsatsastatbadstssdhhhnbb", set, (sorted, {"reverse": True})) ['t', 's', 'n', 'h', 'd', 'b', 'a'] Cheers, Stefan [0] https://github.com/sotte/pelpe [1] http://elixir-lang.org/getting-started/enumerables-and-

Re: Writing SOME class methods in C

2015-11-29 Thread Stefan Behnel
n code. I strongly recommend not to resort to writing real C code here (using the C-API of CPython). It will be slower and will contain more bugs. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Create a .lua fle from Python

2015-10-02 Thread Stefan Behnel
t about the basics of input validation. It really helps in trust building to find such comments from time to time. Stefan [1] mainframes on the Internet, anyone? -- https://mail.python.org/mailman/listinfo/python-list

Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Stefan Behnel
t has all its (necessary) dependencies available in Python 3.x, I can't see a general reason to keep supporting both language versions. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: XML Binding

2015-09-09 Thread Stefan Behnel
a Python object interface to the XML tree, similar to what data binding would give you. And you can stick your own Element object implementations into it if you feel a need to simplify the API itself and/or adapt it to a given document format. http://lxml.de/objectify.html Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging to a file from a C-extension

2015-08-26 Thread Stefan Behnel
Hi, welcome to Python (and to this list). The usual way to reply here is inline, after stripping anything that's not relevant to your reply. AllanPfalzgraf schrieb am 25.08.2015 um 15:03: > From: Stefan Behnel: >> Al Pfalzgraf schrieb am 18.08.2015 um 15:07: >>> If a lo

Re: how to handle cpu cache in python ( or fastest way to call a function once)

2015-08-23 Thread Stefan Behnel
ldn't bother too much finding it out. It's unlikely to hurt real-world code. (And in fact, the more interesting case where things are happing several times in a row rather than being a negligible constant one-time effort seems to be substantially faster in your timings. Congratulations!) > is there a solution? Is there a problem? Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging to a file from a C-extension

2015-08-19 Thread Stefan Behnel
he usual C-API overhead. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Module load times

2015-08-13 Thread Stefan Behnel
our application a command-line tool or so that needs to start and terminate quickly? Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: New module (written in C) for using the high-precision QD library

2015-07-31 Thread Stefan Behnel
Chris Angelico schrieb am 31.07.2015 um 09:37: > On Fri, Jul 31, 2015 at 5:26 PM, Stefan Behnel wrote: >> Your C code seems to be only about 1500 lines, not too late to translate >> it. That should save you a couple of hundred lines and at the same time >> make it work wi

Re: New module (written in C) for using the high-precision QD library

2015-07-31 Thread Stefan Behnel
e make it work with Python 3 (which it currently doesn't, from what I see). Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Foo.__new__ is what species of method?

2015-07-13 Thread Stefan Behnel
ive the class you call it on as first argument (i.e. "Super" and "object" above), not the class you want to instantiate (i.e. "Sub" or "Super"). Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: enumerate XML tags (keys that will become headers) along with text (values) and write to CSV in one row (as opposed to "stacked" values with one header)

2015-06-28 Thread Stefan Behnel
XML, by the way, also to CSV and other tabular formats. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: HOPE: A Python just-in-time compiler for astrophysical computations

2015-06-28 Thread Stefan Behnel
en implementing the desired feature in an existing compiler would be a one-time investment with a much smaller overall impact on further maintenance costs? Not Invented Here Syndrome, I guess... Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Java to Python autoconverters

2015-06-12 Thread Stefan Behnel
ava code that should be reasonably maintainable. If you want to integrate Python code with Java code, take a look at Jython instead. If that's not what you want, then feel free to unveil your intentions. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Embedded Python and C Callback functions

2015-06-07 Thread Stefan Behnel
doc.mefi...@gmail.com schrieb am 07.06.2015 um 10:56: > And I can't use Cython, because I have C++ module, and I have to use it. That's not a valid reason. Cython supports C++ code just fine. http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html Stefan -- https://ma

Re: Sorting in reverse is not the same as sorting then reversing

2015-06-05 Thread Stefan Behnel
dn't know and now got interested, the relevant term here is "stable sorting". It means that elements that compare equal keep their relative order. That's a general property of Python's sort algorithm. All that "reverse=True" does is to change "lower than"

Re: Building an extension module with SWIG

2015-05-30 Thread Stefan Behnel
x27;d always recommend using Cython over a wrapper generator like SWIG. Once you get to the points where it becomes interesting, you'll always end up having more fun writing a Cython based integration layer than fighting your up-hill battle against the way the wrapper generator wants you to design it. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Building an extension module with SWIG

2015-05-30 Thread Stefan Behnel
, here's a Cython [1] version of your code: # put this in a file called "foo.pyx" def gcd(int x, int y): while x > 0: y, x = x, y % x return y Compile it ("cythonize -b foo.pyx") and you'll get an extension module that execut

Re: Creating a reliable sandboxed Python environment

2015-05-30 Thread Stefan Behnel
y done for you_, same as you get a JIT > for free, and pluggable garbage collectors for free, etc. etc. So here the cost of security is actually rewriting the entire language runtime and potentially also major parts of its ecosystem? Not exactly a cheap price either. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating a reliable sandboxed Python environment

2015-05-29 Thread Stefan Behnel
Chris Angelico schrieb am 29.05.2015 um 09:41: > On Fri, May 29, 2015 at 4:18 PM, Stefan Behnel wrote: >>> Lua's a much weaker language than Python is, though. Can it handle >>> arbitrary-precision integers? Unicode? Dare I even ask, >>> arbitrary-prec

Re: Creating a reliable sandboxed Python environment

2015-05-28 Thread Stefan Behnel
Chris Angelico schrieb am 28.05.2015 um 20:51: > On Fri, May 29, 2015 at 4:41 AM, Stefan Behnel wrote: >> davidf...@gmail.com schrieb am 26.05.2015 um 04:24: >>> Has anyone on this list attempted to sandbox Python programs in a >>> serious fashion? I'd be

Re: Creating a reliable sandboxed Python environment

2015-05-28 Thread Stefan Behnel
by intercepting all Python attribute lookups. It doesn't add much to your application to embed Lua (or even LuaJIT) in Python, and it gives users a nicely object oriented language to call and orchestrate your Python objects. Stefan [1] https://pypi.python.org/pypi/lupa -- https://mail.pyt

Re: Strategies for using cffi with C++ code?

2015-05-22 Thread Stefan Behnel
a somewhat biased expert, but using Cython to generate a statically compiled and optimised C++ wrapper is really your best choice. IMHO, it provides the best results/tradeoffs in terms of developer effort, runtime performance and overall end user experience. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling a function is faster than not calling it?

2015-05-10 Thread Stefan Behnel
executing a Python function by some mostly equivalent but more general Python code. So, you're basically replacing a function call by another function call to eval(), plus some extra generic setup overhead. Python functions know exactly what they have to do internally in order to execute. eval() cannot make the same streamlined assumptions. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-07 Thread Stefan Zimmermann
Marko Rauhamaa wrote: > Anyway, Python has os.system() that does the quick and dirty thing you > might be looking for. Always invokes shell ==> overhead for .exe files -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-07 Thread Stefan Zimmermann
This discussion is getting really interesting and far beyond the actual topic :) I want to add some additional thoughts on Popen: Marko Rauhamaa wrote: > Stefan Zimmermann: > > > And last but not least, Popen behavior on Windows makes it difficult > > to write OS-independent

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-07 Thread Stefan Zimmermann
And last but not least, Popen behavior on Windows makes it difficult to write OS-independent Python code which calls external commands that are not binary by default: 2 examples: 1. I wrote a coffeetools package which wraps the CoffeeScript compiler in a Python API. The 'coffee' command is a N

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-07 Thread Stefan Zimmermann
Nice to see that my topic gains that interest :) And I see that I should have gone more into detail about what I'm actually trying to point out. Chris Angelico wrote: > Hmm... hm... Ha! Found the difference. I had an explicit shebang on my > script; yours just starts out with shell commands. That

PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-06 Thread Stefan Zimmermann
that is a heavy overhead for .exe files. Currently I use pywin32 and call Popen([win32api.FindExecutable('command')[1]]) as a workaround. This has zero overhead. It should be default for Popen to call FindExecutable internally. Was this discussed before? Is it worth a PEP? Or at least

Re: XML Parsing

2015-04-05 Thread Stefan Behnel
ly put into it. So, if you want to parse from XML instead, use ElementTree: https://docs.python.org/3/library/xml.etree.elementtree.html Stefan -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >