Deleting all Features of a Vector Layer in pyQGIS

You could use the following code which is heavily based on the answer from this post: How to delete selected features in QGIS using Python

layer = iface.activeLayer()
with edit(layer):   
    for feat in layer.getFeatures():
        layer.deleteFeature(feat.id())

Edit:

Thanks to @GermánCarrillo, a more efficient method could be to delete all features at once:

layer = iface.activeLayer()
with edit(layer):
    listOfIds = [feat.id() for feat in layer.getFeatures()]
    layer.deleteFeatures( listOfIds )

In QGIS3 you can use truncate()

bool QgsVectorDataProvider::truncate()

Removes all features from the layer.