Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am writing a Python AI book right now and I am using version 3.11. Since I am a patient person, I prefer conda to avoid dependency issues, so: conda create --name py3.11 python=3.11 -c conda-forge

Being a Lisp developer (for 40 years), I am finally developing some love for Python after years of having to use it at work for deep learning.

For me the better performance/lower resource improvements in 3.11 (looking forward to 3.12) is a big issue because I compare to Common Lisp performance, which can be very good.

Off topic, but my new found love for Python comes from realizing that many programming tasks can be done so much faster in Python.



> many programming tasks can be done so much faster in Python.

Same here. I came to Python because I'm lazy ;-)

I stayed because the language is elegant and the community is simply outstanding.


The difference in speed is still huge, for example sbcl

  (time (loop for i from 1 below (expt 10 8) by 2 when 
      (zerop (rem i 3) count t)) 
this takes 0.131 seconds

versus python

  import time
  def gato():
    start = time.time()
    s = sum(1 if i % 3 == 0 else 0  for i in       range(1,10\**8,2))
    end = time.time()
    print(s)
    print(end-start)

  gato() 
takes 2.26 seconds, that is 20 times the sbcl version (I am using python 3.10.6)


Doesn't showing this in 3.10 defeat the point of the post and the gp comment?


You are right, since the post say that the performance of 3.11 can be 2x that of 3.10, the implication is that python 3.11 is ten times slower on loop related code than sbcl. Anyway, a 2x improvement is a great feast for python 3.11, congratulations to the team.


And now do it in numba or numpy, which everyone doing serious calculations would do.


it's a very small thing, but the booleans in python can be added like integers, with True being 1 an False being 0. So your comprehension could have been:

    s = sum(i % 3 for i in range(1, 10\*8, 2))


i % 3 is three-valued: 0, 1 or 2.


I think OP meant to do this:

    s = sum(i % 3 == 0 for i in range(1, 10\*8, 2))


As someone that knows Python since version 1.6, that is what kind of always has irritated me.

Sure the language isn't Lisp, but it comes close enough, only to be let down by lack of performance focus, and PyPy never got the spotlight it deserves.

So I kept using Python only for sysadmin stuff when targeting UNIX like workflows.

Finally, it is looking like I can eventually some day reach out for Python in tasks where performace matters.


> Off topic, but my new found love for Python comes from realizing that many programming tasks can be done so much faster in Python.

There's a "freedom of expression" that python has that other languages such as Java/Go lacks. C++ can have similar expressive power by overloading operators, then this was of course eschewed by Java and Go. Go and Java provide a framework for writing code their way. Python doesn't insist you use OOP methodologies, if you don't want (e.g.)

I built a data conversion system in python using the ">>" operator to simplify translation of data.

    temp_f = json_data["temp_c"] >> if_none(use=0) >> to_decimal() >> round(places=4) >> convert_to_f()
For large data structures this becomes tedious with if/elif/else statements and null checking for a small piece of data. Particularly if you're going to translate one large data structure to another.


Python is OOP to its bones, even basic types are instances of specific classes.

    >>> i = 12
    >>> type(i)
    <class 'int'>
    >>> dir(i)
    ['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__',         '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__',         '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__',     '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__',     '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__',     '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag',     'numerator', 'real', 'to_bytes']


I think you got downvoted for the operator overloading but as long as it's used with intention you're fine. Python itself abuses bitwise or for types, everyone's darling SQLAlchemy overloads all the comparators to make filter expressions. Testing libs also overload comparisons to make matchers.


People dislike python these days on there, for whatever reason. HN is not the place I like to discuss programming anymore.


That's pretty neat! Is it packaged up into a library somewhere or is it proprietary?


As an experienced Python dev... Python's "convenience" and "soeed of iteration" completely falls apart when you have more than half a dozen people working on the same codebase of varying development experience. You spend so much time digging yourself out of abuses of internal APIs.


Microservices is the answer. You limit the Python code to completely separate 3k line programs that talk over an message queue. If a junior screws up a service just bin it and rewrite it.


I'm not doing web dev, closer to scientific research.


> Off topic, but my new found love for Python comes from realizing that many programming tasks can be done so much faster in Python.

Wait till you get ahold of ruby. It is the most LISP like language I've found yet in terms of flexibility and what it can do for you.


Ruby is definitely great and I would have totally agreed a couple years ago, but Elixir has blown my mind. It feels so much like LISP sometimes I wonder, especially with the full macro system where you can operate directly on the AST :-D

Given the recent news on Nx and Livebook, Elixir may be a first-class language for ML very soon.

On a related note, Elixir feels a bit like a functional love child of ruby and python.


Can you write general purpose scripts in Elixir like in Ruby or Python?


Yup, you can write standalone Elixir scripts. Running "elixir myscript.exs" gives you that.


And with Mix.install/2 [0] you have access to the entire ecosystem.

Here are a few examples: https://github.com/wojtekmach/mix_install_examples

[0]: https://hexdocs.pm/mix/1.12.3/Mix.html#install/2


If you’re in data science related fields python is kind of a must. Ruby has most of the same libraries but not all of them.

Plus at a certain point the people you have to deal with only know python.


Ruby was my main language from 2002 to about 2005. I ended up migrating back to Common Lisp.


I wonder is there is something similar to the expert system powerloom in python. I hope you get some inspiration from ARIMA (Norvig Book with python code). Also using ontologies with triples in python should be slow for inference.


Unrelated, but I'm wishing to learn lisp myself. I started with Cloture since I have experience with the Java ecosystem. What resources do you recommend for learning Lisp?


I think Racket Scheme is an excellent place to start. "All batteries included", bundled multi-platform IDE (also great with Emacs).


Here's a recently compiled list of good Clojure learning resources:

https://gist.github.com/ssrihari/0bf159afb781eef7cc552a1a0b1...

Edit: if by "learning Lisp" you mean lisps other than Clojure, I don't know :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: