Add a Custom c++ Class to Blender and drawing it in the viewport using an Addon Ok, what I'm asking could not be so mainstream. I'm writing an addon for blender that will add a better particle system, and I am in the process of reating an operator that spawns particles and animates them during time. 
Untill now I've used this procedure to create a particle object:


I created a plane,
Merged it at the center
removed doubles


So That I would have only a vertex. And then to add datas like particle age, the frame it was born, etc, I used object Custom Properties.

the problem is that Blender struggles to keep upp with thousands of different objects to the point where it doesn't even play the animation at all or just crashes. 

But I noticed that it could hold more than 20000 particles at a time without any problem. I want to state that I know python but not so much C++ or C, so excuse me if the following argument is wrong, but I think that blender cannot hold so many object cause they have much more to them than a single particle, for example an objects has Material Slot, Particle Systems, Location, And Much More and It's also treated in a completely different way than a particle which on the other side only has few properties. 

given the Argument is true (Escuse me if it isn't) could I create a simple class in a c++ file like this:

class better_particle{
    public;
    int age;
    vector Location;
    }


And create instead of a normal object a better_particle object to represent each particle, and also important draw that better_particle Class into the viewport using for example a Rectagle (Like For Example blender's Default Particle)?

I think this is possible modifying the Blender source code to fit my needs, but I want to keep it a Blender addon and not just a custom Build.

So is this possible? 

EDIT:
I Cannot use Animation Nodes as it hasn't the flexibility of an addon, and The Tree as long as I know it's executed each frame, so particle will not be able to spawn or move in subframes and this would lead to lagging streaks of particles. The same problem that there's in blender by default.

WHAT I'm TRYING TO ACHIEVE:

I've Written this simple Python Code:

class particle:
pass

created_particles = []
for f in range(0,40): #For each of 40 Frames
    for i in range(0, 30): # Create 30 Particle
        pp = particle() ##Create New Particle Object
        pp.location = (0,0,0) #Add location variable
        pp.spawn_frame = f
        created_particles.extend([pp]), 


As you can see it just creates some particle object ad assign them some variables.
Now I need to Create the particle class in c++ with something like the lines up above and then in Python do something like: 

p = bpy.ops.add_particle()  
p.location = (0,0,0)
etc  


and the Last Thing I need to do it's to create a drawing function in c++ do display these particle objects.
I suggest writing your code in Python first to keep it simple and get results quickly (especially when you have little experience with where are the bottlenecks).

Then you need to benchmark it and find where the bottlenecks are.


if they are on Blender's side, porting your code to c/c++ will have little to no effect. Building your own Blender is the solution.
if they are on your code's side consider using Numpy module rather than writing custom C/C++ code first. If you want speedup on arrays or math, it is often enough. Threading can also help.

For most use cases when you need to wrap C/C++ classes the ctypes module is all you need.

You can also use Cython to expose parts of C/C++ library to Python.

For another solution for Python binding to C/C++ code look into Boost.Python:


  The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes, functions and objects to Python, and vice-versa, using no special tools



Last thing to consider is that Blender 2.8 version is behind corner and a lot of things will change including the particle system. Some coding time on an addon this big might be wasted when it will release and you will have to re-work it or it becomes redundant by the new native system.