The Cython compiler is 20 years old today !

2022-04-04 Thread Stefan Behnel
Dear Python community, it's now 20 years since Greg Ewing posted his first announcement of Pyrex, the tool that is now known and used under the name Cython. https://mail.python.org/pipermail/python-list/2002-April/126661.html It was a long way, and I've written up some of it in a blog post:

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
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-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: 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: 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: 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: 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
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: 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: 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: Calling an unbound method in C using the Public API

2018-08-29 Thread Stefan Behnel
Matthieu Dartiailh schrieb am 29.08.2018 um 16:33: > I am one of the maintainer of the atom library > (https://github.com/nucleic/atom ). This > library provides low-memory footprint Python objects, descriptors and > containers enforcing type validation, implemen

Re: lxml namespace as an attribute

2018-08-17 Thread Stefan Behnel
Skip Montanaro schrieb am 15.08.2018 um 23:25: > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces are defined at the top level, then > adding namespaces=root.nsmap works when calling the xpath method. I > more-or-less get that. > > What I don

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

2018-07-28 Thread Stefan Behnel
Bartosz Golaszewski schrieb am 24.07.2018 um 13:05: > Ok I've found the problem and it's my fault. From tp_dealloc's documentation: > > --- > The destructor function should free all references which the instance > owns, free all memory buffers owned by the instance (using the freeing > function co

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

2018-07-07 Thread Stefan Behnel
Marko Rauhamaa schrieb am 07.07.2018 um 15:41: > Steven D'Aprano : >> On Sat, 07 Jul 2018 02:51:41 +0900, INADA Naoki wrote: >>> D.setdefault('c', None) >> >> Oh that's clever! > > Is that guaranteed to be thread-safe? The documentation ( s://docs.python.org/3/library/stdtypes.html#dict.setdefault

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

2018-07-07 Thread Stefan Behnel
Ben Finney schrieb am 07.07.2018 um 03:38: > Steven D'Aprano writes: > >> Somebody gave a quote about dynamic typing, along the lines of >> >> "Just because a language allows a lot of dynamic features, doesn't mean >> people's code uses a lot of dynamism." > > You did refer us to http://lambda-

Re: List replication operator

2018-05-25 Thread Stefan Behnel
Peter Otten schrieb am 25.05.2018 um 09:28: > Steven D'Aprano wrote: > >> But what do people think about proposing a new list replication with copy >> operator? >> >> [[]]**5 >> >> would return a new list consisting of five shallow copies of the inner >> list. > > Yet another arcanum to learn

Re: List replication operator

2018-05-24 Thread Stefan Behnel
Steven D'Aprano schrieb am 25.05.2018 um 04:25: > On Thu, 24 May 2018 15:12:09 -0400, Ned Batchelder wrote: > >> On 5/24/18 2:17 PM, Steven D'Aprano wrote: > [...] >>> But what do people think about proposing a new list replication with >>> copy operator? >>> >>> [[]]**5 >>> >>> would return

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Stefan Behnel
digi...@gmail.com schrieb am 23.05.2018 um 00:56: > I'm trying to read my iTunes library in Python using iterparse. My current > stub is: > > Snip > > import sys > import datetime > import xml.etree.ElementTree as ET > import argparse > import re > > class Library: > > unmars

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Stefan Behnel
dieter schrieb am 23.05.2018 um 08:25: > If the encoding is not specified, "lxml" will try to determine it > and finally defaults to "utf-8" (which seems to be the correct encoding > for your case). Being an XML parser, it does not do that. XML parsers are designed to reject non-wellformed content

Re: Writing a C extension - borrowed references

2018-03-21 Thread Stefan Behnel
Tom Evans via Python-list schrieb am 20.03.2018 um 18:03: > On Tue, Mar 20, 2018 at 4:38 PM, Chris Angelico wrote: >> BTW, have you looked into Cython? It's smart enough to take care of a >> lot of this sort of thing for you. > > I did a bit; this work is to replace our old python 2 SAML client, >

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
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('Sample.xml') > etree.register_namespace('','http://www.example.com') The default namespace prefix is spelled None (because there is no prefix for it) and not

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

2018-02-23 Thread Stefan Behnel
Steven D'Aprano schrieb am 22.02.2018 um 11:59: > https://www.ibm.com/developerworks/community/blogs/jfp/entry/Python_Meets_Julia_Micro_Performance?lang=en Thanks for sharing, Steven. While it was already suggested between the lines in some of the replies, I'd like to emphasise that the combinati

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

2018-02-19 Thread Stefan Behnel
Jason Qian via Python-list schrieb am 04.02.2018 um 17:52: >This is the case of calling python from c and the python function will > return a string. Hi Jason, I noticed that you ran into a couple of problems using the C-API, so I suggest looking into Cython instead. It basically translates

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: Return str to a callback raise a segfault if used in string formating

2017-10-14 Thread Stefan Behnel
Vincent Vande Vyvre schrieb am 13.10.2017 um 13:18: > Le 13/10/17 à 12:39, Paul Moore a écrit : >> As a specific suggestion, I assume the name of the created file is a >> string object constructed in the C extension code, somehow. The fact >> that you're getting the segfault with some uses of that

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 ) > | ^ > |SyntaxError: invalid syntax > | > |>>

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

2017-09-21 Thread Stefan Behnel
Hartmut Goebel schrieb am 21.09.2017 um 10:59: > I just discovered that CPython now uses Misc/NEWS.d/next to collect > changes an there are a lot of Misc/NEWS/*.rst files for the respective > released version. I'm investigating whether to adopt this for PyInstaller. > > What is the tooling for thi

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 century. Python has no GOTO, but wh

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

2017-09-19 Thread Stefan Behnel
John Ladasky schrieb am 19.09.2017 um 08:54: > I have come to understand from your other posts that adding something to > the stdlib imposes significant constraints on the release schedules of > those modules. I can appreciate the hassle that might cause. Still, > now I wonder what I might be mis

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 German ß. Stefan -- https://mail.pytho

Re: Python 3 removes name binding from outer scope

2017-07-25 Thread Stefan Behnel
Ben Finney schrieb am 25.07.2017 um 08:34: > Ethan Furman writes: > >> Something like: >> >> try: >> >> except ZeroDivisionError as dead_exc: >> exc = dead_exc >> >> >> print(text_template.format(exc=exc) > > That strikes me as busy-work; the

Re: Progress on the Gilectomy

2017-06-10 Thread Stefan Behnel
Serhiy Storchaka schrieb am 11.06.2017 um 07:11: > 10.06.17 15:54, Steve D'Aprano пише: >> Larry Hastings is working on removing the GIL from CPython: >> >> https://lwn.net/Articles/723949/ >> >> For those who don't know the background: >> >> - The GIL (Global Interpreter Lock) is used to ensure th

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 PS

Re: windows utf8 & lxml

2016-12-26 Thread Stefan Behnel
Hi! Sayth Renshaw schrieb am 20.12.2016 um 12:53: > I have been trying to get a script to work on windows that works on mint. The > key blocker has been utf8 errors, most of which I have solved. > > Now however the last error I am trying to overcome, the solution appears to > be to use the .dec

Re: Cython taking more time than regular Python

2016-09-19 Thread Stefan Behnel
Peter Otten schrieb am 19.09.2016 um 14:55: > In [7]: %%cython > def omega(int n): > cdef long i > cdef long result = 0 > for i in range(n): result += i > return result >...: > > In [8]: %timeit omega(10) > 1 loops, best of 3: 91.6 µs per loop Note that this is the wo

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 > is probably the most widely used method It certainly was, years ago, but I honestly doubt

Re: C Python extension to export an Function

2016-09-01 Thread Stefan Behnel
Ganesh Pal schrieb am 01.09.2016 um 14:30: > On Thu, Sep 1, 2016 at 12:32 PM, dieter wrote: >> Ganesh Pal writes: >>> Iam pretty new to C Python extension , I was able to export few simple >>> modules to python and it look like the cool thing to do ... >> >> Maybe, it is a good idea to have a look

Re: Helloworld with Python C extension

2016-08-29 Thread Stefan Behnel
Ganesh Pal schrieb am 29.08.2016 um 19:30: > I need you input on the below hello world program. I a m trying to add a > python binding which will return the character for the given index . I am > on Python 2.7 and linux > > Example : > >>> string ='helloworld' > >>> dda_hello(5) > >>> 'w' >

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
Sivan Greenberg schrieb am 30.07.2016 um 23:15: > I'm wondering about the use of partial in writing parallel code. Is is it > quicker than re-evaluating arguments for a multiple session.get()'s method > with different , for example (of requests) ? > > Or maybe it is used to make sure the argumen

Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Stefan Behnel
Ethan Furman schrieb am 09.07.2016 um 08:27: > On 07/08/2016 10:49 PM, Random832 wrote: >> On Sat, Jul 9, 2016, at 01:26, Steven D'Aprano wrote: > >>> hmean and gmean >>> >>> harmonic_mean and geometric_mean >> >> The latter, definitely. > > My preference is also for the latter. However, if the

Re: Which one is the best XML-parser?

2016-07-02 Thread Stefan Behnel
Random832 schrieb am 24.06.2016 um 15:09: > On Fri, Jun 24, 2016, at 02:39, dieter wrote: >> You want an incremental parser if the XML documents are so huge that >> you must process them incrementally rather than have a data structure >> representing the whole document (in memory). Incremental pars

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

2016-04-21 Thread Stefan Behnel
Random832 schrieb am 21.04.2016 um 18:35: > I was trying to write a proof of concept on including descriptors (e.g. > a "sys.recursionlimit" instead of set/get methods) in the sys module, > and couldn't figure out how to "properly" define a type using > PyType_FromSpecWithBases. Everything I tried

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

2016-04-08 Thread Stefan Behnel
Neal Becker schrieb am 08.04.2016 um 15:27: > I'd like to add -march=native to my pip builds. How can I do this? First of all, make sure you don't install binary packages and wheels. Changing the C compiler flags will require source builds. Then, it should be enough to set the CFLAGS environment

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: Create a .lua fle from Python

2015-10-02 Thread Stefan Behnel
jmp schrieb am 02.10.2015 um 11:03: > Safety is like speed optimization, you care about it only when it can be a > problem. And the vast majority (there's a recent trolling thread about the > equivalent percentage of vast majority if you want to have fun) of python > code may run on trusted network

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

2015-10-01 Thread Stefan Behnel
Chris Warrick schrieb am 01.10.2015 um 18:26: > The Nikola developers decided to deprecate Python 2.7 support. I wonder why it took the Nikola project so long to take that decision. Python 3.3 came out almost exactly three(!) years ago and seems to have all major features that they would require.

Re: XML Binding

2015-09-09 Thread Stefan Behnel
dieter schrieb am 09.09.2015 um 10:20: > Palpandi writes: >> Is it better to use pyxb than lxml? >> >> What are the advantages of lxml and pyxb? > > "pyxb" has a different aim than "lxml". > > "lxml" is a general purpose library to process XML documents. > It gives you an interface to the documen

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
Yuzhi Xu schrieb am 23.08.2015 um 08:10: > I find out that python's VM seems to be very unfriendly with CPU-Cache. > see: > http://stackoverflow.com/questions/32163585/how-to-handle-cpu-cache-in-python-or-fastest-way-to-call-a-function-once > http://stackoverflow.com/questions/32153178/python-funct

Re: Logging to a file from a C-extension

2015-08-19 Thread Stefan Behnel
Al Pfalzgraf schrieb am 18.08.2015 um 15:07: > If a logging file is opened at the level of a Python application, how > would the log file name be communicated to a C-extension so that logging > from the extension would be sent to the same log file? Writing to the file directly (as was suggested) m

Re: Module load times

2015-08-13 Thread Stefan Behnel
Joseph L. Casale schrieb am 13.08.2015 um 18:56: > I have an auto generated module that provides functions exported from a > c dll. Its rather large and we are considering some dynamic code generation > and caching, however before I embark on that I want to test import times. > > As the module is

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
baruc...@gmail.com schrieb am 30.07.2015 um 22:09: > It is written in pure C with the CPython C-API in order to get the highest > possible speed. This is a common fallacy. Cython should still be able to squeeze another bit of performance out of your wrapper for you. It tends to know the C-API bet

Re: Foo.__new__ is what species of method?

2015-07-13 Thread Stefan Behnel
Steven D'Aprano schrieb am 14.07.2015 um 06:54: > On Tuesday 14 July 2015 14:45, Ben Finney wrote: >> The Python reference says of a class ‘__new__’ method:: >> >> object.__new__(cls[, ...]) >> >> Called to create a new instance of class cls. __new__() is a static >> method (special-cas

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
Denis McMahon schrieb am 26.06.2015 um 09:44: > xml data is an unordered list, and are trying to assign an order to it. > > If the xml data was ordered, either each tag would be different, or each > tag would have an attribute specifying a sequence number. XML is not unordered. The document orde

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

2015-06-28 Thread Stefan Behnel
Michael Torrie schrieb am 26.06.2015 um 19:32: > I've never heard of pythran; I'll have to check it out and see how it > compares to the ever-growing crop of Python dialect compilers. My feeling is that Python seems such a simple language at the surface that people who want to write a special purp

Re: Java to Python autoconverters

2015-06-12 Thread Stefan Behnel
Sebastian M Cheung via Python-list schrieb am 12.06.2015 um 13:36: > Are these available? Any good ones to recommend? I recommend not doing that. You'd end up with ugly and unidiomatic Python code that's impossible to maintain, whereas you now (hopefully) have somewhat idiomatic Java code that sho

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://mail.python.org/mailma

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

2015-06-05 Thread Stefan Behnel
Steven D'Aprano schrieb am 05.06.2015 um 16:07: > Sorting in reverse does not give the same result as sorting then reversing. > > It's easiest to see with a key function: > > py> a = ['fox', 'dog', 'DOG', 'cat', 'ape'] > py> b = a[:] > py> a.sort(key=str.lower, reverse=True) > py> b.sort(key=str.

Re: Building an extension module with SWIG

2015-05-30 Thread Stefan Behnel
garyr schrieb am 30.05.2015 um 22:48: > *snip* > >> Compile it ("cythonize -b foo.pyx") and you'll get an extension module >> that >> executes faster than what SWIG would give you and keeps everything in one >> file to improve readability. >> >> [1] http://cython.org/ > > Thanks for your reply. M

Re: Building an extension module with SWIG

2015-05-30 Thread Stefan Behnel
garyr schrieb am 30.05.2015 um 18:22: > I'm trying to create an extension module using SWIG. I've > succeeded in generating a pyd file but when I import the module I get the > error message: "SystemError: dynamic module not initialized properly." I > added an initfoo() function but that didn't solv

Re: Creating a reliable sandboxed Python environment

2015-05-30 Thread Stefan Behnel
Laura Creighton schrieb am 30.05.2015 um 13:24: > As a point of fact, We've _already got_ Topaz, a Ruby interpreter, > Hippy, a PHP interpreter, a Prolog interpreter, a Smalltalk > interpeter, and a javascript interpreter. Recently we got Pyket a > Racket compiler. There also exist plenty of expe

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
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 interested to hear your approach. Not quite sandboxing Python, but I've seen people use my Lupa [1] library for this. They're writing all their code in

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

2015-05-22 Thread Stefan Behnel
Skip Montanaro schrieb am 22.05.2015 um 19:15: > 2015-05-22 12:05 GMT-05:00 Lele Gaifax: >> Maybe http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html? > > Thanks for the reference, Lele. I was thinking in terms of cffi, but > this might work as well. (Shouldn't cffi interfaces be the thin

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

2015-05-10 Thread Stefan Behnel
Steven D'Aprano schrieb am 10.05.2015 um 11:58: > Why is calling a function faster than bypassing the function object and > evaluating the code object itself? And not by a little, but by a lot? > > Here I have a file, eval_test.py: > > # === cut === > from timeit import Timer > > def func(): >

Re: XML Parsing

2015-04-05 Thread Stefan Behnel
Sepideh Ghanavati schrieb am 06.04.2015 um 04:26: > I know basic of python and I have an xml file created from csv which has > three attributes "category", "definition" and "definition description". > I want to parse through xml file and identify actors, constraints, > principal from the text. Howe

Re: Is it possible to deliver different source distributions for different Python versions?

2015-04-05 Thread Stefan Behnel
Dave Hein schrieb am 05.04.2015 um 22:38: > I would like to distribute a python package with different code for > Python 2.* than for Python 3.*. (Mostly this is because of different > unicode string handling). > > There is nothing in to setuptools or PyPi that directly supports > this scenario. >

Re: Speeding up permutations generation

2015-03-06 Thread Stefan Behnel
Ian Kelly schrieb am 06.03.2015 um 18:13: > On Fri, Mar 6, 2015 at 1:24 AM, Abhiram R wrote: >>> A list of 100 elements has approximately 9.33 x 10**157 permutations. >>> If you could somehow generate one permutation every yoctosecond, >>> exhausting them would still take more than a hundred orders

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

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: 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: 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: 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: 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
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: (-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: 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: 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: Clearing globals in CPython

2014-10-02 Thread Stefan Behnel
Chris Angelico schrieb am 02.10.2014 um 16:12: > On Fri, Oct 3, 2014 at 12:07 AM, Grant Edwards wrote: >> On 2014-10-01, Steven D'Aprano wrote: >> >>> Obviously the easiest way to recover is to exit the current session and >>> restart it, but as a challenge, can we recover from this state? >> >> Py

Re: any way to tell at runtime whether a callable is implemented in Python or C ?

2014-09-26 Thread Stefan Behnel
Chris Angelico schrieb am 26.09.2014 um 10:42: > On Fri, Sep 26, 2014 at 5:47 PM, Wolfgang Maier wrote: >> is there any reliable and inexpensive way to inspect a callable from running >> Python code to learn whether it is implemented in Python or C before calling >> into it ? > > I'm not sure you

Re: any way to tell at runtime whether a callable is implemented in Python or C ?

2014-09-26 Thread Stefan Behnel
Wolfgang Maier schrieb am 26.09.2014 um 09:47: > is there any reliable and inexpensive way to inspect a callable from > running Python code to learn whether it is implemented in Python or C > before calling into it ? Not really. Both can have very different types and very different interfaces. The

Re: GCD in Fractions

2014-09-24 Thread Stefan Behnel
blindanagram schrieb am 24.09.2014 um 15:25: > On 24/09/2014 12:44, Steven D'Aprano wrote: > >> blindanagram wrote: > [snip] >> - Mathworld says that GCD of two negative numbers is a negative number; >> >> - but Mathematica says that GCD of two negative numbers is a positive; >> >> - Wikipedia agr

Re: GCD in Fractions

2014-09-23 Thread Stefan Behnel
Ian Kelly schrieb am 23.09.2014 um 19:39: > On Tue, Sep 23, 2014 at 11:26 AM, Stefan Behnel wrote: >> Wolfgang Maier schrieb am 23.09.2014 um 18:38: >>> While at first I thought this to be a rather irrelevant debate over module >>> private vs public naming convent

Re: GCD in Fractions

2014-09-23 Thread Stefan Behnel
blindanagram schrieb am 23.09.2014 um 19:43: > On 23/09/2014 18:26, Stefan Behnel wrote: >> Wolfgang Maier schrieb am 23.09.2014 um 18:38: >>> While at first I thought this to be a rather irrelevant debate over module >>> private vs public naming conventions, I now thi

Re: GCD in Fractions

2014-09-23 Thread Stefan Behnel
Wolfgang Maier schrieb am 23.09.2014 um 18:38: > While at first I thought this to be a rather irrelevant debate over module > private vs public naming conventions, I now think the OP is probably right > and renaming fractions.gcd to fractions._gcd may be a good idea. Making a public API private is

Re: PyCharm refactoring tool?

2014-09-15 Thread Stefan Behnel
George Silva schrieb am 15.09.2014 um 21:49: > It's pretty useful. I use it for some time now and I very much like it. > [...] > The most powerful for me are the rename refactor and extract. Works like > charm (no pun intended). Dito. > On Mon, Sep 15, 2014 at 4:44 PM, Skip Montanaro wrote: >>

Re: pylint for cython?

2014-09-12 Thread Stefan Behnel
Skip Montanaro schrieb am 12.09.2014 um 17:52: > I have slowly been converting some Python source to Cython. I'm pretty > conservative in what changes I make, mostly sprinkling a few "cdef", > "float" and "int" declarations around the pyx file. Still, conservative or > not, it's enough to choke pyl

Re: Python vs C++

2014-08-22 Thread Stefan Behnel
If you want to add Cython to that (overly simplified) graph, you might get something like this: Christian Gollwitzer schrieb am 22.08.2014 um 21:25: > as |--| > c || > c++ |---| Cython || > python|---

Re: error building lxml.etree

2014-08-22 Thread Stefan Behnel
Robin Becker schrieb am 22.08.2014 um 17:50: > I'm trying to build a bunch of extensions in a 2.7 virtual environment on a > centos 7 VM. I don't know centos very well and I understand centos 7 is > quite new > >> building 'lxml.etree' extension >> >> creating build/temp.linux-x86_64-2.7 >> >> cre

Re: Python vs C++

2014-08-21 Thread Stefan Behnel
dieter schrieb am 22.08.2014 um 08:12: > David Palao writes: >> Why to use C++ instead of python? > > Likely, you would not use Python to implement most parts of an > operating system (where, for efficiency reasons, some parts > are even implemented in an assembler language). > > I can imagine t

Re: GIL detector

2014-08-17 Thread Stefan Behnel
Steven D'Aprano schrieb am 17.08.2014 um 16:21: > I wonder whether Ruby programmers are as obsessive about > Ruby's GIL? I actually wonder more whether Python programmers are really all that obsessive about CPython's GIL. Sure, there are always the Loud Guys who speak up when they feel like no-one

Re: What can Nuitka do?

2014-06-27 Thread Stefan Behnel
CM, 28.06.2014 05:57: >> Now type >> >> nuitka --recurse-all something_or_other.py >> >> and hit Enter. What happens? > > I did that and the message is: > >'nuitka' is not recognized as an internal >or external command, operable program or batch file. > > which makes sense becau

  1   2   3   4   5   6   7   8   9   10   >