Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:56:23+00:00 2026-06-14T14:56:23+00:00

Given a PyObject* in C++ how to determine if it is an instance of

  • 0

Given a PyObject* in C++ how to determine if it is an instance of PyLongDoubleScalarObject?

PyLongDoubleScalarObject is the corresponding numpy class to store 128bit floats (long double), which is defined in numpy/arrayscalars.h.

Using dynamic_cast doesn’t work as PyObject* non-polymorphic. When I look how to do something corresponding to dynamic_cast for PyObject then I mostly find a hint to use functions such as PyLong_Check, but I don’t find something like PyLongDouble_Check.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:56:24+00:00Added an answer on June 14, 2026 at 2:56 pm

    The C API equivalent to Python’s isinstance function is PyObject_TypeCheck, so you could do something like:

    if (PyObject_TypeCheck(obj, typeobject)) {
         /* obj matches the given type */
    }
    

    Alternatively, if you want to check the exact type of the object and not accept subtypes, you can check the type directly:

    if (Py_TYPE(obj) == typeobject) {
        /* obj is an instance of the given type and not a subclass */
    }
    

    Note that you need to pass the object representing the type at the Python level rather than the C struct defining the layout of instances. Looking at the numpy headers, it looks like the type object you’re after is probably &PyLongDoubleArrType_Type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

given a Python class hierarchy, say class Base: def method1 def method2 def method3
Given a PyObject* pointing to a python object, how do I invoke one of
Given: class StringRecord : INotifyPropertyChanged { public string Key { get; set; } //
Given a abstract factory implementation: public class FooFactory : IFooFactory { public IFoo Create(object
Given a class that keeps a registry of its Objects: class Person(object): __registry =
Given a list of LIs each LI includes a checkbox like so: <li class=contact>
Given a global vector list of ASCII codes and corresponding number values and a
Given: class FruitBasket { int apples = 0 int oranges = 0 } I
Given a pair of lat/lng values, how do I determine if the pair is
Given the following class template <typename T> class Plane { public: Plane<T>(T A, T

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.