[Python-checkins] r46500 - sandbox/trunk/hotbuffer/README.txt sandbox/trunk/hotbuffer/test_hotbuf.py
martin.blais
python-checkins at python.org
Sun May 28 17:20:43 CEST 2006
Author: martin.blais
Date: Sun May 28 17:20:42 2006
New Revision: 46500
Modified:
sandbox/trunk/hotbuffer/README.txt
sandbox/trunk/hotbuffer/test_hotbuf.py
Log:
Minor bug fix and added docs
Modified: sandbox/trunk/hotbuffer/README.txt
==============================================================================
--- sandbox/trunk/hotbuffer/README.txt (original)
+++ sandbox/trunk/hotbuffer/README.txt Sun May 28 17:20:42 2006
@@ -13,9 +13,9 @@
.. contents::
..
1 TODO
- 1.1 Other Features
- 1.2 Ideas
- 1.3 Documentation
+ 1.1 Question
+ 1.2 Other Features
+ 1.3 Ideas
TODO
@@ -38,6 +38,15 @@
- Check if there a tp_file protocol and if there is, use that
instead to provide the interface.
+ See file_read() from fileobject.c, you need to make it file_read_guts() and
+ create file_read() that allocates a string like before, but also add
+ file_readbuf() that reads directly into a writable buffer.
+
+ Note the presence of readinto() as well, as present but deprecated. Search
+ the ML for readinto()'s story.
+
+* Fix the changes to struct and socket with the right types:
+
* Implement absolute get/put methods (getabs(n), putabs(n, data))
* The hot buffer can unpack in C, similarly implement pack() in C.
@@ -58,6 +67,29 @@
size of the minimal line/message that you may ever encounter,
otherwise you will have to write special parsing routines.
+Question
+--------
+
+* In the buffer protocol, what is the difference between the
+ read-only/read-write buffer interfaces and the char-buffer interface?
+
+ >
+ > In the buffer protocol, there are four functions::
+ >
+ > typedef int (*getreadbufferproc)(PyObject *, int, void **);
+ > typedef int (*getwritebufferproc)(PyObject *, int, void **);
+ > typedef int (*getsegcountproc)(PyObject *, int *);
+ > typedef int (*getcharbufferproc)(PyObject *, int, char **);
+ >
+ > What is the difference between the read-only/read-write and the char-buffer
+ > functions? (apart from the type) What was the original intention of this
+ > interface?
+ >
+ > Also, why is there a Py_ssize_t version of this?
+ >
+
+
+
Other Features
--------------
Modified: sandbox/trunk/hotbuffer/test_hotbuf.py
==============================================================================
--- sandbox/trunk/hotbuffer/test_hotbuf.py (original)
+++ sandbox/trunk/hotbuffer/test_hotbuf.py Sun May 28 17:20:42 2006
@@ -486,8 +486,8 @@
# Loop over all the messages in the current buffer.
while hot:
# Read the length and parse the message.
- length = hot.getbyte() # No error can occur here, since we're
- # still hot.
+ # No error can occur here, since we're hot.
+ length = hot.getbyte()
if len(hot) < length:
# Rollback the length byte and exit the loop to fill
# the buffer with new data.
@@ -514,10 +514,15 @@
hot.compact()
s = read(len(hot))
if not s:
+ hot.flip()
break # Finished the input, exit.
hot.putstr(s)
hot.flip()
+ # Process a truncated message. Maybe pass a truncated=1 flag?
+ if hot:
+ process_msg(hot)
+
def test_netstrings( self ):
"""
Test for parsing netstrings.
More information about the Python-checkins
mailing list