def bezier_bounding_box(bez):
<EOL>try:<EOL><INDENT>bla = bez.large_arc<EOL>return bez.bbox()  <EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>if len(bez) == <NUM_LIT:4>:<EOL><INDENT>xmin, xmax = bezier_real_minmax([p.real for p in bez])<EOL>ymin, ymax = bezier_real_minmax([p.imag for p in bez])<EOL>return xmin, xmax, ymin, ymax<EOL><DEDENT>poly = bezier2polynomial(bez, return_poly1d=True)<EOL>x = real(poly)<EOL>y = imag(poly)<EOL>dx = x.deriv()<EOL>dy = y.deriv()<EOL>x_extremizers = [<NUM_LIT:0>, <NUM_LIT:1>] + polyroots(dx, realroots=True,<EOL>condition=lambda r: <NUM_LIT:0> < r < <NUM_LIT:1>)<EOL>y_extremizers = [<NUM_LIT:0>, <NUM_LIT:1>] + polyroots(dy, realroots=True,<EOL>condition=lambda r: <NUM_LIT:0> < r < <NUM_LIT:1>)<EOL>x_extrema = [x(t) for t in x_extremizers]<EOL>y_extrema = [y(t) for t in y_extremizers]<EOL>return min(x_extrema), max(x_extrema), min(y_extrema), max(y_extrema)<EOL>
returns the bounding box for the segment in the form
    (xmin, xmax, ymin, ymax).
    Warning: For the non-cubic case this is not particularly efficient.