From david.car at earthlink.net Wed Jun 13 23:22:32 2007 From: david.car at earthlink.net (David Car) Date: Wed, 13 Jun 2007 17:22:32 -0400 Subject: [CentralOH] New Types Message-ID: <200706131722.32954.david.car@earthlink.net> Hey Python Gang, I have a question about new types in Python. Just finished reading up and trying a few things out, but I'm a little confused about one thing. When declaring a new type, we basically have two new structures. One is the per instance structure (your PyObject structure), which is basically an expansion of the PyObject structure. At the beginning of that structure is the macro declaration of PyObject_HEAD which contains the reference counter and a pointer to the new type which is a structure of _typeobject. Then for your new type (i.e. your _typeobject structure) there is a place holder for the size of your per instance PyObject structure along with all the necessary function pointers your new type will support. My question is this: Where and when does the pointer in your per instance PyObject structure get set? How does the interpreter know that your PyObject structure is related to your PyTypeObject structure? Since your PyObject structure naming convention is not tied to your PyTypeObject name, how are the two associated? I see how your type is statically instantiated in the initialization, but I don't see where your per instance PyObject is related to it? Is it simply that the two structures co-exist in the same module? Thanks. -- Regards, David From pythondevdang at lazytwinacres.net Thu Jun 14 13:04:38 2007 From: pythondevdang at lazytwinacres.net (Daniel 'Dang' Griffith) Date: Thu, 14 Jun 2007 07:04:38 -0400 Subject: [CentralOH] New Types In-Reply-To: References: Message-ID: <6.2.3.4.2.20070614065726.02c13298@mail.lazytwinacres.net> I definitely don't know the answer. Have you tried posting to comp.lang.python? For a while, I was reading the pythondev mailing list, and there was quite a bit about PyObjects and such, but they were working at a lower level. I would try comp.lang.python first, and then maybe subscribe to the pythondev mailing list and send a question there. Isn't PyObject used for interfacing with C/non-Python code? What kind of fun are you up to? --dang At 06:00 AM 6/14/2007, centraloh-request at python.org wrote: >Date: Wed, 13 Jun 2007 17:22:32 -0400 >From: David Car >Subject: [CentralOH] New Types >I have a question about new types in Python. Just finished reading up and >trying a few things out, but I'm a little confused about one thing. When >declaring a new type, we basically have two new structures. One is the per >instance structure (your PyObject structure), which is basically an expansion >of the PyObject structure. At the beginning of that structure is the macro >declaration of PyObject_HEAD which contains the reference counter and a >pointer to the new type which is a structure of _typeobject. Then for your >new type (i.e. your _typeobject structure) there is a place holder for the >size of your per instance PyObject structure along with all the necessary >function pointers your new type will support. My question is this: Where >and when does the pointer in your per instance PyObject structure get set? >How does the interpreter know that your PyObject structure is related to your >PyTypeObject structure? Since your PyObject structure naming convention is >not tied to your PyTypeObject name, how are the two associated? I see how >your type is statically instantiated in the initialization, but I don't see >where your per instance PyObject is related to it? Is it simply that the two >structures co-exist in the same module? Thanks. From david.car at earthlink.net Thu Jun 14 14:07:00 2007 From: david.car at earthlink.net (David Car) Date: Thu, 14 Jun 2007 08:07:00 -0400 Subject: [CentralOH] New Types In-Reply-To: <6.2.3.4.2.20070614065726.02c13298@mail.lazytwinacres.net> References: <6.2.3.4.2.20070614065726.02c13298@mail.lazytwinacres.net> Message-ID: <200706140807.00365.david.car@earthlink.net> On Thursday 14 June 2007 07:04:38 Daniel 'Dang' Griffith wrote: > I definitely don't know the answer. Have you tried posting to > comp.lang.python? For a while, I was reading the pythondev mailing list, > and there was quite a bit about PyObjects and such, but they were working > at a lower level. I would try comp.lang.python first, and then maybe > subscribe to the pythondev mailing list and send a question there. > Isn't PyObject used for interfacing with C/non-Python code? What kind of > fun are you up to? > --dang > Hey Dang, No, I haven't tried comp.lang.python yet. I've posted to python-forums.org and no response there. I didn't know about comp.lang.python though, so thanks for that tip. I'm just trying to learn to write extensions/new types in Python to interface with some other C code. So far so good, everything works. There's just that little nagging question I have about how it's setting a certain pointer in the PyObject structure for a new type. I don't see where or how this is happening in the initialization chain when you create a new object of your new type. It's one of those things I can just put on the back burner and keep moving forward, but it would be nice to know to make everything clear. Thanks for the comp.lang.python site. I will definitely throw a post up there. All the best. -- Regards, David From wam at cisco.com Thu Jun 14 21:01:10 2007 From: wam at cisco.com (William McVey) Date: Thu, 14 Jun 2007 15:01:10 -0400 Subject: [CentralOH] New Types In-Reply-To: <200706140807.00365.david.car@earthlink.net> References: <6.2.3.4.2.20070614065726.02c13298@mail.lazytwinacres.net> <200706140807.00365.david.car@earthlink.net> Message-ID: <1181847670.28139.10.camel@tardis.cisco.com> On Thu, 2007-06-14 at 08:07 -0400, David Car wrote: > I'm just trying to learn to write extensions/new types in Python to > interface > with some other C code. So far so good, everything works. There's > just that > little nagging question I have about how it's setting a certain > pointer in > the PyObject structure for a new type. Personally, I've never found myself needing to work at that level to write an extension. If I really need to interface with a bit of C code, I would generally write up a swig interface. Now days though, I am now a big BIG fan of building hooks to C code using the ctypes module. I will generally write a direct python mapping of a C library using ctypes, then will use that one-to-one mapping of a C library accessible in python via ctypes to build a python class that gives the C library a pythonic structure and feel (objects, iterators, nice calling conventions, etc)... It's been a winning strategy for me, and the fact that I can avoid having to write C code again has been especially nice. -- William P.S. I've heard good things about pyrex as well for bridging C code to python, although I've not personally used it. From jglands at att.net Tue Jun 19 21:14:25 2007 From: jglands at att.net (Jesse G. Lands) Date: Tue, 19 Jun 2007 19:14:25 +0000 Subject: [CentralOH] Hello all Message-ID: <20070619191425.7f836ff3@LandsTravel> Just want to introduce myself. I'm a system administrator on Wright Patterson AFB. I recently moved back to Ohio from Georgia. I left Ohio at the end of 1995 to join the Army. After I left the Army I stayed in the South working for the military as a contractor. I had the opportunity to transfer back up here with my company and took it. I'm a big Linux user. Every job I've had since 98 I've tried my hardest to put Linux in use there. Unfortunately it's an up hill battle as I'm sure you're all aware. Even more so with the military. How I got introduced into Python: I was working for the military as a contractor. Got sent to Oman for a few months and took along a book on Perl to learn a little scripting. While there I found a game being developed in Python, I had my wife send me a book on it and dropped the Perl book. I've picked it up a few times for reference, but it's been mostly Python since. A few years ago I had chance to take a class at 'The Big Nerd Ranch' taught by Mark Lutz. I was blown away. Though Mark doesn't teach with the Big Nerd Ranch anymore, he teaches his own and I would highly recommend it. I learned more in that week then I had the three years hacking away on my own little projects. Well I'm glad that there is some type of Python group in Central Ohio and hopefully we can get it going into a more active group. Perhaps a group project or something of the sort. -- JLands Arch Current Registered Linux User #290053 Do not meddle in the affairs of cats, for they are subtle and will piss on your computer. --Bruce Graham From david.car at earthlink.net Wed Jun 20 05:17:21 2007 From: david.car at earthlink.net (David Car) Date: Tue, 19 Jun 2007 23:17:21 -0400 Subject: [CentralOH] Hello all In-Reply-To: <20070619191425.7f836ff3@LandsTravel> References: <20070619191425.7f836ff3@LandsTravel> Message-ID: <200706192317.21312.david.car@earthlink.net> Hey Jesse, Welcome back to Ohio. I know what you mean about getting Linux into your work environment. I work for the Air Force (civilian) and although we do have a Linux cluster that I can be thankful for, I really would like it installed on my laptop where I do much of my work. It's an uphill battle as you say, but I'll be fighting it this fall nonetheless. It's a good thing Python is cross platform. So if I lose the battle, I probably could still use Python regardless. I love Python. Started using it with Matplotlib for plotting my data and doing some numerical analysis. I can't read enough since. On Tuesday 19 June 2007 15:14:25 Jesse G. Lands wrote: > group project or something of the sort. That would be fun. -- Regards, David From jglands at att.net Wed Jun 20 18:31:24 2007 From: jglands at att.net (Jesse G. Lands) Date: Wed, 20 Jun 2007 16:31:24 +0000 Subject: [CentralOH] Hello all In-Reply-To: <200706192317.21312.david.car@earthlink.net> References: <20070619191425.7f836ff3@LandsTravel> <200706192317.21312.david.car@earthlink.net> Message-ID: <20070620163124.39e36895@LandsTravel> > Welcome back to Ohio. Thanks, it's been a while. > I know what you mean about getting Linux into > your work environment. I work for the Air Force (civilian) and > although we do have a Linux cluster that I can be thankful for, I > really would like it installed on my laptop where I do much of my > work. It's an uphill battle as you say, but I'll be fighting it this > fall nonetheless. It's a good thing Python is cross platform. So if > I lose the battle, I probably could still use Python regardless. I tried to get our organization to replace the Micro$oft server with a linux cluster as the Oracle server. The database they run is terribly slow. Unfortunately there a 'people' who know exactly what they are doing and choose to keep it on Windows. I've developed a few small scripts to use at work, but most of my hacking comes at home. If it's not .NET then it couldn't possibly be worth anything. > On Tuesday 19 June 2007 15:14:25 Jesse G. Lands wrote: > > group project or something of the sort. > > That would be fun. > It would be nice to maybe put some scripts together or a large project. Perhaps we could eventually get to a script repository for stuff down by our group. Hopefully we can get enough interest soon to have meetings and speakers. Seems like Catherine does stuff like that so we can keep her gainfully employed in speaking for a while. Well good to be a part of the group and anything I can do to help spread the Python 'word' let me know. -- JLands Arch Current Registered Linux User #290053 Gracitation is not responsible for people falling in love -- Albert Einstein From jglands at att.net Fri Jun 29 16:05:09 2007 From: jglands at att.net (Jesse G. Lands) Date: Fri, 29 Jun 2007 14:05:09 +0000 Subject: [CentralOH] Python Contract Message-ID: <20070629140509.3990cb1b@LandsTravel> Debi Calim from Surrex contacted me about a 3 month contract position converting Perl to Python or interfacing it. Anyone interested can call her at 937-427-5478 or email dcalim at surrex.com Not affiliated with them and I get nothing out of it. Just passing along an opportunity. -- JLands Arch Current Registered Linux User #290053 To err is human--and to blame it on a computer is even more so. --Robert Orben From david.car at earthlink.net Sat Jun 30 02:54:32 2007 From: david.car at earthlink.net (David Car) Date: Fri, 29 Jun 2007 20:54:32 -0400 Subject: [CentralOH] Python Contract In-Reply-To: <20070629140509.3990cb1b@LandsTravel> References: <20070629140509.3990cb1b@LandsTravel> Message-ID: <200706292054.33755.david.car@earthlink.net> On Friday 29 June 2007 10:05:09 Jesse G. Lands wrote: > Debi Calim from Surrex contacted me about a 3 month contract position > converting Perl to Python or interfacing it. Anyone interested can > call her at 937-427-5478 or email dcalim at surrex.com > > Not affiliated with them and I get nothing out of it. Just passing > along an opportunity. Thanks Jesse for the heads up. -- Regards, David