A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-July/046098.html below:

[Python-Dev] PyInstance_Check() and new-style classes

[Python-Dev] PyInstance_Check() and new-style classes [Python-Dev] PyInstance_Check() and new-style classesGreg Ewing greg at cosc.canterbury.ac.nz
Tue Jul 13 05:06:46 CEST 2004
Eric Wilhelm <ewilhelm at sbcglobal.net>:

> +       if ((obj->ob_type->tp_flags & Py_TPFLAGS_HEAPTYPE) || 
>           PyInstance_Check(obj)) {

I don't understand why you need to make this check.
Aren't you going to have to check individually anyway for all
the types you want to treat specially? If so, why not just

  if (PyString_CheckExact(obj)) {
    /* convert it to a Perl string */
  }
  elif (PyInt_CheckExact(obj)) {
    /* convert it to a Perl integer */
  }
  ...
  else {
    /* None of the above, wrap it generically */
  }

Using the CheckExact macros will ensure that you don't pick
up any subclasses of the built-in types.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4