From: MRAB on
Rami Chowdhury wrote:
> On Tuesday 06 July 2010 22:42:25 rantingrick wrote:
>> On Jul 6, 9:11 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
>>
>> +use...(a)gmail.com> wrote:
>>> "pyni"! Pronounced like "tiny"! Yay!
>> hmm, how's about an alternate spelling... "pyknee", or "pynee", or
>> "pynie" ... considering those are not taken either?
>
> Pynie's taken too -- it's the Python implementation on the Parrot VM.
>
"PyNatInt" gets no hits on Google.
From: Alf P. Steinbach /Usenet on
* rantingrick, on 07.07.2010 07:42:
> On Jul 6, 9:11 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
> +use...(a)gmail.com> wrote:
>
>> "pyni"! Pronounced like "tiny"! Yay!
>
> hmm, how's about an alternate spelling... "pyknee", or "pynee", or
> "pynie" ... considering those are not taken either?

Hm, for pure shock value I think I'll use the acronym PYthon Native Interface
Support.

pynis! :-)

A set of C++ classes to ease the writing of extensions.

Like,


<code file="Ptr.h">
// progrock.pynis -- "Python Native Interface Support"
// A simple C++ framework for writing Python 3.x extensions.
//
// Copyright (C) Alf P. Steinbach, 2010.

#ifndef PYNIS_PTR_H
#define PYNIS_PTR_H
#include <progrock/cppx/devsupport/better_experience.h>


//----------------------------------------- Dependencies:

#include <Python.h>
#include <assert.h>
#include <algorithm>



//----------------------------------------- Interface:

namespace progrock{ namespace pynis {

enum DoAddRef { doAddRef };

class Ptr
{
private:
PyObject* p_;

public:
Ptr( PyObject* p = 0 ): p_( p )
{}

Ptr( PyObject* p, DoAddRef ): p_( p )
{
assert( p != 0 );
Py_INCREF( p_ );
}

Ptr( Ptr const& other ): p_( other.p_ )
{
Py_XINCREF( p_ );
}

~Ptr()
{
Py_XDECREF( p_ );
}

void swapWith( Ptr& other ) { std::swap( p_, other.p_ ); }
Ptr& operator=( Ptr other ) { swapWith( other ); return *this; }

PyObject* get() const { return p_; }

PyObject* release()
{
PyObject* const result = p_;
Py_XDECREF( p_ );
p_ = 0;
return result;
}
};

} } // namespace progrock::pynis


#endif
</code>


Cheers,

- Alf (shocked)

PS: Darn, forgot to google it. But I think it's unlikely the name's already in use!

--
blog at <url: http://alfps.wordpress.com>
From: Alf P. Steinbach /Usenet on
* Alf P. Steinbach /Usenet, on 08.07.2010 01:47:
>
> enum DoAddRef { doAddRef };
>
> class Ptr
> {
> private:
> PyObject* p_;
>
> public:
> Ptr( PyObject* p = 0 ): p_( p )
> {}
>
> Ptr( PyObject* p, DoAddRef ): p_( p )
> {
> assert( p != 0 );
> Py_INCREF( p_ );
> }
>
> Ptr( Ptr const& other ): p_( other.p_ )
> {
> Py_XINCREF( p_ );
> }
>
> ~Ptr()
> {
> Py_XDECREF( p_ );
> }
>
> void swapWith( Ptr& other ) { std::swap( p_, other.p_ ); }
> Ptr& operator=( Ptr other ) { swapWith( other ); return *this; }
>
> PyObject* get() const { return p_; }
>
> PyObject* release()
> {
> PyObject* const result = p_;
> Py_XDECREF( p_ );

Hark. This Py_XDECREF shouldn't be there, I don't know how it got there. The
whole point of 'release', with conventional semantics, is to /not/ decrement the
reference count.


> p_ = 0;
> return result;
> }
> };


Sorry for posting unfinished code,

- Alf


PS: "pyni" was a good name. But in use! When I thought about adding the "s" as
disambiguation I thought the pure shock value of that was funny in a way, but
now it doesn't seem funny. Is "pytes" (Python Extension Support) a good name?

--
blog at <url: http://alfps.wordpress.com>
From: rantingrick on
On Jul 7, 6:47 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
+use...(a)gmail.com> wrote:

> Hm, for pure shock value I think I'll use the acronym PYthon Native Interface
> Support.
>
> pynis! :-)

Well as long as you don't put your "pynis" *pointers* in "pynie" then
everything will be Ok! ;-)