As scw points out, you want an implementation of α-shapes.
Alpha shapes can be considered a generalisation of the convex hull. They were first described in 1981 in:
Edelsbrunner, H.; Kirkpatrick, D.; Seidel, R.; , "On the shape of a set of points in the plane," Information Theory, IEEE Transactions on , vol.29, no.4, pp. 551- 559, Jul 1983
Open source implementations exist for the environments you are interested in:
PostGIS
#PostGIS IfIf you are using the PostGIS stack, pgRouting's optional Driving Distance extension exposes an alpha shape implementation. I'm not sure if you can vary the alpha parameter, however.
Usage is below:
SELECT the_geom AS alpha_shape
FROM
points_as_polygon(
'SELECT id, ST_X(your_geom) AS x, ST_Y(your_geom) AS y FROM your_table');
Python
#Python ThereThere are probably many pythonPython modules you could use. I have heard good things about CGAL, a C++ computational geometry library. Python wrappers exist for parts of CGAL, including exposing CGAL's alpha shape implementation to Python.
Be aware that parts of CGAL are licensed under the QPL, which means that if you distribute your program, linked to CGAL, you may need to release it under the QPL. It is fine to keep your code proprietary if you do not redistribute your program code or binaries.