Sunday, 15 August 2010

binary - Python integer to read-only buffer -


I am using cdb for a continuous database in python. I would like to add integer IDs to some strings, and I would not like to handle each of these integer IDs as strings, and instead of storing them as an integer, the CDB is either a string or a read-only buffer Is searching. Is there any way that I can store these keys as an integer instead of a string?

For example:

  cdb = cdb.cdbmake ("test.cdb", "test.cdb.tmp") key = 5 value = "some test string "# This is an error constructor throws. The (key, value) #TypeError: add () argument should be 1 string or read-only buffer, not int #this will work, but seems incompetent creator. According to the database, the string takes only the keys: ADD (str (key), value)   

ADD is an associative array: it maps the string to the strings (data).

Then you have to convert the integer first to string. I suggest that you wrap str in a utility function and forget about overhead.


No comments:

Post a Comment