[Python-announce] Brand new: Line Profiler GUI v0.1

2022-02-08 Thread Joseph Martinot-Lagarde
Hi all,
In the dark moments of code optimization, line_profiler from Robert Kern (now 
https://github.com/pyutils/line_profiler) helped me a lot. To ease the usage of 
this tool I created a GUI, namely "Line Profiler GUI".
The installation is just a pip command away (choose your favorite python Qt 
binding):

$ pip install line-profiler-gui[PySide2]
$ pip install line-profiler-gui[PyQt5]

The code is available on Github: https://github.com/Nodd/lineprofilergui

Happy optimization!
Joseph
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[issue33646] os.fspath() bypasses __fspath__ for str subclasses

2018-05-25 Thread Joseph Martinot-Lagarde

New submission from Joseph Martinot-Lagarde <contreba...@gmail.com>:

os.fspath() returns its argument if it is a str. That means that it bypasses 
__fspath__ for str subclasses.

This is the case for the library path.py for example.

This is a corner case that was discovered while trying to fix 
https://github.com/matplotlib/matplotlib/issues/11306

Minimal example:

```
import os

class MyPath(str):
def __fspath__(self):
print("Returns a pure string")
return str(self)

os.fspath(MyPath())  # Prints nothing
```

--
components: Library (Lib)
messages: 317666
nosy: contrebasse
priority: normal
severity: normal
status: open
title: os.fspath() bypasses __fspath__ for str subclasses
type: behavior
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33646>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Python vs C++

2014-08-24 Thread Joseph Martinot-Lagarde

Le 23/08/2014 16:21, Chris Angelico a écrit :

On Sun, Aug 24, 2014 at 12:02 AM, Ian Kelly ian.g.ke...@gmail.com wrote:

I don't know how fast lilypond is, but perhaps one could write an editor
that wraps lilypond and invokes it in realtime to show the output in an
adjacent panel, perhaps with a brief delay when the user stops typing.


You theoretically could, but it'd be a bit awkward in places. It's not
hard for a small textual change to result in a large visual change (eg
if you use relative notes and add/remove an octave shift - it'll shift
every subsequent note in the staff, which might mean more/less ledger
lines needed, which will affect how much vertical space the staff
needs, which will affect pagination...), so it'd often make for rather
nasty flicker. Better to keep it explicit.

ChrisA

Frescobaldi (http://www.frescobaldi.org/) works exactly like this. It's 
like a latex IDE but for lilypond. It's quite powerfull and 
multiplatform. I use it exclusively now, it's way better that the bash 
script I used before that more or less rebuild the files when changed.


This way you get the power of plain text and you have an almost 
instantaneous snapshot of the end result.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-22 Thread Joseph Martinot-Lagarde

Le 22/08/2014 02:26, Chris Angelico a écrit :

On Fri, Aug 22, 2014 at 4:05 AM, Joseph Martinot-Lagarde
joseph.martinot-laga...@m4x.org wrote:

For information, Cython works with C++ now:
http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html.


Now isn't that cool!

Every time Cython gets discussed, I get a renewed desire to learn it.
Trouble is, I don't have any project that calls for it - there's
nothing I'm desperately wanting to do that involves both Python and
C/C++. Anyone got any suggestions? :)

ChrisA


A python API for OpenSceneGraph ? I wouldn't use cython for this, though...

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-21 Thread Joseph Martinot-Lagarde

Le 21/08/2014 15:40, Chris Angelico a écrit :

On Thu, Aug 21, 2014 at 10:54 PM, David Palao dpalao.pyt...@gmail.com wrote:

Why to use C++ instead of python?

This is, perhaps, a bit off-topic, but I really want to know the
thoughts of experienced python programmers on it.


No, it's a fair question. Why are we all here?

The fact is, there's not a huge amount of reason left. If you're
linking against a C++ API, you may find it easiest to do the whole
program in C++, rather than use something like Cython (which, as far
as I'm aware, is C-only) or write a two-part project. And obviously if
you have an existing C++ codebase, then porting it has costs, and
maintaining it is probably better. But for the most part, I would
strongly recommend starting a project in a high level language like
Python unless there's a really compelling reason to do otherwise. C++
has, of late, been growing a number of features that belong in higher
level languages; but if you want those sorts of features, why not just
grab Python or Pike or something and save yourself the trouble?


For information, Cython works with C++ now: 
http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html.


Joseph

--
https://mail.python.org/mailman/listinfo/python-list


Re: IDE for python

2014-06-03 Thread Joseph Martinot-Lagarde

Le 28/05/2014 13:31, Sameer Rathoud a écrit :

I was searching for spyder, but didn't got any helpful installable.


What problem did you encounter while trying to install spyder ?

Spyder is oriented towards scientific applications, but can be used as a 
general python IDE. I use it for GUI development too.


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: How can this assert() ever trigger?

2014-05-13 Thread Joseph Martinot-Lagarde

Le 13/05/2014 11:56, Albert van der Horst a écrit :

In article mailman.9917.1399914607.18130.python-l...@python.org,
Joseph Martinot-Lagarde  joseph.martinot-laga...@m4x.org wrote:

Le 10/05/2014 17:24, Albert van der Horst a écrit :

I have the following code for calculating the determinant of
a matrix. It works inasfar that it gives the same result as an
octave program on a same matrix.

/ 

def determinant( mat ):

..

  result = lastr[jx]
  assert(result0.)

...

  assert(result0.)
  nom *= result   # Compenstate for multiplying a row.

...

  assert(nom0.)

..


/-

Now on some matrices the assert triggers, meaning that nom is zero.
How can that ever happen? mon start out as 1. and gets multiplied
with a number that is asserted to be not zero.

Any hints appreciated.

Groetjes Albert


I know it's not the question, but if you want a replacement for octave
did you try numpy (and scipy) ? The determinant would be computer faster
and with less memory than with your function.


I'm using several programming languages in a mix to solve Euler problems.
This is about learning how octave compares to python for a certain kind of
problem as anything.
The determinant program I had lying around, but it was infinite precision
with integer only arithmetic. Then I made a simple modification and got
mad because I didn't understand why it didn't work.

I have used numpy and its det before, but I find it difficult to
remember how to create a matrix in numpy. This is the kind of thing
that is hard to find in the docs. Now I looked it up in my old
programs: you start a matrix with the zeroes() function.

I expect the built in determinant of octave to be on a par with corresponding
python libraries.



---


Groetjes Albert



You can use numpy.zeros(), but you can also use the same list of lists 
that you use for your problem.


Transform a list of lists into a numpy array:
 np.asarray([[1, 2],[3, 4]])
array([[1, 2],
   [3, 4]])

Use a numpy function directly on a list of lists (works for must numpy 
functions):

 np.linalg.det([[1, 2],[3, 4]])
-2.0004

More info on array creation: 
http://wiki.scipy.org/Tentative_NumPy_Tutorial#head-d3f8e5fe9b903f3c3b2a5c0dfceb60d71602cf93


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


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

2014-05-12 Thread Joseph Martinot-Lagarde

Le 10/05/2014 19:07, esaw...@gmail.com a écrit :

Hi All--

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 definitive answers to my questions, below.  I had run into 
many mostly installation problems that I could never get NumPy or SciPy to work 
with Python 3.3 or newer.  I am using Windows7 64 bit OS.
A few questions:
1.  What are the latest versions of NumPy and SciPy that are compatible 
with Python 3.3 or newer and Windows7 64 bit?
2.  What is the best source to download and install them on my computer?
3.  Are they all installable on my OS w/o any major problems/addition?
4.  In the long run, would it be better to use UNIX instead of Windows, if 
I were to use Python for all of my research?
Thanks in advance. EK

Building the scientific libraries on windows is very tricky because you 
need a compatible C and Fortran compiler, as well as some libraries. The 
usual and recommended route is to use python distributions where the 
most used libraries are installed. You can still use pip to install 
additionnal packages. You have a list over here: 
http://www.scipy.org/install.html


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: How can this assert() ever trigger?

2014-05-12 Thread Joseph Martinot-Lagarde

Le 10/05/2014 17:24, Albert van der Horst a écrit :

I have the following code for calculating the determinant of
a matrix. It works inasfar that it gives the same result as an
octave program on a same matrix.

/ 

def determinant( mat ):
 ''' Return the determinant of the n by n matrix mat
 i row j column
 Destroys mat ! '''
 #print getting determinat of, mat
 n=len(mat)
 nom = 1.
 if n == 1: return mat[0][0]
 lastr = mat.pop()
 jx=-1
 for j in xrange(n):
if lastr[j]:
jx=j
break
 if jx==-1: return 0.
 result = lastr[jx]
 assert(result0.)
 # Make column jx zero by subtracting a multiple of the last row.
 for i in xrange(n-1):
 pivot = mat[i][jx]
 if 0. == pivot: continue
 assert(result0.)
 nom *= result   # Compenstate for multiplying a row.
 for j in xrange(n):
 mat[i][j] *= result
 for j in xrange(n):
 mat[i][j] -= pivot*lastr[j]
 # Remove colunm jx
 for i in xrange(n-1):
x= mat[i].pop(jx)
assert( x==0 )

 if (n-1+jx)%20: result = -result
 det = determinant( mat )
 assert(nom0.)
 return result*det/nom

/-

Now on some matrices the assert triggers, meaning that nom is zero.
How can that ever happen? mon start out as 1. and gets multiplied
with a number that is asserted to be not zero.

Any hints appreciated.

Groetjes Albert

I know it's not the question, but if you want a replacement for octave 
did you try numpy (and scipy) ? The determinant would be computer faster 
and with less memory than with your function.


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: The “does Python have variables?” debate

2014-05-08 Thread Joseph Martinot-Lagarde

Le 08/05/2014 02:35, Ben Finney a écrit :

Marko Rauhamaa ma...@pacujo.net writes:


Ben Finney b...@benfinney.id.au:


That's why I always try to say “Python doesn't have variables the way
you might know from many other languages”,


Please elaborate. To me, Python variables are like variables in all
programming languages I know.


Many established and still-popular languages have the following
behaviour::

 # pseudocode

 foo = [1, 2, 3]
 bar = foo  # bar gets the value [1, 2, 3]
 assert foo == bar  # succeeds
 foo[1] = spam# foo is now == [1, spam, 3]
 assert foo == bar  # FAILS, ‘bar’ == [1, 2, 3]

This is because such languages treat each variable as “containing” a
value. Assignment puts another copy of the value in the variable, after
which those two values have a distinct history. What happens to one
value does not affect the other.

Python, on the other hand, has this behaviour::

 foo = [1, 2, 3]
 bar = foo  # ‘bar’ binds to the value ‘[1, 2, 3]’
 assert foo == bar  # succeeds
 foo[1] = spam# ‘foo’ *and* ‘bar’ now == [1, spam, 3]
 assert foo == bar  # succeeds, ‘bar’ is bound to ‘[1, spam, 3]’

The assignment statement in Python does not put a value in a container,
the way it does for variables in many popular languages. Instead,
assignment binds the left-hand-side reference (in these examples, names)
to the right-hand-side value. Both remain references to the same value
until the binding changes to some other value.

So Python doesn't have variables in the way programmers coming from many
other languages expect. Instead, it has references bound to values.

For me, names bound to values is the same concept as pointer pointing to 
memory. bar = foo copies the pointer and not the underlying memory. This 
is not a foreign concept to C programmers.



---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list