[Python-checkins] r46345 - sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/setup.py sandbox/trunk/hotbuffer/test_hotbuf.py
martin.blais
python-checkins at python.org
Fri May 26 17:48:19 CEST 2006
Author: martin.blais
Date: Fri May 26 17:48:18 2006
New Revision: 46345
Added:
sandbox/trunk/hotbuffer/setup.py (contents, props changed)
Modified:
sandbox/trunk/hotbuffer/README.txt
sandbox/trunk/hotbuffer/test_hotbuf.py
Log:
Modified: sandbox/trunk/hotbuffer/README.txt
==============================================================================
--- sandbox/trunk/hotbuffer/README.txt (original)
+++ sandbox/trunk/hotbuffer/README.txt Fri May 26 17:48:18 2006
@@ -10,104 +10,73 @@
network I/O that avoids creating temporary strings and from which binary data
can be directly decoded.
+.. contents::
+..
+ 1 TODO
+ 1.1 Features
+ 1.2 Document
+ 1.3 Convert from ASCII formats
+ 2 Notes on the Java NIO / ByteBuffer
-
-* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC
-* We need to make the client more easily remove the calls to remaining()
+TODO
+====
-* FIXME make it possible to read from a file directly into a hotbuf!!
+* Run oprofile on the code
-* Write a smallish PEP about it
-* Measure performance results before all of this
-* Move the branch to the sandbox
+* Need to select between PyObject_MALLOC and PyObject_MEMMALLOC
-* FIXME we need to find a way to automatically advance position without doing it
- in Python
+* We need to make the client more easily remove the calls to remaining()
-* FIXME remove Py_XDECREF where possible
+* Make it possible to read from a file directly into a hotbuf
-* FIXME implement the file protocol (read(), write()) on the buffer object
+ - implement the file protocol (read(), write()) on the buffer object
+ - is there a file protocol?
-* We need to be able to convert from ascii formats, e.g. long with an offset
- (Runar, the long conversions)
+Features
+--------
-* Change the mark stuff
+* Change the mark, this will make the loop easier to understand
* setmark() to save both the position and limit
* remove the special behaviours of the mark being discarded
* reset() should reset both the position and the limit
* setmark() becomes push(), reset() becomes pop()
-
-
-For reading from and writing to network buffers.
-
-Look at:
-
-* Java ByteBuffer class
-* SocketChannel
-* nio classes
-
-
-Maybe rename to “seribuf”, or “netbuf”?
-
-
-TODO
-====
-- How do we automatically advance the pointer on pack and unpack?
-
-
- Add hash function
+
- Add support for some of the other sequence methods.
+
- Perhaps implement returning the buffer object itself from some of
+
the methods in order to allow chaining of operations on a single line.
-- Implement a resize function
-- Maybe remove the API methods declared at the top.
-- Add support for big vs. little endian
+- Implement a resize function
-Pending Issues
-==============
- Should we support weakrefs?
-Java NIO / ByteBuffer
-=====================
+Document
+--------
-We need to provide position/limit/mark/reset
-
- A buffer is a linear, finite sequence of elements of a specific primitive
- type. Aside from its content, the essential properties of a buffer are its
- capacity, limit, and position:
-
- A buffer's capacity is the number of elements it contains. The capacity of a
- buffer is never negative and never changes.
-
- A buffer's limit is the index of the first element that should not be read
- or written. A buffer's limit is never negative and is never greater than its
- capacity.
-
- A buffer's position is the index of the next element to be read or
- written. A buffer's position is never negative and is never greater than its
- limit.
+* Write a smallish PEP about it
+* Remove Py_XDECREF where possible
-Invariants
-----------
+Convert from ASCII formats
+--------------------------
-The following invariant holds for the mark, position, limit, and capacity values:
+* We need to be able to convert from ascii formats, e.g. long with an offset
+ (Runar, the long conversions)
- 0 <= mark <= position <= limit <= capacity
-A newly-created buffer always has a position of zero and a mark that is
-undefined. The initial limit may be zero, or it may be some other value that
-depends upon the type of the buffer and the manner in which it is
-constructed. The initial content of a buffer is, in general, undefined.
-Implementation
---------------
+Notes on the Java NIO / ByteBuffer
+==================================
-* Write extensive documentation
+Inspired from the interaction of:
+* Java ByteBuffer class
+* SocketChannel
+* NIO classes
Added: sandbox/trunk/hotbuffer/setup.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/hotbuffer/setup.py Fri May 26 17:48:18 2006
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+from distutils.core import setup, Extension
+
+VERSION = '1.0'
+DESCRIPTION = "Fast I/O buffers for binary protocols"
+LONG_DESCRIPTION = """
+A buffer class similar to Java NIO ByteBuffer that is meant to be used for
+network I/O that avoids creating temporary strings and from which binary data
+can be directly decoded.
+"""
+
+CLASSIFIERS = filter(None, map(str.strip,
+"""
+Environment :: Console
+Intended Audience :: Developers
+License :: OSI Approved :: MIT License
+Natural Language :: English
+Programming Language :: Python
+Topic :: Software Development :: Libraries :: Python Modules
+""".splitlines()))
+
+setup(
+ name="hotbuf",
+ version=VERSION,
+ description=DESCRIPTION,
+ long_description=LONG_DESCRIPTION,
+ classifiers=CLASSIFIERS,
+ author="Martin Blais",
+ author_email="blais at furius.ca",
+ url="http://furius.ca/python/hotbuf",
+ license="PSF License",
+ py_modules=['hotbuf'],
+ ext_modules=[
+ Extension("_hotbuf", ["Modules/_hotbuf.c"]),
+ ],
+)
+
Modified: sandbox/trunk/hotbuffer/test_hotbuf.py
==============================================================================
--- sandbox/trunk/hotbuffer/test_hotbuf.py (original)
+++ sandbox/trunk/hotbuffer/test_hotbuf.py Fri May 26 17:48:18 2006
@@ -99,8 +99,10 @@
b.clear()
b.setposition(100)
b.putstr(MSG)
+ b.setlimit(b.position)
b.setposition(100)
b.compact()
+ b.flip()
self.assertEquals(str(b), MSG)
def test_byte( self ):
More information about the Python-checkins
mailing list