473,835 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Python Strinh Immutability Broken!


"Gabriel Genellina":
>To avoid altering the equilibrium of the whole universe, use
ctypes.create_ string_buffer:
http://python.net/crew/theller/ctype...tal-data-types
Thanks Gabriel – looks like I really have to spend more time with that
excellent document.
Patrick Maupin:
>Whenever I do low-level stuff like this, I'm in one of two modes:

Mode #1: I'm using somebody else's C library and the overhead of
doing so is small.

Mode #2: I need to code my own low-level stuff (for speed, IO access,
whatever).
This seems to be where I am at.
>
In mode 1, I try not to break out a compiler. ctypes is great for
this, and the results are "pure python" to the extent that you can
give pure python to someone else with the same C library, and it will
work. No muss, no fuss, no makefile, no question that ctypes is
awesome stuff.

In mode 2, I have to break out a compiler. I almost never do this
without ALSO breaking out Pyrex. Pyrex is also awesome stuff, and in
Pyrex, you can easily create a (new) Python string for your results
without having to worry about reference counting or any other really
nasty low level interpreter details. You can code a lot of stuff in
pure Pyrex, and you can easily mix and match Pyrex and C.

Pyrex and ctypes are both tools which let me connect to non-Python
code without having to remember to handle Python interpreter internals
correctly. If I can get by with ctypes, I do, but if I actually have
to code in something other than Python to get the job done, I bypass
ctypes and go straight for Pyrex.
Don’t know anything about Pyrex except that it is not in the
standard library on Suse – will try to read up on it. Thanks.

Terry Reedy:
http://python.net/crew/theller/ctype...al.html#arrays
>Which essentially is the bytearray type of 3.0.
How does it differ from plain old array.array(b,” The quick brown fox”)?

- Hendrik
Aug 26 '08 #1
0 1233

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

105
5220
by: Peter Hickman | last post by:
Well after all this discussion it would appear that a 'Python like' language has appeared => Prothon. http://www.prothon.org/index.html Very alpha, sort of like Python (if you consider the indenting is what makes Python unique) and sort of Ruby in its use of prefixes to define scoping etc (although there is no reference to this trait being borrowed from Ruby). It also quotes Self as being an influence.
0
1538
by: Peter Otten | last post by:
QOTW: "try...except and try...finally are really two completely different statements with different purposes." - Carl Banks "Zope and ZODB do incredibly complex stuff as side effects in what Guido surely thought of as 'tiny hooks'. He had in mind that hasattr() might look for a key in a dict or list, and suppress a harmless KeyError or IndexError, not start World War III and then send an endless sequence of Terminators back in time to...
3
6380
by: Terry Hancock | last post by:
Is there an *easy* way to make an object immutable in python? Or perhaps I should say "one obvious way to do it"? Oughtn't there to be one? I've found a thread on how to do this, which essentially says something like "redefine __setattr__, __delattr__, __hash__, __eq__, __setitem__, delitem__ ... and probably some other stuff too".
267
10894
by: Xah Lee | last post by:
Python, Lambda, and Guido van Rossum Xah Lee, 2006-05-05 In this post, i'd like to deconstruct one of Guido's recent blog about lambda in Python. In Guido's blog written in 2006-02-10 at http://www.artima.com/weblogs/viewpost.jsp?thread=147358
122
5556
by: C.L. | last post by:
I was looking for a function or method that would return the index to the first matching element in a list. Coming from a C++ STL background, I thought it might be called "find". My first stop was the Sequence Types page of the Library Reference (http://docs.python.org/lib/typesseq.html); it wasn't there. A search of the Library Reference's index seemed to confirm that the function did not exist. A little later I realized it might be called...
0
772
by: Roy Smith | last post by:
In article <mailman.2119.1219612653.922.python-list@python.org>, "Hendrik van Rooyen" <mail@microcorp.co.zawrote: Reminds me of that great old song from "Saturday Night Hacker": Oh, oh, oh, oh. Flaying alive, flaying alive. Oh, oh, oh, oh. Flaying ali-i-i-i-i-ive!
0
165
by: Simon Brunning | last post by:
2008/8/25 Hendrik van Rooyen <mail@microcorp.co.za>: 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. -- Cheers, Simon B.
0
160
by: Lie | last post by:
On Oct 11, 5:27 am, "Hendrik van Rooyen" <m...@microcorp.co.zawrote: Not necessarily. You've mentioned two ways. PS: Umm, a little bit off note: set is a built-in name, I'm a little confused whether you meant on creating a "set" or setting the push bit to 1, if the latter case it might be better to use set and clear instead of passing a second parameter (and also to choose another name).
0
9808
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9652
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10812
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10523
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7766
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3995
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.