HNHacker News
TopNewBestAskShowJobs

codeape

42 karma · joined July 6, 2010

submissionscomments
codeape··on The Performance Impact of Using dict() Instead of {} in CPython 2.7
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}

codeape··on F# Foundation Launch : Open-source, cross-platform F# (1PM PST/9PM GMT Today)
Is it still based on .NET/mono?
codeape··on Display 100 Hello World Without Using Loops
Why the exec?

    print "Hello world\n" * 100
codeape··on Browse man pages in style with your personal manservant
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.

codeape··on In-memory key-value store in C, Go and Python
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.
codeape··on In-memory key-value store in C, Go and Python
I don't use socket.send/flush. I use sockfile.write/flush.
codeape··on In-memory key-value store in C, Go and Python
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.

codeape··on In-memory key-value store in C, Go and Python
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?

codeape··on SQL Fiddle
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).

codeape··on The lsm command for Latent Semantic Mapping
Is it available on Linux?
codeape··on Ask HN: Postgresql or Sqlite for Python WSGI apps?
Never use SQLite in production if you expect more than one simultaneous user.
codeape··on Ask HN: Web framework independent Python libraries useful for web development.
Werkzeug or WebOb if you're using WSGI.

I like kid and jinja2 for templating.

codeape··on What Android is
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?

codeape··on Ask HN: How will it impact my webapp if it is written in Python instead of PHP.
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.

← PreviousPage 2 of 2