News for hackers. Stuff that matters.

codeape

From the article:

    I’ve been reviewing lot of code lately for various open 
    source and internal projects written in Python. As part of 
    those reviews, I have noticed what I think is a trend 
    toward using dict() instead of {} to create dictionaries. I 
    don’t know exactly why this trend has emerged.
My guess for why this trend has emerged: People prefer javascripts object literal syntax where the attribute names are not quoted.

After writing javascript:

var o = { a: 1, b: 2};

... it feels a bit clunky to write Python:

o = { "a": 1, "b": 2}

Is it still based on .NET/mono?
Re:Display 100 Hello World Without Using Loops on Friday May 25, 2012 @06:33AM (#4022876)
Why the exec?

    print "Hello world\n" * 100
Re:Browse man pages in style with your personal manservant on Thursday May 03, 2012 @07:20AM (#3923236)
I believe html manpages are built in to most Linux distros' default apache install (or at least easy to set up).

http://localhost/cgi-bin/man/man2html

At least on Ubuntu, after apt-get install apache2, the URL above works.

Re:In-memory key-value store in C, Go and Python on Wednesday March 21, 2012 @07:31AM (#3733872)
The reason the python version is slow is (I believe) that the code is very inefficient. It uses socket.sendall() instead of sockfile.write/flush. Using sockfile.write/flush speeds it up from 50 requests/second to 7k requests/second on my machine.
Re:In-memory key-value store in C, Go and Python on Wednesday March 21, 2012 @06:27AM (#3733764)
I don't use socket.send/flush. I use sockfile.write/flush.
Re:In-memory key-value store in C, Go and Python on Wednesday March 21, 2012 @06:02AM (#3733723)
I changed memg.py to use sockfile.write()/.flush() instead of socket.sendall().

This makes the memg.py server > x100 faster. It outperforms a gevent-based implementation by 10%.

See https://github.com/codeape2/Key-Value-Polyglot/commit/cbc53a...

EDIT: It does not outperform the gevent-based implementation. More performance testing indicates that gevent is around 2x faster. But it outperforms the original version by an order of magnitude.

Re:In-memory key-value store in C, Go and Python on Wednesday March 21, 2012 @05:01AM (#3733621)
I lack knowledge on networking/event-based systems on a fundamental level.

Here's what I don't understand:

* test.py is sequential: It first does 500 sets then 500 gets, all in one thread, using a single connection to the server.

* The socket handling function (memg.py:handle_con/memg-diesel.py:handle_con) is called once. There is no parallell execution going on.

* So why is the memg-diesel.py code so much faster? What makes the code for sending and receiving data to/from the socket so much faster?

Could someone please explain to me why an epoll-based solution is so much faster?

Re:SQL Fiddle on Thursday February 02, 2012 @05:07AM (#3542127)
Great work, love it!

An idea: Integrate with different ORMs (Python SQLAlchemy, Ruby ActiveRecord etc.) and let users execute code against the schemas.

http://imgur.com/O5PoV

Would obviously require a sandboxed execution environment, like some of the pastebins that allow code execution (for instance http://codepad.org).

Re:The lsm command for Latent Semantic Mapping on Friday June 24, 2011 @08:52AM (#2691970)
Is it available on Linux?
Re:Ask HN: Postgresql or Sqlite for Python WSGI apps? on Monday May 30, 2011 @05:46AM (#2598956)
Never use SQLite in production if you expect more than one simultaneous user.
Werkzeug or WebOb if you're using WSGI.

I like kid and jinja2 for templating.

Re:What Android is on Wednesday November 24, 2010 @10:13AM (#1937548)
Questions:

* Is it possible to use the Android as a Linux development platform?

* Can I compile POSIX sources on the Android?

* For instance, can I download bash, Vim and Python tarballs to an Android device and build?

Could not agree more.

My default stack is Werkzeug+SQLAlchemy+Jinja2. Deployed on Apache/mod_wsgi. If a customer wants Windows/IIS, I deploy using isapi-wsgi.