Recently, L. Rozansky and E. Witten associated to any hyper-Kähler manifold X a system of ’weights‘ (numbers, one for each trivalent graph) and used them to construct invariants of topological 3-manifolds. We give a simple cohomological definition of these weights in terms of the Atiyah class of X (the obstruction to the existence of a holomorphic connection). We show that the analogy between the tensor of curvature of a hyper-Kähler metric and the tensor of structure constants of a Lie algebra observed by Rozansky and Witten, holds in fact for any complex manifold, if we work at the level of cohomology and for any Kähler manifold, if we work at the level of Dolbeault cochains. As an outcome of our considerations, we give a formula for Rozansky–Witten classes using any Kähler metric on a holomorphic symplectic manifold.