Re: Python String Immutability Broken!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hendrik van Rooyen

    Re: Python String Immutability Broken!


    "Simon Brunning":
    >You can indeed use ctypes to modify the value of a string - see
    ><http://tinyurl.com/5hcnwl>. You can use it to crash the OS, too.
    >
    >My advice - don't.
    Thanks for the link.

    Any advice on what to do or use as an I/O structure for dissemination?


    Ken Seehart:

    8<----------- using ctypes to make 1+14 = 10 ------------------
    >I love ctypes. So cool. It's not supposed to be safe.
    And here I thought I was weird…
    Life is either a daring adventure or nothing. Security does not
    exist in nature, nor do the children of men as a whole experience
    it. Avoiding danger is no safer in the long run than exposure.
    *Helen Keller <http://www.quotationsp age.com/quotes/Helen_Keller/>*
    /US blind & deaf educator (1880 - 1968)/
    >
    >Of course I would not hire anyone who believes this quote, other than
    >Helen Keller, if she were still with us.
    Why not? – as I see it, the Keller quote states the literal truth of
    the matter – we all live under an illusion of security – but then
    that might just be because I am South African, and the country is
    run by cattle thieves.
    >It is quite possible to write a small program that works using abused
    >strings. But my life better not depend on it. Among other things, if
    >you use the abused string as a key anywhere, you will not get correct
    >results. Trying to change the length of the string will cause
    >disasters. Lengthening a string will corrupt memory, and shortening the
    >string will not shorten it but rather embed '\0' in it.
    Understood. – remember I am using it as a kind of array of “pseudoports”
    - memory representations of what goes on on wires on the outside.

    So only a real madman would try to impute the kind of cross bit
    correlation needed to use the bunch of bits as a key. The length would
    be fixed, governed by the existence of real hardware on the outside.

    Ken Seehart again:
    >Yes, there is a better way. Use a character array instead of a string.
    The original reason I used a string directly instead of array.array was
    to try to skip the serialisation step when disseminating the information
    via sockets.

    As you can appreciate, this is all “hot stuff” as it represents said
    wire states, and is of interest system wide.

    So lets explore this further – lets say I use two arrays – one to
    represent the stuff that must be output, and one to represent the
    latest inputs read.

    Then, I think, first prize would be the ability to “publish” that
    information as a shared memory block, that can be accessed by other
    python processes. Then it will be possible to a priori “chop up
    the ownership” of the various bits, so that a process can simply
    monitor the bits of interest to it, setting or clearing the bits
    of the outputs it is responsible for. In this way the work could
    be divided amongst many processes.

    Then, on a periodic basis, the I/O would be done, much like one
    would do it in an embedded system using an interrupt driven ticker
    routine.

    That would be really cool.

    Does anybody know how to get such memory sharing done in Python?
    (Linux only)

    - Hendrik



Working...