Skip to content

possible to sample python cpp extensions ...? #370

Closed

Description

@breathe

Wondering if there's anyway I could get pyinstrument to see into cpp callstacks ... I like pyinstrument and the fact that it can be started up within process.

Even if this feature was difficult to achieve in general -- I'm wondering if there might be a way I could hack together something simpler that would work for my specific codebase. In my codebase, I use nanobind to define an extension module in cpp, and all time spent within is a result of a python function call (python calls into cpp, never the reverse).

I could also conceivably add some code to my python -> cpp callsites to try and make this analysis more feasible ...

Activity

  1. joerick commented on May 24, 2025

    @joerick
    Owner

    pyinstrument uses sys.setprofile. As I understand it, I don't think it's possible to profile arbitrary C++ though this interface.

    I'm on mac, I've had decent luck with profiling with Instruments.app, but I don't know how to set this up for a Python extension.

  2. Repository owner locked and limited conversation to collaborators on May 24, 2025
  3. converted this issue into a discussion #378 on May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions