3 Вклад в тег
Mac OS X (10.4) - Finding the IP address and MAC a...
#python -m SimpleHTTPServer 8000 Serving HTTP on 0.0.0.0 port 8000 ...
Pickle is slow
Pickle is both slower and produces larger serialized values than most of the alternatives.
To illustrate this, I put together a simple benchmark comparing pickle to the built in JSON module, the Apache Thrift library, and MessagePack. This benchmark measures the number of objects a second each of these libraries can read and write. The data being serialized here are just randomly generated fake 'Tweet' objects containing just four fields:
Pickle is the clear underperformer here. Even the 'cPickle' extension thats written in C has a serialization rate thats about a quarter that of JSON or Thrift. Pickle also produces serialized values that are around double the size of Thrift or MessagePack.
Warning: The pickle module is not intended to be secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source.
import threading class Repository: def __init__(self): self.__lock=threading.Lock() def add(self): with self.__lock: with open(self.config_path,"r") as json_data: try: data = json.load(json_data) except: logging.critical( "FATAL!!!can't read %s" % data) raise ValueError("can't json.load(%s)" % data)
import MySQLdb #Start a connection db= MySQLdb.connect(host="dbhost", user="dbuser" , passwd="dbpass", db="dbname") db.autocommit(False) cursor = db.cursor() try: cursor.execute("Your SQL") cursor.execute("Another sql") db.commit() except: db.rollback()
# it's example how run [uwsgi] plugins = python27 http-socket = :80 #pythonpath = /srv/myapp #virtualenv = /home/project/ve chdir = /home/project processes = 1 threads = 4 #pythonpath = .. module = manager:app # This line below was important #wsgi-file = manager.py #callable = app # Turn this off for production catch-exceptions = true stats = /.tmp/.uwsgi-stats.socket touch-reload = /.tmp/.uwsgi-reload
Hugo is a general-purpose website framework. Technically speaking, Hugo is a static site generator. This means that, unlike systems like WordPress, Ghost and Drupal, which run on your web server expensively building a page every time a visitor requests one, Hugo does the building when you create your content. Since websites are viewed far more often than they are edited, Hugo is optimized for website viewing while providing a great writing experience.Hugo - документация.