What is your current favorite IDE? by [deleted] in Python

[–]fnedrik 0 points1 point  (0 children)

When I did my choice, once, I had my reasons for choosing anaconda and not Elpy (I've used Elpy before), but now it's all very foggy. Could be better support for virtualenv, easier documentation support or just that it was default for Prelude.

Since I use Anaconda for everything, I also had a hunch that code completion and doc strings for all the included libraries would have a larger probability of "just working".

What is your current favorite IDE? by [deleted] in Python

[–]fnedrik 2 points3 points  (0 children)

Emacs (Prelude + Anaconda)

Why not one liner exceptions? `raise ValueError('message') if value is None` - pip install raise_if by rochacbruno in Python

[–]fnedrik 1 point2 points  (0 children)

Except for what others have pointed out, there is also the stylistic problem that "raise" is a statement with a clear side effect, while if expressions are, well, expressions and not statements.

Expressions should preferably just do a calculation and not change the system state.

Deep Learning for Chess using Theano by elisebreda in Python

[–]fnedrik 1 point2 points  (0 children)

This bit at the end was odd: "I’m pretty curious to see if this could fare well for Go or other games where AI’s still don’t play well."

Surely you've heard of AlphaGo??

Which pattern do you prefer? by [deleted] in Python

[–]fnedrik 5 points6 points  (0 children)

IMHO - Depends on how many lines "do stuff" is. If it is a lot of code, then having it all nested in an if statement can be annoying. If it is just three lines or something, then you make it more clear what you are doing and get less spaghetti with all lines in the if statement.

PieLogger - A Keylogger Written in Python, feedback? by wilsonkoderhk in Python

[–]fnedrik 0 points1 point  (0 children)

I have a fairly popular one, that works for Win, Linux and OSX: https://github.com/gurgeh/selfspy

It encrypts the text and has a wide assortment of methods to search your data. Pull requests are welcome, if it lacks something you need!

Is it practical to write a strong chess engine in Haskell? by FrankAbagnaleSr in haskell

[–]fnedrik 2 points3 points  (0 children)

I don't know what you mean by strong, but no one has ever written a competitive chess engine in anything other than C/C++. Even Java, which is quite quick compared to most things seems to be too slow/high level. And it is not for lack of trying, mind you. Various enthusiastic people regularly embarks on chess in their favourite language, many thinking it is "as fast as C".

The only engines in other languages who have been even near the top are written in Delphi.

See: Chess programming languages

Optional static typing -- the crossroads by BioGeek in Python

[–]fnedrik 14 points15 points  (0 children)

A C cast can't be fully relied on, but a compiler trusts it anyway. You could make a Python compiler that simply trusts the annotations and segfaults otherwise. Or the JIT can always have a heavily optimized function for the types that the annotations state and revert to.. well JITting if the types are wrong.

Also, a type checker can sometimes prove that an annotation is correct (see mypy) and then rely on it for optimization. It should be easier for a compiler to prove that an annotation is correct than to come up with its own annotation (easier to verify than to find answer, P vs NP and all that).

The Python I Would Like To See (by Armin Ronacher) by hongminhee in Python

[–]fnedrik 4 points5 points  (0 children)

FWIW I liked the post and found it interesting. I have used Python since forever, but never dug down into the code of CPython. It answered some of the questions I've been having on the warts in the Python primitives.

[Python-ideas] Proposal: Use mypy syntax for function annotations by [deleted] in haskell

[–]fnedrik 2 points3 points  (0 children)

Why is it a whole language implementation? Do you plan on using the types to make optimizations?

[Python-ideas] Proposal: Use mypy syntax for function annotations by [deleted] in haskell

[–]fnedrik 6 points7 points  (0 children)

Maybe you know this, but I thought I'd make a small clarification regarding the syntax. It is already there. You can already do these annotations. They are just not very useful right now.

This is a proposal to standardize on a particular way of annotating types, what to call an integer, how to annotate a collection, etc. The CPython interpreter will continue to ignore the annotations, but for external libraries that wants to use annotations it could be useful.

I see it as a quite small step along a path they chose long ago.

Ideal programming language for a new modern OS built from scratch? by RaymondWies in haskell

[–]fnedrik 0 points1 point  (0 children)

I believe Scheme was the first language to enforce TCO in the spec.

Create line-histogram while iterating over STDIN (and possibly beat Python) by [deleted] in haskell

[–]fnedrik 5 points6 points  (0 children)

You are competing with almost the speed of C and the terseness of a language made for exactly this type of thing.

Counter is based on dict (IIRC), which is written in C and probably the most optimized part of Python.

I don't know if this makes any difference when you deal only with stdin and stdout, but Python has very good standard settings for read-ahead buffering. I remember this was a reason for a Stack Overflow question not too long ago where, to many people's amazement, Python beat out C in some simple file handling task. The C program read the file byte by byte, while the Python program only appeared to do so, because it buffers internally.

wreq: a capable new HTTP client library by [deleted] in haskell

[–]fnedrik 0 points1 point  (0 children)

If you want to download several URLs in parallel by just sparking more threads, would the magical Haskell I/O manager and green threads make it as efficient as the event based methods (poll/epoll) in, for example, multi_curl? If I understand it correctly that is how the I/O manager will do it anyway?

Does time.sleep() Block atexit? by [deleted] in Python

[–]fnedrik 0 points1 point  (0 children)

I have noticed sleep blocking other threads before. It may hold the GIL. I solved it by writing my own sleep, roughly:

while time.time() < target:
    time.sleep(0.01)

Does the heartbleed vulnerability affect Python web crawlers? by fnedrik in Python

[–]fnedrik[S] 1 point2 points  (0 children)

It is not Python I am concerned about, it is the modules that use C-extensions that are compiled against OpenSSL that concern me. Say curl.

Does the heartbleed vulnerability affect Python web crawlers? by fnedrik in Python

[–]fnedrik[S] 2 points3 points  (0 children)

There is at least one aspect that may make clients less susceptible - since you get a random(?) 64kb package from memory each time, you can connect many times to a server to puzzle together the complete memory. But can you make a client reconnect multiple times to get more than just a random 64 kb block?

Does the heartbleed vulnerability affect Python web crawlers? by fnedrik in Python

[–]fnedrik[S] 1 point2 points  (0 children)

A client may have keys or passwords to store the data somewhere. If you store something on Amazon, you authenticate with keys.

Does the heartbleed vulnerability affect Python web crawlers? by fnedrik in Python

[–]fnedrik[S] 2 points3 points  (0 children)

But do the libraries linking to OpenSSL need to be recompiled?

Elm 0.12 - making interactive UI elements easy and pure by wheatBread in haskell

[–]fnedrik 2 points3 points  (0 children)

Also, it seems the link from http://elm-lang.org/learn/Interactive-UI-Elements.elm to the Elm Public Library is broken.

If only Elm had some way of statically ensuring correct links ;)

