Page 5 of 16

### Re: Python tricks

Posted: May 22nd, 2019, 2:01 pm
Be careful around the memory leaks in Pandas.
I suppose memory management in the Python-C twilight zone is tricky.
BTW library looks nice.

### Re: Python tricks

Posted: May 23rd, 2019, 6:24 pm
1. I am looking for books on Numpy and Scipy, with focus on the numerical algorithms and background. I am not interested in having to wade in syntax before getting to these topics.

Any suggestions? Thx!
Not a book but maybe also interesting if you look at numpy. Take a look at cupy.

Lets you run the same code on either cpu or gpu by just setting a switch methode.

### Re: Python tricks

Posted: June 4th, 2019, 1:12 pm

### Re: Python tricks

Posted: June 18th, 2019, 8:07 am
The Joy of FP
multiply = lambda x: x*x
expo = lambda x: exp(x)

input = [1,2,3,4]

for func in funcs:
value = list(map(func, a))
print(value)

for i in range(4):
values = map(lambda x: x(i), funcs)
print(values)

### Re: Python tricks

Posted: June 24th, 2019, 2:08 pm
The Joy of FP
multiply = lambda x: x*x
expo = lambda x: exp(x)

input = [1,2,3,4]

for func in funcs:
value = list(map(func, a))
print(value)

for i in range(4):
values = map(lambda x: x(i), funcs)
print(values)

You probably need numpy or math (or cmath!?).
Variable a is not defined.
I would go for list comprehension. (sorry I previously typed in 'list a comprehension').

import numpy as np

multiply = lambda x: x*x
expo = lambda x: np.exp(x)

input = [1,2,3,4]

[list(map(func, input)) for func in funcs]

### Re: Python tricks

Posted: June 24th, 2019, 2:32 pm
Oh, a = [1,2,3]

BTW OOP in Python is a real shocker. Still, it is probably good for scaffolding to prevent cognitive overload?

Funny name, 'comprehension', C++ STL calls it 'transform' and more generic (ignore that remark).

### Re: Python tricks

Posted: July 8th, 2019, 11:10 pm
Oh, a = [1,2,3]

BTW OOP in Python is a real shocker. Still, it is probably good for scaffolding to prevent cognitive overload?

Funny name, 'comprehension', C++ STL calls it 'transform' and more generic (ignore that remark).
I spent some time trying to implement  abstract data structure Red-Black tree. I just gave up. It gets very complicated in python. Coding it using C/C++  is not easy, but a real nightmare in Python. My idea was to reproduce a master template I already coded in C

### Re: Python tricks

Posted: July 9th, 2019, 7:16 am

### Re: Python tricks

Posted: July 9th, 2019, 11:06 am

### Re: Python tricks

Posted: July 9th, 2019, 11:08 am
Python does not support private attributes/member data (?)

### Re: Python tricks

Posted: July 9th, 2019, 12:11 pm
Thanks!!! Now I have no excuses to retake my project!

### Re: Python tricks

Posted: July 9th, 2019, 1:04 pm
If you have a working library in C/C++, you can use it as a shared library in python through Boost.Python. No need to reinvent the wheel.

### Re: Python tricks

Posted: July 9th, 2019, 2:32 pm
Python does not support private attributes/member data (?)
Not really (You already know it, don't you?).

https://docs.python.org/3.7/tutorial/classes.html#tut-private

### Re: Python tricks

Posted: July 9th, 2019, 4:01 pm
If you have a working library in C/C++, you can use it as a shared library in python through Boost.Python. No need to reinvent the wheel.
Indeed.
Creating rb trees in Python must be the closest thing to torture.

### Re: Python tricks

Posted: July 9th, 2019, 4:02 pm
Python does not support private attributes/member data (?)
Not really (You already know it, don't you?).

https://docs.python.org/3.7/tutorial/classes.html#tut-private
This is scary. Meshuggah.

It's just this subtle point will be lost on newbies going forward.