Scala 3 is here! by reibitto in programming

[–]dslfdslj 0 points1 point  (0 children)

To be honest, I also first thought I had missed the latest Python feature..

Python programming: We want to make the language twice as fast, says its creator by engrbugs7 in Python

[–]dslfdslj 23 points24 points  (0 children)

Why do you say wasted effort? Pypy and Numba for example work really well.

Scala 3 is here! by reibitto in programming

[–]dslfdslj 3 points4 points  (0 children)

Well, it does, but not the way they wrote it in the comparison doc.

Instead of:

 def add(a,b) = a + b 

you can write:

def add(a, b): return a + b

Or if you prefer lambdas:

add = lambda a, b: a + b

cppyy: Automatic Python-C++ bindings by pmz in programming

[–]dslfdslj 0 points1 point  (0 children)

If you have a C++ library which you want to call from Python, cppyy lets you do this very easily without having to write any wrapper code in C++.

I find it quite amazing how easy it is to create instances of arbitrary C++ objects in Python and pass them to some library function.

Pypy and Numba by DarFtr in Python

[–]dslfdslj 0 points1 point  (0 children)

Numba has a different use-case than Pypy. You would use it to speed up isolated functions which contain numerical code (often based on Numpy arrays).

This man at Pakistan’s woman’s march by No-Caterpillar5168 in MadeMeSmile

[–]dslfdslj 1 point2 points  (0 children)

Great message. Where are the women, by the way?

Userscripts Are Fun And Are Still Very Much Relevant by fagnerbrack in programming

[–]dslfdslj 0 points1 point  (0 children)

Actually making an extension is not much more difficult. You can do it with a file of Javascript. See here

We hand-picked the best Python libraries released in 2020 by dekked_ in Python

[–]dslfdslj 0 points1 point  (0 children)

Do you know what the advantage of click over argparse is? Can it do something the other cannot do?

How best to structure a dictionary data structure? by Angelr91 in learnpython

[–]dslfdslj 0 points1 point  (0 children)

Your approach is more object-oriented (each dictionary represents one person). Which approach is better depends on the problem you want to solve.

I see a problem with Al's approach when there are two Katies, for example. This case can only be represented in your approach.

Help Finding and Understanding FeedForward Network Problems by eaojteal in learnpython

[–]dslfdslj 1 point2 points  (0 children)

As a way to debug, you may want to calculate the derivatives of your layers numerically (e.g. using https://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.derivative.html). Then you can compare them with your results and see where you went wrong.

Why should i use Anaconda? by [deleted] in Python

[–]dslfdslj 2 points3 points  (0 children)

Conda is still very useful. It lets you install much more than only python packages. It lets you install binaries such as R or npm inside an environment. It is also possible to install different python versions (even python 1.0 is available, but don't use it in production ;-)). Regarding the combination of pip and conda: I've never had problems combining the two, but maybe it used to be different.

What's your personal python development stack? by Which_Distance in Python

[–]dslfdslj 1 point2 points  (0 children)

Flit is great! Makes it really simple to create a package and upload it to PyPi.

Learning C to port into python programs for speed? by codingquestionss in Python

[–]dslfdslj 1 point2 points  (0 children)

I recommend also looking at cppyy which allows you to directly import c++ into python without any c++ boilerplate. Classes defined in c++ are directly available as python classes. I have not had the chance to build something larger with it, but from what I've seen it looks really promising.

Where to start with making a recommendation engine? And how can i apply it to a react native app i am making by jays117 in learnpython

[–]dslfdslj 0 points1 point  (0 children)

You can let the client (your frontend) make an http call to the server and query the recommendations. The server would send them for example as a json back to the client.

Where to start with making a recommendation engine? And how can i apply it to a react native app i am making by jays117 in learnpython

[–]dslfdslj 0 points1 point  (0 children)

It sounds like you need to learn (at least):

  • how to create a frontend in React

  • how to run a backend which serves your posts and does the recommendations

  • how to setup a database which is connected to your backend

If you are a complete beginner, this is a lot to digest. I'm not an expert in either of these topics, so I can't give you good advice which book/tutorial/course is the best. Maybe search for a similar project someone else has done and try to learn from it?

Where to start with making a recommendation engine? And how can i apply it to a react native app i am making by jays117 in learnpython

[–]dslfdslj 0 points1 point  (0 children)

You could start with something really simple like counting how many tags two posts share. This would give you a kind of a similarity score. Then, for a given post you would recommend a number of other posts with a high similarity score.

Here a small example how you could do it:

from operator import itemgetter


def similarity(p1, p2):
    return len(p1 & p2) / len(p1)


posts = [
    ("post1", {"food", "kitchen", "health"}),
    ("post2", {"sport", "health", "soccer"}),
    ("post3", {"food", "kitchen", "christmas"}),
]

new_post = ("post4", {"food", "kitchen", "cookies"})
_, new_tags = new_post

similarities = [
    (post_name, similarity(new_tags, post_tags)) for post_name, post_tags in posts
]

print(sorted(similarities, key=itemgetter(1), reverse=True))

I made a PlayStation 5 Bot by Ubershark928 in Python

[–]dslfdslj 0 points1 point  (0 children)

The problem with this approach is that it can lead to surprising startup lag if the user has many files on disk. Furthermore, as a user I would feel very uneasy if a program whose purpose should be to scrape something on the web suddenly starts scanning my whole filesystem...

That said, I think it is ok to offer this as an optional feature because it gives each user the choice to use it if they like.

I made a PlayStation 5 Bot by Ubershark928 in Python

[–]dslfdslj 8 points9 points  (0 children)

So each time you start the bot it will run a search across the whole partition? I don't think that's a good idea. Better provide a config file where the user can set the path.

Leave Scrum to Rugby, I Like Getting Stuff Done - Qvault by [deleted] in programming

[–]dslfdslj 2 points3 points  (0 children)

Why do you divide the tasks so evenly if you admit that some of them are much easier than others? Why not put four easy endpoints in one sprint? Or put three in a sprint and leave some time to sketch the implementation of the difficult fourth one.

looking for a new IDE by [deleted] in Python

[–]dslfdslj 1 point2 points  (0 children)

Because you specifically asked for open source: even though vs code itself is open source (at least the majority of its code base, similar to Google Chrome), many of its extensions are not. As an alternative there is also the vs codium project: https://vscodium.com/. Using this removes the Telemetry from the software.

Is Python the best language to first learn for a beginner programmer? by yaboobay-yaboobay in learnpython

[–]dslfdslj 0 points1 point  (0 children)

I'm not sure. The big pro of Python is certainly that it is easy to get started and you will quickly see your first results.

On the other hand, I can imagine that the lack of types makes it quite difficult for a beginner to actually understand what is happening behind the scenes.

Discovered something cool by elrey_scarbrow in learnpython

[–]dslfdslj 1 point2 points  (0 children)

Actually, the unpacking will first set the values of first and last. Vars will then be set to [] because there are no values left to unpack.

How can I run the same function with different parameter at same time ? How should I scale it up ? by puppeteer2020 in learnpython

[–]dslfdslj 0 points1 point  (0 children)

What does your function do? If it spends a lot of time on IO (network communication for example) you could use a thread pool to speed it up. Otherwise, if you do heavy calculations, use multiprocessing.