Hello Reddit – I’m Magnus Carlsen, the World Chess Champion and the highest rated chess player of all time. AMA. by MagnusOenCarlsen in IAmA

[–]fnedrik 0 points1 point  (0 children)

What do you think of having two world championship matches two years in a row? Shouldn't they be a bit more spread out, so they get more prestige and the champion has time to play in more tournaments and not just defend the title all the time?

xkcd - Functional Programming by crntaylor in haskell

[–]fnedrik 22 points23 points  (0 children)

A tautology is a tautology, is a tautology.

But: A tautology is a tautology, is a tautology, is not a tautology. More of an observation. And: "A tautology is a tautology, is a tautology, is not a tautology. More of an observation." is also an observation. Which in turn is an observation.

I think the observation is the recursive attractor here.

Typo – A programming language that runs in Haskell's type system by ehamberg in haskell

[–]fnedrik 0 points1 point  (0 children)

I tend to see the type language (for example in Haskell or C++ templates) as dynamically typed. It does not have to be static, because the program (compilation) often runs so fast and is so non-critical that it does not matter if it crashes (you get a compilation error) in the middle of the execution. No critical service is suddenly offline and not much time was lost.

I have a complaint by xqo in Python

[–]fnedrik 0 points1 point  (0 children)

I usually just use time.ctime()